Collecting basic statistics from won games
[impuzzle] / src / statistics.h
diff --git a/src/statistics.h b/src/statistics.h
new file mode 100644 (file)
index 0000000..f2fa380
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef STATISTICS_H
+#define STATISTICS_H
+
+#include <QObject>
+#include <QList>
+
+class Statistics : public QObject
+{
+    Q_OBJECT
+
+public:
+    enum Difficulty {
+        easyDifficulty = 0,
+        hardDifficulty
+    };
+
+    static Statistics *instance();
+
+    int gameCount(Difficulty difficulty) const;
+
+    int totalGameCount() const;
+
+    qreal averageMoves(Difficulty difficulty) const;
+
+    int minMoves(Difficulty difficulty) const;
+
+    int maxMoves(Difficulty difficulty) const;
+
+public slots:
+    void addNewScore(int moves, Difficulty difficulty);
+
+    void increaseGameCount(Difficulty difficulty);
+
+    void readFile();
+
+    void saveFile();
+
+private:
+    Statistics(QObject *parent = 0);
+
+    static Statistics *instance_;
+
+    QList<int> moves_;
+    QList<int> minMoves_;
+    QList<int> maxMoves_;
+    QList<int> games_;
+};
+
+#endif