-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.hpp
112 lines (74 loc) · 1.91 KB
/
command.hpp
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
#include "land.hpp"
#include <array>
#pragma once
class Game;
struct Player;
struct User;
enum class CmdStatus {
Success,
InvalidNumArmies,
NotEnoughArmies,
SelfHarm,
PlayerNotOwner,
DestIsOrigin,
TargetOutsideRange,
InvalidNumDie,
InvalidCardPlay,
IOError
};
struct Command {
Player* player;
virtual CmdStatus Execute(Game& game) = 0;
Command(Player& player_) : player{&player_} {};
};
struct EndTurn : Command {
CmdStatus Execute(Game& game);
EndTurn(Player& player_) :
Command{player_} {};
};
struct PlaceArmy : Command {
Territory* terr;
unsigned numArmies;
PlaceArmy(Player& player_,
Territory& terr_, unsigned numArmies_) :
Command{player_}, terr{&terr_}, numArmies{numArmies_} {};
CmdStatus Execute(Game& game);
};
struct FreeMove : Command {
Territory* origin;
Territory* dest;
unsigned numArmies;
FreeMove(Player& player_, Territory& origin_,
Territory& dest_, unsigned numArmies_) :
Command{player_}, origin{&origin_}, dest{&dest_},
numArmies{numArmies_} {};
CmdStatus Execute(Game& game);
};
struct AttackInit : Command {
Territory* origin;
Territory* target;
unsigned numDie;
AttackInit(Player& player_, Territory& origin_,
Territory& target_, unsigned numDie_) :
Command{player_}, origin{&origin_}, target{&target_},
numDie{numDie_} {};
CmdStatus Execute(Game& game);
};
struct DefendInit : Command {
unsigned numDie;
DefendInit(Player& player_, unsigned numDie_) :
Command{player_}, numDie{numDie_} {};
CmdStatus Execute(Game& game);
};
struct VictoryArmyMove : Command {
unsigned numArmies;
VictoryArmyMove(Player& player_, unsigned numArmies_) :
Command{player_}, numArmies{numArmies_} {};
CmdStatus Execute(Game& game);
};
struct PlayCards : Command {
std::array<std::string, 3> cardNames;
PlayCards(Player& player_, std::array<std::string, 3> cardNames_) :
Command{player_}, cardNames{cardNames_} {};
CmdStatus Execute(Game& game);
};