-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardSeven.cpp
More file actions
67 lines (51 loc) · 1.54 KB
/
CardSeven.cpp
File metadata and controls
67 lines (51 loc) · 1.54 KB
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
#include "CardSeven.h"
CardSeven::CardSeven(const CellPosition& pos) : Card(pos) // set the cell position of the card
{
cardNumber = 7; // set the inherited cardNumber data member with the card number (1 here)
}
CardSeven::~CardSeven(void)
{
}
void CardSeven::ReadCardParameters(Grid* pGrid)
{
}
void CardSeven::Apply(Grid* pGrid, Player* pPlayer)
{
Output* pOut = pGrid->GetOutput();
// 1- Call Apply() of the base class Card to print the message that you reached this card number
Card::Apply(pGrid, pPlayer);
pOut->ClearStatusBar();
pGrid->PrintErrorMessage("Restarts the game for the first player whose cell is after the current player in the grid. ");
int changeCellNum = 0;
int Diff = NumHorizontalCells * NumVerticalCells;
int cellnumcurrplayer = pPlayer->GetCell()->GetCellPosition().GetCellNum();
for (int i = 0; i < MaxPlayerCount; i++) {
if (((pGrid->GetCellNumOfPlayer(i))) > cellnumcurrplayer) {
if (pGrid->GetCellNumOfPlayer(i) - cellnumcurrplayer < Diff) {
Diff = pGrid->GetCellNumOfPlayer(i) - cellnumcurrplayer;
changeCellNum = pGrid->GetCellNumOfPlayer(i);
}
}
}
if (Diff != NumHorizontalCells * NumVerticalCells) {
for (int i = 0; i < MaxPlayerCount; i++) {
if (pGrid->GetCellNumOfPlayer(i) == changeCellNum) {
pGrid->RestartPlayerWithNum(i);
}
}
}
else {
pGrid->PrintErrorMessage("No Players Found...");
}
}
void CardSeven::Save(ofstream& OutFile, int Type)
{
if (Type == 2) {
Card::Save(OutFile, Type);
OutFile << endl;
}
}
void CardSeven::Load(ifstream& Infile)
{
Card::Load(Infile);
}