-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThief.h
75 lines (52 loc) · 1.97 KB
/
Thief.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
#pragma once
#include "BaseGameEntity.h"
#include "StateMachine.h"
#include "Locations.h"
#include "ConsoleUtils.h"
#include "ThiefOwnedStates.h"
struct Telegram;
//the amount of nuggets a thief can carry
const int MaxNuggetsLupin = 2;
//the amount of gold a thief must have before he feels his treasure is enought.
const int ComfortLevelLupin = 8;
class Thief : public BaseGameEntity
{
private:
//an instance of the state machine class.
StateMachine<Thief>* m_pStateMachine;
location_type m_Location;
int m_iGoldCarried;
int m_iMoneyInThiefHouse;
//is he presently stealing ?
bool m_bStealing;
// is he in prison ?
bool m_bInPrison;
public:
Thief(int id):m_Location(thief_house),
m_bStealing(false),
m_bInPrison(false),
BaseGameEntity(id)
{
//set up state machine
m_pStateMachine = new StateMachine<Thief>(this);
m_pStateMachine->SetCurrentState(EnterBankAndStealTheNugget::Instance());
}
~Thief() { delete m_pStateMachine;}
void Update();
virtual bool HandleMessage(const Telegram& msg);
StateMachine<Thief>* GetFSM()const { return m_pStateMachine; }
//----------------------------------------------------accessors
location_type Location()const { return m_Location; }
void ChangeLocation(location_type loc) { m_Location = loc; }
bool Stealing()const { return m_bStealing; }
void SetStealing(bool val) { m_bStealing = val; }
bool InPrison()const { return m_bInPrison; }
void SetInPrison(bool val) { m_bInPrison = val; }
int GoldCarried()const { return m_iGoldCarried; }
void SetGoldCarried(int val) { m_iGoldCarried = val; }
void AddToGoldCarried(int val);
bool PocketsFull()const { return m_iGoldCarried >= MaxNuggetsLupin; }
int Treasure()const { return m_iMoneyInThiefHouse; }
void SetTreasure(int val) { m_iMoneyInThiefHouse = val; }
void AddToTreasure(int val);
};