-
Notifications
You must be signed in to change notification settings - Fork 2
/
CardTwelve.cpp
73 lines (55 loc) · 1.64 KB
/
CardTwelve.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "CardTwelve.h"
#include "CardNine.h"
#include "CardTen.h"
#include "CardEleven.h"
CardTwelve::CardTwelve(const CellPosition& pos) : Card(pos) // set the cell position of the card
{
cardNumber = 12; // set the inherited cardNumber data member with the card number (12 here)
}
CardTwelve::~CardTwelve(void)
{
}
void CardTwelve::ReadCardParameters(Grid* pGrid)
{
}
void CardTwelve::Apply(Grid* pGrid, Player* pPlayer)
{
Card::Apply(pGrid, pPlayer);
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
// get poorest player in the play
Player* poorest = pGrid->GetPoorestPlayer();
// get most expensive station of the current player
int mostExpensive = pPlayer->GetMostExpensiveStationNumber();
if (poorest == pPlayer) {
pOut->PrintMessage("Player " + to_string(pPlayer->getPlayerNumber()) + ": None will take you station, You are already the poorest player here :(");
return;
}
if (mostExpensive == -1) return;// not found
switch(mostExpensive) {
case 9:
CardNine::setOwner(poorest);
break;
case 10:
CardTen::setOwner(poorest);
break;
case 11:
CardTen::setOwner(poorest);
break;
default:
break;
}
pOut->PrintMessage("Card " + to_string(mostExpensive) + " was transferred to player" + to_string(poorest->getPlayerNumber()));
}
Card* CardTwelve::GetCopy(CellPosition& Pos)
{
return new CardTwelve(Pos);
}
void CardTwelve::Save(ofstream& OutFile)
{
OutFile << this->GetCardNumber() << "\t" << this->position.GetCellNum() << "\n";
}
void CardTwelve::Load(ifstream& Infile, Grid* pGrid)
{
pGrid->AddObjectToCell(this);
}