-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCardFive.cpp
More file actions
28 lines (23 loc) · 913 Bytes
/
CardFive.cpp
File metadata and controls
28 lines (23 loc) · 913 Bytes
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
#include "CardFive.h"
CardFive::CardFive(const CellPosition& pos) : Card(pos) // set the cell position of the card
{
cardNumber = 5; // set the inherited cardNumber data member with the card number (5 here)
}
void CardFive::Read(ifstream& load)
{
int cellpos;
load >> cellpos;
position = CellPosition::GetCellPositionFromNum(cellpos);
}
CardFive::~CardFive(void)
{
}
void CardFive::Apply(Grid* pGrid, Player* pPlayer)
{
// 1- Call Apply() of the base class Card to print the message that you reached this card number
Card::Apply(pGrid, pPlayer);
// 2- Move forward by the same number of steps that you just rolled and moved
//already. (if you reach a ladder or a snake at the end of moving forward, take it).
CellPosition tocell = CellPosition::GetCellPositionFromNum(this->position.GetCellNum() + pPlayer->GetjustRolledDiceNum());
pPlayer->MoveToCell(pGrid, tocell);
}