-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinerOwnedStates.h
169 lines (110 loc) · 4.09 KB
/
MinerOwnedStates.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
#ifndef MINER_OWNED_STATES_H
#define MINER_OWNED_STATES_H
#include "State.h"
class Miner;
struct Telegram;
//------------------------------------------------------------------------
//
// In this state the miner will walk to a goldmine and pick up a nugget
// of gold. If the miner already has a nugget of gold he'll change state
// to VisitBankAndDepositGold. If he gets thirsty he'll change state
// to QuenchThirst
//------------------------------------------------------------------------
class EnterMineAndDigForNugget : public State<Miner>
{
private:
EnterMineAndDigForNugget(){}
//copy ctor and assignment should be private
EnterMineAndDigForNugget(const EnterMineAndDigForNugget&);
EnterMineAndDigForNugget& operator=(const EnterMineAndDigForNugget&);
public:
//this is a singleton
static EnterMineAndDigForNugget* Instance();
virtual void Enter(Miner* miner);
virtual void Execute(Miner* miner);
virtual void Exit(Miner* miner);
virtual bool OnMessage(Miner* agent, const Telegram& msg);
};
//------------------------------------------------------------------------
//
// Entity will go to a bank and deposit any nuggets he is carrying. If the
// miner is subsequently wealthy enough he'll walk home, otherwise he'll
// keep going to get more gold
//------------------------------------------------------------------------
class VisitBankAndDepositGold : public State<Miner>
{
private:
VisitBankAndDepositGold(){}
//copy ctor and assignment should be private
VisitBankAndDepositGold(const VisitBankAndDepositGold&);
VisitBankAndDepositGold& operator=(const VisitBankAndDepositGold&);
public:
//this is a singleton
static VisitBankAndDepositGold* Instance();
virtual void Enter(Miner* miner);
virtual void Execute(Miner* miner);
virtual void Exit(Miner* miner);
virtual bool OnMessage(Miner* agent, const Telegram& msg);
};
//------------------------------------------------------------------------
//
// miner will go home and sleep until his fatigue is decreased
// sufficiently
//------------------------------------------------------------------------
class GoHomeAndSleepTilRested : public State<Miner>
{
private:
GoHomeAndSleepTilRested(){}
//copy ctor and assignment should be private
GoHomeAndSleepTilRested(const GoHomeAndSleepTilRested&);
GoHomeAndSleepTilRested& operator=(const GoHomeAndSleepTilRested&);
public:
//this is a singleton
static GoHomeAndSleepTilRested* Instance();
virtual void Enter(Miner* miner);
virtual void Execute(Miner* miner);
virtual void Exit(Miner* miner);
virtual bool OnMessage(Miner* agent, const Telegram& msg);
};
//------------------------------------------------------------------------
//
// miner changes location to the saloon and keeps buying Whiskey until
// his thirst is quenched. When satisfied he returns to the goldmine
// and resumes his quest for nuggets.
//------------------------------------------------------------------------
class QuenchThirst : public State<Miner>
{
private:
QuenchThirst(){}
//copy ctor and assignment should be private
QuenchThirst(const QuenchThirst&);
QuenchThirst& operator=(const QuenchThirst&);
public:
//this is a singleton
static QuenchThirst* Instance();
virtual void Enter(Miner* miner);
virtual void Execute(Miner* miner);
virtual void Exit(Miner* miner);
virtual bool OnMessage(Miner* agent, const Telegram& msg);
};
//------------------------------------------------------------------------
//
// this is implemented as a state blip. The miner eats the stew, gives
// Elsa some compliments and then returns to his previous state
//------------------------------------------------------------------------
class EatStew : public State<Miner>
{
private:
EatStew(){}
//copy ctor and assignment should be private
EatStew(const EatStew&);
EatStew& operator=(const EatStew&);
public:
//this is a singleton
static EatStew* Instance();
virtual void Enter(Miner* miner);
virtual void Execute(Miner* miner);
virtual void Exit(Miner* miner);
virtual bool OnMessage(Miner* agent, const Telegram& msg);
};
#endif