blob: a75767c9fafe701e728b3839dd5da9da409f57e3 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include "rl.h"
#include "GameData.h"
#include "strings.h"
#include "GameController.h"
#include "backend/print.h"
#include "backend/WeaponObject.h"
#include "backend/Dungeon.h"
using namespace std;
GameController::GameController(Dungeon & dungeon) : dungeon(dungeon), player(dungeon.get_player()) {
lprtf("Wat is de naam van je karakter?\n");
string name = rl();
player.name = name.c_str();
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;
}
|