-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDangerZone.cpp
More file actions
58 lines (44 loc) · 1.51 KB
/
Copy pathDangerZone.cpp
File metadata and controls
58 lines (44 loc) · 1.51 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
#include "DangerZone.h"
DangerZone::DangerZone(const CellPosition & dangerZonePosition): GameObject(dangerZonePosition)
{
}
void DangerZone::Draw(Output * pOut) const
{
pOut->DrawDangerZone(position);
}
void DangerZone::Apply(Grid * pGrid, Player * pPlayer)
{
pGrid->PrintErrorMessage("You have reached a danger zone. Click to continue...");
int NewHealth = pPlayer->GetHealth() - 1;
pPlayer->SetHealth(NewHealth);
if (NewHealth == 0)
{
int loser = pPlayer->GetPlayerNum();
int winner = 1 - loser;
pGrid->PrintErrorMessage("Your health is done, Player " + to_string(winner) + " winned");
pGrid->SetEndGame(true);
}
pGrid->UpdateInterface();
///TODO: Implement this function as mentioned in the guideline steps (numbered below) below
//done
// == Here are some guideline steps (numbered below) to implement this function ==
// 1- Print a message "You have reached a danger zone. Click to continue ..." and wait mouse click
// 2- Apply the danger zone's effect by reducing the health of the player by 1
// 3- Update the players info which is displayed (check Grid class and decide which function to use)
}
void DangerZone::Save(ofstream& OutFile, type Type, int n)
{
if (Type == dangerzones)
{
OutFile << "DangerZone n" << n << " cell = " << position.GetCellNumFromPosition(position) << "\n";
}
}
void DangerZone::Load(ifstream& Infile)
{
int watercell;
Infile >> watercell; //get the cell number of saved waterpit
position = position.GetCellPositionFromNum(watercell);
}
DangerZone::~DangerZone()
{
}