-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCardTwo.cpp
62 lines (46 loc) · 1.31 KB
/
CardTwo.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
#include "CardTwo.h"
#include "Cell.h"
#include "Ladder.h"
#include "Grid.h"
CardTwo::CardTwo(const CellPosition& pos):Card(pos)
{
cardNumber = 2; // set the inherited cardNumber data member with the card number (2 here)
}
void CardTwo::ReadCardParameters(Grid* pGrid)
{
}
void CardTwo::Apply(Grid* pGrid, Player* pPlayer)// Applies the effect of CardTwo on the passed Player
{
Card::Apply(pGrid, pPlayer);
Input* pIn = pGrid->GetInput();
Output* pOut = pGrid->GetOutput();
Ladder*lad=pGrid->GetNextLadder(position); //Checks the prescence of a ladder in the remaining cells.
if (lad == NULL) //if there was no ladder found.
{
int x, y;
pOut->PrintMessage("No ladder, Click to continue.... ");
pIn->GetPointClicked(x, y);
pOut->ClearStatusBar();
}
else //if a ladder was found start moving the player to it.
{
int run;
run = lad->GetPosition().GetCellNum() - pPlayer->GetCell()->GetCellPosition().GetCellNum();
pPlayer->Move(pGrid, run);
}
pPlayer->SetTurnCount(pPlayer->GetTurnCount() - 1);
}
Card* CardTwo::Copy(Card* pCard) {
CellPosition pos;
CardTwo* copy = new CardTwo(pos);
return copy;
}
void CardTwo::Save(ofstream& OutFile) {
Card::Save(OutFile);
}
void CardTwo::Load(ifstream& Infile) {
Card::Load(Infile);
}
CardTwo::~CardTwo()
{
}// A Virtual Destructor