diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-02 14:44:25 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-02 14:44:25 +0100 |
commit | 369e3d71aa79783d95166739cfa93a480defe6ea (patch) | |
tree | cc4e590da6d98fc891ce3488cc150ffa10173520 /frontend/cmd/cheat.cpp | |
parent | 815ec66a68c01dc4a8f0c5ec6c9193a71e7547e2 (diff) |
more cleanup + add give command to test things
Diffstat (limited to 'frontend/cmd/cheat.cpp')
-rw-r--r-- | frontend/cmd/cheat.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/frontend/cmd/cheat.cpp b/frontend/cmd/cheat.cpp index 8c0af8d..981bca1 100644 --- a/frontend/cmd/cheat.cpp +++ b/frontend/cmd/cheat.cpp @@ -1,13 +1,36 @@ +#include <memory> + #include "backend/print.h" #include "backend/Dungeon.h" #include "../GameController.h" +#include "../GameData.h" using namespace std; +constexpr const char * cmd_give_key = "Manifesteer"; +void GameController::cmd_give(string & item_name) { + Player & player = this->dungeon->get_player(); + GameData & gamedata = GameData::get_instance(); + auto object = unique_ptr<Object>(gamedata.create_object(item_name)); + lprtf("Object aangemaakt: %s\n", object->get_displayname().c_str()); + player.inventory.push_back(object.release()); +} + void GameController::cmd_cheat(string &) { Player & player = this->dungeon->get_player(); player.cheating = !player.cheating; lprtf("Cheats staan nu %s.\n", player.cheating ? "aan" : "uit"); + this->cmdset_cheats(); +} + +void GameController::cmdset_cheats() { + Player & player = this->dungeon->get_player(); + + if (player.cheating) { + this->cmds[cmd_give_key] = &GameController::cmd_give; + } else { + this->cmds.erase(cmd_give_key); + } } |