Made statistics to keep track of also: bad guys squished, shots, time needed and...
[supertux.git] / src / statistics.h
1 //
2 //  SuperTux -  A Jump'n Run
3 //  Copyright (C) 2004 Ricardo Cruz <rick2@aeiou.pt>
4 //
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License
7 //  as published by the Free Software Foundation; either version 2
8 //  of the License, or (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 Free Software
17 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 //  02111-1307, USA.
19
20 #ifndef SUPERTUX_STATISTICS_H
21 #define SUPERTUX_STATISTICS_H
22
23 using namespace SuperTux;
24
25 namespace SuperTux {
26 class LispReader;
27 class LispWriter;
28 class DrawingContext;
29 }
30
31 enum {
32   SCORE_STAT,
33   BADGUYS_SQUISHED_STAT,
34   SHOTS_STAT,
35   TIME_NEEDED_STAT,
36   JUMPS_STAT,
37   NUM_STATS
38 };
39
40 /** This class is a layer between level and worldmap to keep
41  *  track of stuff like scores, and minor, but funny things, like
42  *  number of jumps and stuff */
43
44 class Statistics
45 {
46 public:
47   Statistics();
48   ~Statistics();
49
50   /// read statistics from lisp file
51   void parse(LispReader& reader);
52   /// write statistics to lisp file
53   void write(LispWriter& writer);
54
55   /* Draw to the worldmap or a game message */
56   // TODO: make this functions working
57   void draw_worldmap_info(DrawingContext& context);
58   void draw_message_info(DrawingContext& context);
59
60   void add_points(int stat, int points);
61   int get_points(int stat);
62
63   void set_points(int stat, int points);
64
65   void reset();
66
67   /* Give another Statistics object, find the best of each one */
68   void merge(Statistics& stats);
69
70   /* Add two statistic objects */
71   void operator+=(const Statistics& o);
72
73 private:
74   int stats[NUM_STATS];
75 };
76
77 extern Statistics global_stats;
78
79 #endif /*SUPERTUX_STATISTICS_H*/