Moved some console commands' implementations nearer to target classes
[supertux.git] / src / player_status.cpp
index 25eb28e..02a44e9 100644 (file)
@@ -54,6 +54,8 @@ PlayerStatus::PlayerStatus()
   key_gold->set_action("outline");
   
   tux_life.reset(sprite_manager->create("images/creatures/tux_small/tux-life.sprite"));
+
+  Console::registerCommand("coins", this);
 }
 
 PlayerStatus::~PlayerStatus()
@@ -111,7 +113,7 @@ PlayerStatus::write(lisp::Writer& writer)
       writer.write_string("bonus", "iceflower");
       break;
     default:
-      msg_warning("Unknown bonus type.");
+      msg_warning << "Unknown bonus type." << std::endl;
       writer.write_string("bonus", "none");
   }
   writer.write_bool("key-brass", keys & KEY_BRASS);
@@ -140,7 +142,7 @@ PlayerStatus::read(const lisp::Lisp& lisp)
     } else if(bonusname == "iceflower") {
       bonus = ICE_BONUS;
     } else {
-      msg_warning("Unknown bonus '" << bonusname << "' in savefile");
+      msg_warning << "Unknown bonus '" << bonusname << "' in savefile" << std::endl;
       bonus = NO_BONUS;
     }
   }
@@ -207,3 +209,17 @@ PlayerStatus::operator= (const PlayerStatus& other)
   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]))) {
+      msg_info << "Usage: coins <number>" << std::endl;
+    } else {
+      coins = Console::string_to<int>(arguments[0]);
+    }
+    return true;
+  }
+  return false;
+}
+