aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd/cheat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/cmd/cheat.cpp')
-rw-r--r--frontend/cmd/cheat.cpp23
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);
+ }
}