aboutsummaryrefslogtreecommitdiff
path: root/frontend/cmd/cheat.cpp
blob: 59fb13c076bb9bcb86570ea48f2ba4e59dca037d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 = 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);
	}
}