-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoinSet.cpp
65 lines (51 loc) · 1.29 KB
/
CoinSet.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
#include "CoinSet.h"
#include "Input.h"
#include "Output.h"
#include "Player.h"
CoinSet::CoinSet(const int Amount, const CellPosition &CellPos) : GameObject(CellPos)
{
SetAmount(Amount);
}
CoinSet::CoinSet(){}
void CoinSet::Draw(Output* pOut) const
{
pOut->DrawCoinSet(position);
}
void CoinSet::Apply(Grid* pGrid, Player* pPlayer)
{
Input * in = pGrid->GetInput();
Output * out = pGrid->GetOutput();
int x,y;
out->PrintMessage("You have reached a coin set with amount value of " + to_string(Amount) + " | Click to continue ...");
in -> GetPointClicked(x,y);
out -> ClearStatusBar();
pPlayer -> SetWallet (pPlayer -> GetWallet() + Amount);
out -> PrintMessage("Your total wallet amount has increased to " + to_string (pPlayer -> GetWallet()) + " Coins | Click to continue ...");
in -> GetPointClicked(x,y);
out -> ClearStatusBar();
}
void CoinSet::SetAmount(int amount)
{
Amount = (amount >= 0 ? amount : -1);
}
int CoinSet::GetAmount() const
{
return Amount;
}
void CoinSet::Save(ofstream& outFile, Type gameObj)
{
if (gameObj == COINSETS)
{
outFile << position.GetCellNum() << ' ' << Amount << std::endl;
}
}
void CoinSet::Load(ifstream& InFile)
{
int cellNumber, coins;
InFile >> cellNumber >> coins;
position = CellPosition(cellNumber);
Amount = coins;
}
CoinSet::~CoinSet()
{
}