aboutsummaryrefslogtreecommitdiff
path: root/frontend/GameController.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-01 10:18:22 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-01 10:18:22 +0100
commit798948dbe6f012e194f053c4e862cf697f30b793 (patch)
tree32c71420d1188f98cfb41b6f0d9536c5fa4bf5a7 /frontend/GameController.cpp
parentd7012045bb61f117fb7b9c51ddd03e4c54f25fe6 (diff)
more WIP (move some Player things to backend)
Diffstat (limited to 'frontend/GameController.cpp')
-rw-r--r--frontend/GameController.cpp49
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;
+}
+