-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.cpp
More file actions
71 lines (60 loc) · 1.58 KB
/
Card.cpp
File metadata and controls
71 lines (60 loc) · 1.58 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
60
61
62
63
64
65
66
67
68
69
70
71
#include "Card.h"
int Card::CardCount = 0;
Card::Card(const CellPosition& pos) : GameObject(pos) // sets the cell position of the GameObject
{
CardCount++;
}
void Card::SetCardNumber(int cnum)
{
if (cnum >= 1 && cnum <= 12)
cardNumber = cnum; // needs validation
else cardNumber = 2;
}
void Card::SetCardCount(int Count)
{
CardCount = (Count >= 0)? Count: 0;
}
int Card::GetCardCount()
{
return CardCount;
}
int Card::GetCardNumber()
{
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, 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 ...");
}
void Card::Save(ofstream& OutFile, int Type)
{
if (cardNumber < 10) {
OutFile << this->cardNumber << " ";
}
else {
OutFile << this->cardNumber << " ";
}
OutFile << this->position.GetCellNum() << " ";
}
void Card::Load(ifstream& Infile)
{
int StartPos;
Infile >> StartPos;
this->position = CellPosition::GetCellPositionFromNum(StartPos);
}
Card::~Card()
{
CardCount--;
}