source: trunk/src/statistics.h @ 197

Last change on this file since 197 was 197, checked in by guyru, 6 years ago

Save score distribution

File size: 2.3 KB
Line 
1/***************************************************************************
2 *   Copyright (C) 2006-2009 by Guy Rutenberg   *
3 *   guyrutenberg@gmail.com   *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 *                                                                         *
10 *   This program is distributed in the hope that it will be useful,       *
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13 *   GNU General Public License for more details.                          *
14 *                                                                         *
15 *   You should have received a copy of the GNU General Public License     *
16 *   along with this program; if not, write to the                         *
17 *   Free Software Foundation, Inc.,                                       *
18 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19 ***************************************************************************/
20
21#ifndef OPENYAHTZEE_STATISTICS_INC
22#define OPENYAHTZEE_STATISTICS_INC
23
24#include "configuration.h"
25#include <vector>
26namespace statistics {
27
28class Statistics {
29public:
30        Statistics(configuration::Configuration *backend);
31        /**
32         * Records that a new game has been started.
33         */
34        void game_started();
35
36        /**
37         * Records that a game was ended.
38         * \param score The score the game ended with.
39         */
40        void game_finished(int score);
41
42        /**
43         * Resets the statistics data.
44         */
45        void reset();
46
47private:
48        /**
49         * Saves the current status of the statistics object.
50         */
51        void save();
52
53        int games_started;
54        int games_finished;
55        std::vector<int> score_distribution;
56        configuration::Configuration *backend;
57};
58
59const int score_distribution_granuality = 50;
60// anything above the following score will be in the same slot
61const int score_distribution_max = 500;
62const int score_distributions_slots = score_distribution_max/score_distribution_granuality+1;
63
64} //namespace
65
66#endif
67
Note: See TracBrowser for help on using the repository browser.