aboutsummaryrefslogtreecommitdiff
path: root/frontend/Player.cpp
blob: adf4e44a0ca7dc00772a9b82a565085f86b6fa3e (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
#include "strings.h"
#include "Player.h"
#include "print.h"

using namespace std;

static string argv_pop(vector<string> & argv) {
	string el = argv.front();
	argv.erase(argv.begin());
	return el;
}

Player::Player(Dungeon & dungeon) : dungeon(dungeon) {
	this->cmds.clear();
	cmdset_default();
}

void Player::cmdset_default() {
	this->cmds["Kijk"] = &Player::cmd_query;
	this->cmds["Zoek"] = &Player::cmd_search;
	this->cmds["Ga"] = &Player::cmd_go;
	this->cmds["Pak"] = &Player::cmd_get;
	this->cmds["Leg"] = &Player::cmd_put;
	this->cmds["Bekijk"] = &Player::cmd_view;
	this->cmds["Sla"] = &Player::cmd_hit;
	this->cmds["Draag"] = &Player::cmd_equip;
	this->cmds["Wacht"] = &Player::cmd_wait;
	this->cmds["Consumeer"] = &Player::cmd_use;
	this->cmds["Help"] = &Player::cmd_help;
	this->cmds["Godmode"] = &Player::cmd_cheat;
	this->cmds["Quit"] = &Player::cmd_quit;
}

void Player::cmdset_death() {
	this->cmds["Help"] = &Player::cmd_help;
	this->cmds["Quit"] = &Player::cmd_quit;
	this->cmds["Opnieuw"] = &Player::cmd_restart;
}

FollowupAction Player::cmd(Argv argv) {
	if (argv.size() == 0) return FollowupAction::NONE;
	string cmd = argv_pop(argv);

	if (this->cmds.contains(cmd))
		return (this->*cmds.at(cmd))(argv);

	print_string(strings::UNKNOWN_CMD);

	return FollowupAction::NONE;
}