-
Notifications
You must be signed in to change notification settings - Fork 0
/
Actor.h
173 lines (152 loc) · 5.11 KB
/
Actor.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef ACTOR_H_
#define ACTOR_H_
#include "GraphObject.h"
// Students: Add code to this file, Actor.cpp, StudentWorld.h, and StudentWorld.cpp
class StudentWorld;
class BaseActor: public GraphObject {
public:
BaseActor(int imageID, double startX, double startY, Direction dir = 0, int depth = 0, double size = 1.0);
virtual void doSomething() = 0;
// traits of actor
virtual bool blocksMovement() const { return false;}
virtual bool blocksFlame() const { return false;}
virtual bool canExit() const { return false;}
virtual bool isKilledByFlamePit() const { return false;}
virtual bool canBeInfected() const { return false;}
virtual bool explodesLM() const { return false;}
virtual bool isPerson() const { return false;}
virtual bool isZombie() const { return false;}
// possible actions
int checkAlive() const {return m_isAlive;}
void setAlive(int newAlive) { m_isAlive = newAlive;}
int infectionCount() const {return m_infectionCount;}
void setInfectionCount(int next) { m_infectionCount = next;}
bool isSaved() const { return m_saved;}
void setSaved(bool next) { m_saved = next;}
bool isInfected() const { return m_isInfected;}
void setInfected(bool next) { m_isInfected = next;}
bool isParalyzed() const { return m_isParalyzed;}
void setParalysis(bool next) { m_isParalyzed = next;}
StudentWorld* getWorld() const { return gw;}
void setWorld(StudentWorld* newGW) { gw = newGW;}
virtual void doWhenDead() const {};
void checkMove(int& x, int& y, Direction dir, int moves) const;
private:
int m_isAlive;
bool m_isParalyzed;
bool m_isInfected;
int m_infectionCount;
bool m_saved;
StudentWorld* gw;
};
class Penelope: public BaseActor {
public:
Penelope(int x, int y, StudentWorld* gw);
virtual void doSomething();
virtual bool blocksMovement() const { return true;}
virtual bool canExit() const { return true;}
virtual bool isKilledByFlamePit() const { return true;}
virtual bool canBeInfected() const { return true;}
virtual bool explodesLM() const { return true;}
virtual bool isPerson() const { return true;}
virtual void doWhenDead() const;
};
class Wall: public BaseActor {
public:
Wall(int x, int y, StudentWorld* gw);
virtual void doSomething();
virtual bool blocksMovement() const { return true;}
virtual bool blocksFlame() const { return true;}
};
class Exit: public BaseActor {
public:
Exit(int x, int y, StudentWorld* gw);
virtual void doSomething();
virtual bool blocksFlame() const { return true;}
};
class Pit: public BaseActor {
public:
Pit(int x, int y, StudentWorld* gw);
virtual void doSomething();
};
class Flame: public BaseActor {
public:
Flame(int x, int y, StudentWorld* gw, Direction dir);
virtual void doSomething();
void ifOverlap(int x, int y);
virtual bool explodesLM() const { return true;}
};
class Vomit: public BaseActor {
public:
Vomit(int x, int y, StudentWorld* gw);
virtual void doSomething();
};
class BaseGoodie: public BaseActor {
public:
BaseGoodie(int imageID, int x, int y, StudentWorld* gw);
virtual void doSomething();
virtual bool isKilledByFlamePit() const { return true;}
virtual void doIfOverlap() = 0;
private:
};
class VaccineGoodie: public BaseGoodie {
public:
VaccineGoodie(int x, int y, StudentWorld* gw);
virtual void doIfOverlap();
};
class LandmineGoodie: public BaseGoodie {
public:
LandmineGoodie(int x, int y, StudentWorld* gw);
virtual void doIfOverlap();
};
class GasCanGoodie: public BaseGoodie {
public:
GasCanGoodie(int x, int y, StudentWorld* gw);
virtual void doIfOverlap();
};
class Landmine: public BaseActor {
public:
Landmine(int x, int y, StudentWorld* gw);
virtual void doSomething();
virtual void doWhenDead() const;
private:
int m_inactiveTicks;
};
class BaseZombie: public BaseActor {
public:
BaseZombie(int x, int y, StudentWorld* gw);
virtual void doSomething();
virtual bool blocksMovement() const { return true;}
virtual bool isKilledByFlamePit() const { return true;}
virtual bool explodesLM() const { return true;}
virtual bool isZombie() const { return true;}
virtual void doWhenDead() const;
virtual void smartPlan() {}
private:
int m_distancePlan;
};
class DumbZombie: public BaseZombie {
public:
DumbZombie(int x, int y, StudentWorld* gw);
virtual void doWhenDead() const;
};
class SmartZombie: public BaseZombie {
public:
SmartZombie(int x, int y, StudentWorld* gw);
virtual void doWhenDead() const;
virtual void smartPlan();
};
class Citizen: public BaseActor {
public:
Citizen(int imageID, int x, int y, StudentWorld* gw);
virtual ~Citizen();
virtual void doSomething();
virtual bool blocksMovement() const { return true;}
virtual bool canExit() const { return true;}
virtual bool isKilledByFlamePit() const { return true;}
virtual bool canBeInfected() const { return true;}
virtual bool explodesLM() const { return true;}
virtual bool isPerson() const { return true;}
virtual void doWhenDead() const;
};
#endif // ACTOR_H_