diff options
Diffstat (limited to 'frontend/GameController.cpp')
-rw-r--r-- | frontend/GameController.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/frontend/GameController.cpp b/frontend/GameController.cpp new file mode 100644 index 0000000..5505380 --- /dev/null +++ b/frontend/GameController.cpp @@ -0,0 +1,49 @@ +#include "GameData.h" +#include "strings.h" +#include "GameController.h" + +#include "backend/WeaponObject.h" +#include "backend/Dungeon.h" + +using namespace std; + +GameController::GameController(Dungeon & dungeon) : dungeon(dungeon), player(dungeon.get_player()) { + cmdset_default(); + player.set_location(dungeon.get_start_location()); + player.equip(static_cast<WeaponObject *>(GameData::get_instance().create_object("Dolk"))); +} + +void GameController::cmdset_default() { + this->cmds["Kijk"] = &GameController::cmd_query; + this->cmds["Zoek"] = &GameController::cmd_search; + this->cmds["Ga"] = &GameController::cmd_go; + this->cmds["Pak"] = &GameController::cmd_get; + this->cmds["Leg"] = &GameController::cmd_put; + this->cmds["Bekijk"] = &GameController::cmd_view; + this->cmds["Sla"] = &GameController::cmd_hit; + this->cmds["Draag"] = &GameController::cmd_equip; + this->cmds["Wacht"] = &GameController::cmd_wait; + this->cmds["Consumeer"] = &GameController::cmd_use; + this->cmds["Help"] = &GameController::cmd_help; + this->cmds["Godmode"] = &GameController::cmd_cheat; + this->cmds["Quit"] = &GameController::cmd_quit; +} + +void GameController::cmdset_death() { + this->cmds["Help"] = &GameController::cmd_help; + this->cmds["Quit"] = &GameController::cmd_quit; + this->cmds["Opnieuw"] = &GameController::cmd_restart; +} + +FollowupAction GameController::cmd(string & argv) { + if (argv.size() == 0) return FollowupAction::NONE; + string cmd = str_title(str_consume_arg(argv)); + + if (this->cmds.contains(cmd)) + return (this->*cmds.at(cmd))(argv); + + str_print(strings::UNKNOWN_CMD); + + return FollowupAction::NONE; +} + |