| [193] | 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" |
|---|
| [197] | 25 | #include <vector> |
|---|
| [193] | 26 | namespace statistics { |
|---|
| 27 | |
|---|
| 28 | class Statistics { |
|---|
| 29 | public: |
|---|
| 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 | |
|---|
| 47 | private: |
|---|
| 48 | /** |
|---|
| 49 | * Saves the current status of the statistics object. |
|---|
| 50 | */ |
|---|
| 51 | void save(); |
|---|
| 52 | |
|---|
| 53 | int games_started; |
|---|
| 54 | int games_finished; |
|---|
| [197] | 55 | std::vector<int> score_distribution; |
|---|
| [193] | 56 | configuration::Configuration *backend; |
|---|
| 57 | }; |
|---|
| 58 | |
|---|
| [197] | 59 | const int score_distribution_granuality = 50; |
|---|
| 60 | // anything above the following score will be in the same slot |
|---|
| 61 | const int score_distribution_max = 500; |
|---|
| 62 | const int score_distributions_slots = score_distribution_max/score_distribution_granuality+1; |
|---|
| 63 | |
|---|
| [193] | 64 | } //namespace |
|---|
| 65 | |
|---|
| 66 | #endif |
|---|
| 67 | |
|---|