-
Notifications
You must be signed in to change notification settings - Fork 0
/
Orders.h
247 lines (213 loc) · 6.72 KB
/
Orders.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#pragma once
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include "LoggingObserver.h"
class Player;
class Territory;
using namespace std;
//Base class for all orders
class Order : public ILoggable, public Subject {
public:
//default constructor
Order();
//destructor
virtual ~Order();
//copy constructor
Order(const Order& o);
//constructor taking in a string setting the type of the order
Order(std::string type);
//get the order type as a string
std::string getType() const;
//assignment operator
virtual Order& operator=(const Order& o);
//clone function
virtual Order* clone() const;
//validate method to make sure an order is of a valid type
virtual bool validate();
//execute method to execute the action of the order and display its description
virtual void execute();
//Method responsible for writing a specific string based on the type of order. Abstract method from ILoggable.
std::string stringToLog();
private:
//stream insertion operator
friend std::ostream& operator<<(std::ostream& description, const Order& order);
//order type
std::string* _type;
};
class Deploy : public Order {
public:
//default constructor
Deploy();
Deploy(Player* p, Territory* target, int);
//destructor
virtual ~Deploy();
//copy constructor
Deploy(const Deploy& dep);
//assignment operator
virtual Deploy& operator=(const Deploy& dep);
//clone function
virtual Deploy* clone() const;
//validate method to make sure an order is of a valid type
bool validate();
//execute method to execute the action of the order and display its description
void execute();
private:
//stream insertion operator
friend std::ostream& operator<<(std::ostream& description, const Deploy& deploy);
//New Implementation
Player* player;
Territory* targetTerritory;
int armiesToDeploy;
};
class Advance : public Order{
public:
//default constructor
Advance();
Advance(Player* p); // Parameterized Constructor
Advance(Player* p, Territory* source, Territory* target);
//destructor
virtual ~Advance();
//copy constructor
Advance(const Advance& adv);
//assignment operator
virtual Advance& operator=(const Advance& adv);
//clone function
virtual Advance* clone() const;
//validate method to make sure an order is of a valid type
bool validate();
//execute method to execute the action of the order and display its description
void execute();
private:
//stream insertion operator
friend std::ostream& operator<<(std::ostream& description, const Advance& advance);
//New Implementation
Player* player;
Territory* targetTerritory;
Territory* sourceTerritory;
int armiesToAdvance;
};
class Bomb : public Order{
public:
//default constructor
Bomb();
Bomb(Territory* target);
//destructor
virtual ~Bomb();
//copy constructor
Bomb(const Bomb& bmb);
//assignment operator
virtual Bomb& operator=(const Bomb& bmb);
//clone function
virtual Bomb* clone() const;
//validate method to make sure an order is of a valid type
bool validate();
//execute method to execute the action of the order and display its description
void execute();
private:
//stream insertion operator
friend std::ostream& operator<<(std::ostream& description, const Bomb& bomb);
//New Implementation
Territory* targetTerritory;
};
class Blockade : public Order{
public:
//default constructor
Blockade();
Blockade(Territory* target);
//destructor
virtual ~Blockade();
//copy constructor
Blockade(const Blockade& blck);
//assignment operator
virtual Blockade& operator=(const Blockade& blck);
//clone function
virtual Blockade* clone() const;
//validate method to make sure an order is of a valid type
bool validate();
//execute method to execute the action of the order and display its description
void execute();
private:
//stream insertion operator
friend std::ostream& operator<<(std::ostream& description, const Blockade& blockade);
//New Implementation
Territory* targetTerritory;
};
class Airlift : public Order{
public:
//default constructor
Airlift();
Airlift(Territory* source, Territory* target);
//destructor
virtual ~Airlift();
//copy constructor
Airlift(const Airlift& al);
//assignment operator
virtual Airlift& operator=(const Airlift& al);
//clone function
virtual Airlift* clone() const;
//validate method to make sure an order is of a valid type
bool validate();
//execute method to execute the action of the order and display its description
void execute();
private:
//stream insertion operator
friend std::ostream& operator<<(std::ostream& description, const Airlift& airlift);
//New Implementation
Territory* targetTerritory;
Territory* sourceTerritory;
int armiesToAirlift;
};
class Negotiate : public Order{
public:
//default constructor
Negotiate();
Negotiate(Player* p, Player* target);
//destructor
virtual ~Negotiate();
//copy constructor
Negotiate(const Negotiate& ng);
//assignment operator
virtual Negotiate& operator=(const Negotiate& ng);
//clone function
virtual Negotiate* clone() const;
//validate method to make sure an order is of a valid type
bool validate();
//execute method to execute the action of the order and display its description
void execute();
private:
//stream insertion operator
friend std::ostream& operator<<(std::ostream& description, const Negotiate& negotiate);
//New Implementation
Player* player;
Player* targetPlayer;
};
class OrdersList : public ILoggable, public Subject {
public:
//default constructor
OrdersList();
//destructor
~OrdersList();
//copy constructor
OrdersList(const OrdersList& ol);
//assignment operator
OrdersList& operator=(const OrdersList& ol);
//return the size of the orderslist
int size();
//addOrder method to add all kind of orders in the orderslist
void addOrder(Order* order);
//remove method to delete a specific order from the list using its index inside the orderslist
void remove();
//clear all orders
void clearOrders();
//Method responsible for writing a specific string based on the type of order added to the list. Abstract method from ILoggable.
std::string stringToLog();
//get order list
std::queue<Order*>& get_order_list();
private:
//The vector of Order pointers
std::queue<Order*>* _orderlist;
//stream insertion operator
friend std::ostream& operator<<(std::ostream& strm, const OrdersList& orderslist);
};