Rewrote Yeti to rely on position instead of ellapsed time
[supertux.git] / src / player_status.cpp
index 02a44e9..24a1b99 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;
@@ -38,6 +39,8 @@ PlayerStatus* player_status = 0;
 PlayerStatus::PlayerStatus()
   : coins(START_COINS),
     bonus(NO_BONUS),
+    max_fire_bullets(0),
+    max_ice_bullets(0),
     score_multiplier(1),
     max_score_multiplier(1)
 {
@@ -55,7 +58,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 +75,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,9 +112,12 @@ 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_int("fireflowers", max_fire_bullets);
+  writer.write_int("iceflowers", max_ice_bullets);
+  
   writer.write_bool("key-brass", keys & KEY_BRASS);
   writer.write_bool("key-iron", keys & KEY_IRON);
   writer.write_bool("key-bronze", keys & KEY_BRONZE);
@@ -142,10 +144,13 @@ 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;
     }
   }
+  lisp.get("fireflowers", max_fire_bullets);
+  lisp.get("iceflowers", max_ice_bullets);
+
   bool val = false;
   if(lisp.get("key-brass", val) && val == true)
     set_keys(KEY_BRASS);
@@ -194,7 +199,7 @@ PlayerStatus::draw(DrawingContext& context)
   context.draw_text(white_text, coinstext, Vector(SCREEN_WIDTH - white_text->get_text_width(coinstext) - gold_text->get_text_width(" 99999") - BORDER_X, BORDER_Y), LEFT_ALLIGN, LAYER_FOREGROUND1);
   context.draw_text(gold_text, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y), RIGHT_ALLIGN, LAYER_FOREGROUND1);
 
-  draw_keys(context);  
+  //draw_keys(context);  
 
   context.pop_transform();
 }
@@ -214,7 +219,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]);
     }