blob: c590aa94efc9454d2736f8cbbf1ebdb8c859e105 (
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
55
56
57
58
59
60
61
62
63
64
65
66
|
#pragma once
#include <vector>
#include <unordered_map>
#include <string>
class Dungeon;
class Location;
enum FollowupAction {
NONE,
UPDATE,
EXIT,
RESTART,
};
class Player {
typedef std::vector<std::string> & Argv;
typedef FollowupAction Cmd(Argv);
private:
std::string name;
unsigned int health_points = 20;
float attack_chance = 0.4;
// TODO: WeaponObject[]
// TODO: GoldObject[]
// TODO: ArmorObject[]
Location & location;
bool cheating = false;
public:
Player(Dungeon & dungeon);
virtual ~Player() = default;
public:
FollowupAction cmd(Argv argv);
public:
void take_damage(unsigned int dmg);
float get_attack();
private:
void cmdset_default();
void cmdset_death();
private:
std::unordered_map<std::string, FollowupAction(Player::*)(Argv)> cmds;
Cmd cmd_query;
Cmd cmd_search;
Cmd cmd_go;
Cmd cmd_get;
Cmd cmd_put;
Cmd cmd_view;
Cmd cmd_hit;
Cmd cmd_equip;
Cmd cmd_wait;
Cmd cmd_use;
Cmd cmd_help;
Cmd cmd_cheat;
Cmd cmd_quit;
Cmd cmd_restart;
private:
Dungeon & dungeon;
};
|