-bool
-GameSession::consoleCommand(std::string command)
-{
- if (command == "foo") {
- msg_info << "bar" << std::endl;
- return true;
- }
-
- if (currentsector == 0) return false;
- Player& tux = *currentsector->player;
-
- // Cheating words (the goal of this is really for debugging,
- // but could be used for some cheating, nothing wrong with that)
- if (command == "grow") {
- tux.set_bonus(GROWUP_BONUS, false);
- return true;
- }
- if (command == "fire") {
- tux.set_bonus(FIRE_BONUS, false);
- return true;
- }
- if (command == "ice") {
- tux.set_bonus(ICE_BONUS, false);
- return true;
- }
- if (command == "lifeup") {
- player_status->incLives();
- return true;
- }
- if (command == "numberofthebeast") {
- player_status->coins += 55;
- return true;
- }
- if (command == "lifedown") {
- player_status->coins = std::max(player_status->coins-25, 0);
- return true;
- }
- if (command == "grease") {
- tux.physic.set_velocity_x(tux.physic.get_velocity_x()*3);
- return true;
- }
- if (command == "invincible") {
- // be invincle for the rest of the level
- tux.invincible_timer.start(10000);
- return true;
- }
- if (command == "mortal") {
- // give up invincibility
- tux.invincible_timer.stop();
- return true;
- }
- if (command == "shrink") {
- // remove powerups
- tux.kill(tux.SHRINK);
- return true;
- }
- if (command == "kill") {
- tux.kill(tux.KILL);
- return true;
- }
- if (command == "restart") {
- restart_level(true);
- return true;
- }
- if (command == "whereami") {
- msg_info << "You are at x " << tux.get_pos().x << ", y " << tux.get_pos().y << std::endl;
- return true;
- }
- if (command == "gotoend") {
- // goes to the end of the level
- tux.move(Vector(
- (currentsector->solids->get_width()*32) - (SCREEN_WIDTH*2), 0));
- currentsector->camera->reset(
- Vector(tux.get_pos().x, tux.get_pos().y));
- return true;
- }
- if (command == "flip") {
- FlipLevelTransformer flip_transformer;
- flip_transformer.transform(GameSession::current()->get_current_level());
- return true;
- }
- if (command == "finish") {
- finish(true);
- return true;
- }
- if (command == "camera") {
- msg_info << "Camera is at " << Sector::current()->camera->get_translation().x << "," << Sector::current()->camera->get_translation().y << std::endl;
- return true;
- }
- if (command == "quit") {
- main_loop->quit();
- return true;
- }
-
- return false;
-}
-