-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDangerZone.cpp
More file actions
51 lines (37 loc) · 1.21 KB
/
Copy pathDangerZone.cpp
File metadata and controls
51 lines (37 loc) · 1.21 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
#include "DangerZone.h"
#include "Player.h"
DangerZone::DangerZone(const CellPosition & dangerZonePosition): GameObject(dangerZonePosition)
{
}
void DangerZone::Draw(Output * pOut) const
{
pOut->DrawDangerZone(position);
}
void DangerZone::Apply(Grid * pGrid, Player * pPlayer)
{
///TODO: Implement this function as mentioned in the guideline steps (numbered below) below
// 1- Print a message to inform the player about the danger zone
pGrid->GetOutput()->PrintMessage("You have reached a danger zone. Click to continue...");
pGrid->GetInput()->GetCellClicked(); // Wait for user acknowledgment
// 2- Reduce the health of the player by 1
pPlayer->SetHealth(pPlayer->GetHealth() - 1);
// 3- Update the player's information displayed on the grid
pGrid->UpdateInterface();
}
void DangerZone::Save(ofstream& OutFile, string file)
{
if (!OutFile.is_open())
OutFile.open(file, ios::out);
OutFile << position.GetCellNum() << endl;
}
void DangerZone::Load(ifstream& Infile, string file)
{
if (!Infile.is_open())
Infile.open(file, ios::in);
int cellNum;
Infile >> cellNum;
position = CellPosition::GetCellPositionFromNum(cellNum);
}
DangerZone::~DangerZone()
{
}