-
Notifications
You must be signed in to change notification settings - Fork 0
/
CardSeven.cpp
64 lines (55 loc) · 1.42 KB
/
CardSeven.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
58
59
60
61
62
63
64
#include "CardSeven.h"
CardSeven::CardSeven(const CellPosition& pos) :Card(pos)
{
CardCount++;
cardNumber = 7; // initialise card number to 7
}
const CellPosition CardSeven::firstCell(1); // initialise firstcell member to first cell in grid
void CardSeven::ReadCardParameters(Grid* pGrid)
{
// no parameters to read
}
Card* CardSeven::PasteCard()
{
//create and retuen a new object to be added to grid
Card* copy = new CardSeven(0);
return copy;
}
Card* CardSeven::CopyCard()
{
// create and return a new object to be added to clipboard
CardSeven* copy = new CardSeven(0);
// decrement card count as acrd was not added to grid
CardCount--;
return copy;
}
void CardSeven::Apply(Grid* pGrid, Player* pPlayer)
{
Card::Apply(pGrid, pPlayer); // calls apply of base class
// gets next player
Player* next = pGrid->GetNextPlayer(position);
if (next) // if found reset all players in the cell
{
CellPosition nextpos = next->GetCell()->GetCellPosition();
for (int i = 0; i < 4; i++)
{
Player* another = pGrid->CheckCurrentCellPlayer(nextpos, i);
if (another)
{
//move all players to first cell using updateplayercell() function in grid
pGrid->UpdatePlayerCell(another,firstCell) ;
}
}
}
}
void CardSeven::Save(ofstream& OutFile, Object_Type obj)
{
if (obj != card)
return;
Card::Save(OutFile, obj);
OutFile << endl;
}
CardSeven::~CardSeven()
{
CardCount--; // decrement card count when deleted
}