2 // Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 #include "utils/lispreader.h"
20 #include "utils/lispwriter.h"
21 #include "statistics.h"
23 Statistics global_stats;
25 Statistics::Statistics()
30 Statistics::~Statistics()
35 Statistics::parse(LispReader& reader)
37 reader.read_int("score", stats[SCORE_STAT]);
41 Statistics::write(LispWriter& writer)
43 writer.write_int("score", stats[SCORE_STAT]);
47 Statistics::add_points(int stat, int points)
49 stats[stat] += points;
53 Statistics::get_points(int stat)
61 for(int i = 0; i < MAX_STATS; i++)
66 Statistics::merge(Statistics& stats_)
68 stats[SCORE_STAT] = std::max(stats[SCORE_STAT], stats_.stats[SCORE_STAT]);
72 Statistics::operator+=(const Statistics& stats_)
74 stats[SCORE_STAT] += stats_.stats[SCORE_STAT];