-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAction.h
96 lines (84 loc) · 1.78 KB
/
Action.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once
enum Actions
{
up,
down,
_left,
_right,
exiT,
help,
saveGame,
numberOfActs
};
// Abstract class
class Action
{
public:
// Returns the symbol of the key
virtual char symbol() = 0;
// Relevant operation over the current map & the hero
virtual void Act(Map &m, Hero &h) = 0;
// Returns the type
virtual Actions getType() = 0 ;
};
// Four inheritor classes moving the hero in the four directions
class Up: public Action
{
public:
Up() {}
~Up() {}
virtual char symbol() { return 'w'; }
virtual void Act(Map &m, Hero &h);
virtual Actions getType() { return up; }
};
class Down: public Action
{
public:
Down() {}
~Down(){}
virtual char symbol() { return 's'; }
virtual void Act(Map &m, Hero &h);
virtual Actions getType() { return down; }
};
class Left: public Action
{
public:
Left() {}
~Left(){}
virtual char symbol() { return 'a'; }
virtual void Act(Map &m, Hero &h);
virtual Actions getType() { return _left; }
};
class Right: public Action
{
public:
Right() {}
~Right(){}
virtual char symbol() { return 'd'; }
virtual void Act(Map &m, Hero &h);
virtual Actions getType() { return _right; }
};
// Inheritor class Exit
class Exit: public Action
{
public:
virtual char symbol() { return 'q';}
virtual void Act(Map &m, Hero &h) { isRunning = false; }
virtual Actions getType() {return exiT;}
};
// Inheritor class Help menu
class KeyMap: public Action
{
public:
virtual char symbol() {return 'h';}
virtual void Act(Map &m, Hero &h);
virtual Actions getType() {return help;}
};
// Save Game
class SaveGame: public Action
{
public:
virtual char symbol() { return 'f'; }
virtual void Act(Map &m, Hero &h);
virtual Actions getType() { return saveGame; }
};