-
Notifications
You must be signed in to change notification settings - Fork 0
/
PreventCard_4.cpp
57 lines (41 loc) · 1.17 KB
/
PreventCard_4.cpp
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
#include "PreventCard_4.h"
#include "Player.h"
PreventCard_4::PreventCard_4(const CellPosition & pos) : Card(pos) // set the cell position of the card
{
cardNumber = 4; // set the inherited cardNumber data member with the card number
}
PreventCard_4::PreventCard_4(){
cardNumber = 4;
}
PreventCard_4::~PreventCard_4()
{
}
void PreventCard_4::ReadActionParameters()
{
//No ReadAction Parameters
}
void PreventCard_4 :: Apply(Grid* pGrid, Player* pPlayer)
{
Card::Apply (pGrid, pPlayer);
Input * in = pGrid -> GetInput();
Output * out = pGrid -> GetOutput();
out -> PrintMessage ("Prevent Card, Choose the prevented player");
CellPosition p = in -> GetCellClicked();
for (int i = 0; i < MaxPlayerCount - 1; i++)
{
pGrid -> AdvanceCurrentPlayer();
CellPosition c = pGrid -> GetCurrentPlayer() -> GetPlayerCellPosition();
if (p.HCell() == c.HCell() && p.VCell() == c. VCell())
pGrid -> Apply_Prevent(pGrid -> GetCurrentPlayer() -> getPlayerNum());
}
pGrid -> AdvanceCurrentPlayer();
out->ClearStatusBar();
}
void PreventCard_4::Save(ofstream& outFile, Type gameObj)
{
if (gameObj == CARDS)
{
Card::Save(outFile, gameObj);
outFile << std::endl;
}
}