-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInputDiceValueAction.cpp
More file actions
53 lines (46 loc) · 1.22 KB
/
InputDiceValueAction.cpp
File metadata and controls
53 lines (46 loc) · 1.22 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
#include "InputDiceValueAction.h"
#include "Input.h"
#include "Output.h"
#include"Grid.h"
#include"Player.h"
InputDiceValueAction::InputDiceValueAction(ApplicationManager* pApp) :Action(pApp)
{
}
InputDiceValueAction::~InputDiceValueAction()
{
}
bool InputDiceValueAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Enter A Dice Value ...");
Dicevalue = pIn->GetInteger(pOut);
while (Dicevalue < 1 || Dicevalue>6)
{
pOut->PrintMessage("Invalid Dice Value,Please Enter A number between 1 and 6");
Dicevalue = pIn->GetInteger(pOut);
}
pOut->DrawDiceValue(Dicevalue);
pIn->GetCellClicked();
pOut->ClearStatusBar();
return true;
}
void InputDiceValueAction::Execute()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
if (pGrid->GetEndGame())
{
pOut->PrintMessage("Game Is Over ...");
pOut->DrawPlayerWins(4);
pIn->GetCellClicked();
pOut->ClearStatusBar();
return;
}
Player* pPlayer = pGrid->GetCurrentPlayer();
ReadActionParameters();
pPlayer->Move(pGrid, Dicevalue);
pGrid->AdvanceCurrentPlayer();
}