-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCardTwo.cpp
54 lines (45 loc) · 1.42 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
#include "CardTwo.h"
CardTwo::CardTwo(const CellPosition& pos) : Card(pos) // set the cell position of the card
{
cardNumber = 2; // set the inherited cardNumber data member with the card number (2 here)
}
Card* CardTwo::GetCopy(const CellPosition& pos)
{
return new CardTwo(pos);
}
void CardTwo::ReadCardParameters(Grid* pGrid)
{
//No Parameters for CardTwo
}
void CardTwo::Apply(Grid* pGrid, Player* pPlayer)
{
Card::Apply(pGrid, pPlayer);
// Printing a message showing the player the details of card two
pGrid->PrintErrorMessage("This card moves you to the start of the next ladder. Click to continue...");
Ladder* next_ladder = pGrid->GetNextLadder(this->GetPosition()); // Getting a pointer to the next ladder
// If there's no ladders ahead show an informative message
if (!next_ladder)
{
pGrid->PrintErrorMessage("There is no ladder ahead! Click to continue...");
}
else {
pGrid->UpdatePlayerCell(pPlayer, next_ladder->GetPosition()); // Moving the player to the start of the next ladder
next_ladder->Apply(pGrid, pPlayer); // Applying the Ladder to the player
}
}
void CardTwo::Save(ofstream& outFile, ObjectType ObjType)
{
if (ObjType == Cards)
{
// Calling the parent class save function that saves the type and card position to the file
Card::Save(outFile, ObjType);
// No Card Parameters here
outFile << std::endl;
}
}
void CardTwo::Load(ifstream& InFile) {
Card::Load(InFile);
}
CardTwo::~CardTwo(void)
{
}