-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.cpp
57 lines (47 loc) · 1.49 KB
/
Card.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
#include "Card.h"
#include <fstream>
Card::Card(const CellPosition & pos) : GameObject(pos) // sets the cell position of the GameObject
{
}
bool Card::IsOverlapping(GameObject* newObj) const {
//card cannot be overlapped by another object
return false;
}
void Card::SetCardNumber(int cnum)
{
if (cnum >= 1 && cnum <= 12)
cardNumber = cnum; // needs validation
else
cardNumber = -1;
}
void Card::setPosition(CellPosition p) {
position.SetHCell(p.HCell());
position.SetVCell(p.VCell());
}
int Card::GetCardNumber()
{
return cardNumber;
}
void Card::Save(ofstream& OutFile, const CellPosition& startCellPos)
{
OutFile << cardNumber << " " << startCellPos.GetCellNum();
}
void Card::Draw(Output* pOut) const
{
///TODO: call the appropriate Ouput function that draws a cell containing the "cardNumber" in "position"
pOut->DrawCell(position, cardNumber);
}
void Card::ReadCardParameters(Grid * pGrid)
{
// we should not make it pure virtual because some Cards doesn't have parameters
// and if we make it pure virtual, that will make those Cards abstract classes
}
void Card::Apply(Grid* pGrid, Player* pPlayer)
{
// As written below the "Roll Dice" action in the document ==> Check the Project Document
// "If a player reaches a card of any other type", the following message should be printed then wait mouse click
pGrid->PrintErrorMessage("You have reached card " + to_string(cardNumber) + ". Click to continue ...");
}
Card::~Card()
{
}