-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputDiceValueAction.cpp
More file actions
41 lines (37 loc) · 965 Bytes
/
InputDiceValueAction.cpp
File metadata and controls
41 lines (37 loc) · 965 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 "InputDiceValueAction.h"
#include "Grid.h"
#include "Player.h"
InputDiceValueAction::InputDiceValueAction(ApplicationManager* pApp) : Action(pApp)
{
}
void InputDiceValueAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Please enter a dice value between 1-6");
do {
diceValue = pIn->GetInteger(pOut);
pOut->ClearStatusBar();
}
while (!(diceValue<7 && diceValue>0));
}
void InputDiceValueAction::Execute()
{
ReadActionParameters();
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
if (pGrid->GetEndGame())
{
pOut->PrintMessage("The Game has ended, for another game click NewGame");
}
else
{
Player* pplayer = pGrid->GetCurrentPlayer();
pplayer->Move(pGrid, diceValue);
pGrid->AdvanceCurrentPlayer();
}
}
InputDiceValueAction::~InputDiceValueAction()
{
}