3 // SuperTux (Statistics module)
4 // Copyright (C) 2004 Ricardo Cruz <rick2@aeiou.pt>
5 // Copyright (C) 2006 Ondrej Hosek <ondra.hosek@gmail.com>
6 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #ifndef SUPERTUX_STATISTICS_H
23 #define SUPERTUX_STATISTICS_H
27 namespace lisp { class Writer; }
28 namespace lisp { class Lisp; }
32 /** This class is a layer between level and worldmap to keep
33 * track of stuff like scores, and minor, but funny things, like
34 * number of jumps and stuff */
38 int coins; /**< coins collected */
39 int total_coins; /**< coins in level */
40 int badguys; /**< badguys actively killed */
41 int total_badguys; /**< (vincible) badguys in level */
42 float time; /**< seconds needed */
43 int secrets; /**< secret areas found */
44 int total_secrets; /**< secret areas in level */
47 Statistics(); /**< Creates new statistics, call reset() before counting */
50 /// read statistics from lisp file
51 void parse(const lisp::Lisp& lisp);
52 /// write statistics to lisp file
53 void write(lisp::Writer& writer);
55 void draw_worldmap_info(DrawingContext& context); /**< draw worldmap stat HUD */
56 void draw_message_info(DrawingContext& context, std::string title); /**< draw stats at level start */
57 void draw_endseq_panel(DrawingContext& context, Statistics* best_stats, Surface* backdrop); /**< draw panel shown during level's end sequence */
59 void reset(); /**< Set stats (but not totals) to zero */
60 void merge(Statistics& stats); /**< Given another Statistics object finds the best of each one */
61 void operator+=(const Statistics& o); /**< Add two Statistics objects */
63 void declare_invalid(); /**< marks statistics as invalid for their entire lifetime (e.g. after cheating). Invalid statistics will not be merged or drawn. */
66 bool valid; /**< stores whether this statistics can be trusted */
67 Timer timer; /**< for draw_worldmap_info: time until switching to next stat */
68 int display_stat; /**< for draw_worldmap_info: which stat is currently displayed */
71 #endif /*SUPERTUX_STATISTICS_H*/