Spiky, Snowball and Poison Ivy can move again
[supertux.git] / src / player_status.cpp
index 02a44e9..3fe09f2 100644 (file)
@@ -1,7 +1,8 @@
 //  $Id$
 //
-//  SuperTux -  A Jump'n Run
+//  SuperTux
 //  Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
@@ -28,7 +29,7 @@
 #include "sprite/sprite_manager.hpp"
 #include "math/vector.hpp"
 #include "main.hpp"
-#include "msg.hpp"
+#include "log.hpp"
 
 static const int START_COINS = 100;
 static const int MAX_COINS = 99999;
@@ -55,7 +56,7 @@ PlayerStatus::PlayerStatus()
   
   tux_life.reset(sprite_manager->create("images/creatures/tux_small/tux-life.sprite"));
 
-  Console::registerCommand("coins", this);
+  Console::instance->registerCommand("coins", this);
 }
 
 PlayerStatus::~PlayerStatus()
@@ -72,17 +73,13 @@ void PlayerStatus::reset()
 }
 
 void
-PlayerStatus::incLives()
+PlayerStatus::add_coins(int count)
 {
-  player_status->coins = std::min(player_status->coins+100, MAX_COINS);
-  sound_manager->play("sounds/lifeup.wav");
-}
-
-void
-PlayerStatus::incCoins()
-{
-  coins++;
-  sound_manager->play("sounds/coin.wav");
+  coins = std::min(coins + count, MAX_COINS);
+  if(count > 100)
+    sound_manager->play("sounds/lifeup.wav");
+  else
+    sound_manager->play("sounds/coin.wav");
 }
 
 void
@@ -113,7 +110,7 @@ PlayerStatus::write(lisp::Writer& writer)
       writer.write_string("bonus", "iceflower");
       break;
     default:
-      msg_warning << "Unknown bonus type." << std::endl;
+      log_warning << "Unknown bonus type." << std::endl;
       writer.write_string("bonus", "none");
   }
   writer.write_bool("key-brass", keys & KEY_BRASS);
@@ -142,7 +139,7 @@ PlayerStatus::read(const lisp::Lisp& lisp)
     } else if(bonusname == "iceflower") {
       bonus = ICE_BONUS;
     } else {
-      msg_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl;
+      log_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl;
       bonus = NO_BONUS;
     }
   }
@@ -214,7 +211,7 @@ PlayerStatus::consoleCommand(std::string command, std::vector<std::string> argum
 {
   if (command == "coins") {
     if ((arguments.size() < 1) || (!Console::string_is<int>(arguments[0]))) {
-      msg_info << "Usage: coins <number>" << std::endl;
+      log_info << "Usage: coins <number>" << std::endl;
     } else {
       coins = Console::string_to<int>(arguments[0]);
     }