-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInputDiceValueAction.cpp
56 lines (40 loc) · 1.02 KB
/
InputDiceValueAction.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
49
50
51
52
53
#include "InputDiceValueAction.h"
#include "Grid.h"
#include "Player.h"
InputDiceValueAction::InputDiceValueAction(ApplicationManager* pApp) : Action(pApp)
{
}
InputDiceValueAction::~InputDiceValueAction()
{
}
void InputDiceValueAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Input Dice Value: Enter Dice Value...");
bool Test = false;
while (!Test)
{
InputNumber = pIn->GetInteger(pOut);
if (InputNumber > 6 || InputNumber < 1)
pOut->PrintMessage("Input Dice Value: You entered invalid Dice value try another one...");
else
Test = true;
}
pOut->ClearStatusBar();
}
void InputDiceValueAction::Execute()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
ReadActionParameters();
if (!pGrid->GetEndGame())
{
Player* pPlayer = pGrid->GetCurrentPlayer();
pPlayer->Move(pGrid, InputNumber);
pGrid->AdvanceCurrentPlayer();
}
else
pOut->PrintMessage("Game Finished");
}