-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.cpp
More file actions
59 lines (45 loc) · 1.26 KB
/
Copy pathCard.cpp
File metadata and controls
59 lines (45 loc) · 1.26 KB
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
#include "Card.h"
Card::Card(const CellPosition & pos) : GameObject(pos) // sets the cell position of the GameObject
{
SetCardNumber(pos.GetCellNum());
++num;
}
int Card::num = 0;
void Card::SetCardNumber(int cnum)
{
if (cnum>0&&cnum<14)
cardNumber = cnum; // needs validation
else cardNumber = -1; //#?!
//else will treated as -1 (we don't use - numbers)
}
int Card::GetCardNumber() const
{
return cardNumber;
}
void Card::Draw(Output* pOut) const
{
///TODO: call the appropriate Ouput function that draws a cell containing the "cardNumber" in "position"
pOut->DrawCell(position,GetCardNumber());
}
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 ...");
}
int Card::GetNumberOfCards()
{
return num;
}
void Card::DecNum()
{
--num;
}
Card::~Card()
{
}