-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ai.hpp
67 lines (56 loc) · 1.49 KB
/
Ai.hpp
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
67
#ifndef AI_HPP
#define AI_HPP
class Ai : public Persistent
{
public:
virtual void update(Actor *t_owner) = 0;
static std::unique_ptr<Ai> create(TCODZip &t_zip);
protected:
enum AiType
{
MONSTER,
CONFUSED_MONSTER,
PLAYER
};
};
class PlayerAi : public Ai
{
public:
int m_xp_lvl;
PlayerAi();
int getNextLevel();
void wait(const unsigned int t_num_turns = 1);
void update(Actor *t_owner);
void handleActionKey(Actor *t_owner, const int t_ascii, const bool t_shift = false);
Actor *chooseFromInventory(Actor *t_owner);
void load(TCODZip &t_zip);
void save(TCODZip &t_zip);
protected:
bool moveOrAttack(Actor *t_owner, const int t_target_x, const int t_target_y);
static const std::unordered_map<TCOD_keycode_t, std::pair<int, int>> s_movement_keys;
static const std::unordered_map<char, std::pair<int, int>> s_movement_chars;
};
class MonsterAi : public Ai
{
public:
MonsterAi();
void update(Actor *t_owner);
void load(TCODZip &t_zip);
void save(TCODZip &t_zip);
protected:
int m_move_count;
static const int S_TRACKING_TURNS;
void moveOrAttack(Actor *t_owner, const int t_target_x, const int t_target_y);
};
class ConfusedMonsterAi : public Ai
{
public:
ConfusedMonsterAi(const int t_num_turns, std::unique_ptr<Ai> t_old_ai);
void update(Actor *t_owner);
void load(TCODZip &t_zip);
void save(TCODZip &t_zip);
protected:
int m_num_turns;
std::unique_ptr<Ai> m_old_ai;
};
#endif