-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWaterPit.cpp
More file actions
41 lines (33 loc) · 879 Bytes
/
Copy pathWaterPit.cpp
File metadata and controls
41 lines (33 loc) · 879 Bytes
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
#include "WaterPit.h"
WaterPit::WaterPit(const CellPosition & waterPitPosition):GameObject(waterPitPosition)
{
}
void WaterPit::Draw(Output * pOut) const
{
pOut->DrawWaterPit(position);
}
void WaterPit::Apply(Grid * pGrid, Player * pPlayer)
{
int loser = pPlayer ->GetPlayerNum();
int winner = 1 - loser;
pPlayer->SetHealth(0);
pGrid->PrintErrorMessage("You drowned in a water pit. Player " + to_string(winner) + " winned");
pGrid->SetEndGame(true);
pGrid->UpdateInterface();
}
void WaterPit::Save(ofstream& OutFile, type Type, int n)
{
if (Type == waterpits)
{
OutFile << "WaterPit n" << n << " cell = " << position.GetCellNumFromPosition(position) << "\n";
}
}
void WaterPit::Load(ifstream& Infile)
{
int watercell;
Infile >> watercell; //get the cell number of saved waterpit
position = position.GetCellPositionFromNum(watercell);
}
WaterPit::~WaterPit()
{
}