-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPoison.cpp
48 lines (40 loc) · 1.07 KB
/
Poison.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
#include "Poison.h"
Poison::Poison(Grid* pGr, Player* attacker) : Attack(pGr, attacker)
{
AttackTarget = NULL;
}
void Poison::ReadAttackTarget()
{
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
while (AttackTarget == NULL)
{
pOut->PrintMessage("Enter the number of the player you want to attack (from 0 to " + to_string(MaxPlayerCount - 1) + ")");
int targetNum = pIn->GetInteger(pOut);
pOut->ClearStatusBar();
// get the player pointer with the num the user has entered
Player* targetPlayer = pGrid->GetPlayerWithNum(targetNum);
if (targetPlayer != NULL)
{
if (targetPlayer != Attacker)
AttackTarget = targetPlayer;
else
pGrid->PrintErrorMessage("You can't attack yourself! click to continue...");
}
else
{
pGrid->PrintErrorMessage("Invalid player number! click to continue...");
}
}
}
Player* Poison::getAttackTarget()
{
return AttackTarget;
}
void Poison::Execute()
{
ReadAttackTarget();
// set the poisoned data member in the attacked player to 5
AttackTarget->setPoisoned(5);
pGrid->AdvanceCurrentPlayer();
}