3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "lisp/writer.h"
22 #include "lisp/lisp.h"
23 #include "player_status.h"
24 #include "resources.h"
26 static const int START_LIVES = 4;
27 static const int MAX_LIVES = 99;
29 PlayerStatus player_status;
31 PlayerStatus::PlayerStatus()
36 max_score_multiplier(1)
40 void PlayerStatus::reset()
46 max_score_multiplier = 1;
50 PlayerStatus::incLives()
54 sound_manager->play_sound("lifeup");
58 PlayerStatus::incCoins()
65 sound_manager->play_sound("coin");
69 PlayerStatus::write(lisp::Writer& writer)
73 writer.write_string("bonus", "none");
76 writer.write_string("bonus", "growup");
79 writer.write_string("bonus", "fireflower");
82 writer.write_string("bonus", "iceflower");
85 std::cerr << "Unknown bonus type.\n";
86 writer.write_string("bonus", "none");
89 writer.write_int("lives", lives);
90 writer.write_int("coins", coins);
91 writer.write_int("max-score-multiplier", max_score_multiplier);
95 PlayerStatus::read(const lisp::Lisp& lisp)
99 std::string bonusname;
100 if(lisp.get("bonus", bonusname)) {
101 if(bonusname == "none") {
103 } else if(bonusname == "growup") {
104 bonus = GROWUP_BONUS;
105 } else if(bonusname == "fireflower") {
107 } else if(bonusname == "iceflower") {
110 std::cerr << "Unknown bonus '" << bonusname << "' in savefile.\n";
115 lisp.get("lives", lives);
116 lisp.get("coins", coins);
117 lisp.get("max-score-multiplier", max_score_multiplier);