// $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
#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;
key_gold->set_action("outline");
tux_life.reset(sprite_manager->create("images/creatures/tux_small/tux-life.sprite"));
+
+ Console::instance->registerCommand("coins", this);
}
PlayerStatus::~PlayerStatus()
}
void
-PlayerStatus::incLives()
-{
- player_status->coins = std::min(player_status->coins+100, MAX_COINS);
- sound_manager->play("sounds/lifeup.wav");
-}
-
-void
-PlayerStatus::incCoins()
+PlayerStatus::add_coins(int count)
{
- 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
writer.write_string("bonus", "iceflower");
break;
default:
- msg_warning("Unknown bonus type.");
+ log_warning << "Unknown bonus type." << std::endl;
writer.write_string("bonus", "none");
}
writer.write_bool("key-brass", keys & KEY_BRASS);
} else if(bonusname == "iceflower") {
bonus = ICE_BONUS;
} else {
- msg_warning("Unknown bonus '" << bonusname << "' in savefile");
+ log_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl;
bonus = NO_BONUS;
}
}
keys = other.keys;
}
+bool
+PlayerStatus::consoleCommand(std::string command, std::vector<std::string> arguments)
+{
+ if (command == "coins") {
+ if ((arguments.size() < 1) || (!Console::string_is<int>(arguments[0]))) {
+ log_info << "Usage: coins <number>" << std::endl;
+ } else {
+ coins = Console::string_to<int>(arguments[0]);
+ }
+ return true;
+ }
+ return false;
+}
+