-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCardFour.cpp
More file actions
29 lines (24 loc) · 800 Bytes
/
CardFour.cpp
File metadata and controls
29 lines (24 loc) · 800 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
29
#include "CardFour.h"
CardFour::CardFour(const CellPosition& pos) : Card(pos) // set the cell position of the card
{
cardNumber = 4; // set the inherited cardNumber data member with the card number (4 here)
}
void CardFour::Read(ifstream& load)
{
int cellpos;
load >> cellpos;
position = CellPosition::GetCellPositionFromNum(cellpos);
}
CardFour::~CardFour(void)
{
}
void CardFour::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- Moves the player forward to the start of the next snake. (If no snakes ahead, do nothing)
if (Snake* NS = pGrid->GetNextSnake(this->GetPosition()))
{
pPlayer->MoveToCell(pGrid, NS->GetPosition());
}
}