-
Notifications
You must be signed in to change notification settings - Fork 1
/
NewGameAction.cpp
45 lines (38 loc) · 975 Bytes
/
NewGameAction.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
#include "NewGameAction.h"
#include "Input.h"
#include "Output.h"
#include "Grid.h"
#include "Player.h"
NewGameAction::NewGameAction(ApplicationManager* pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
NewGameAction::~NewGameAction()
{
}
void NewGameAction::ReadActionParameters()
{
// No Action Parameters for the new game action.
}
void NewGameAction::Execute()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
// Creating A New CellPosition With CellNum 1
const CellPosition start(1);
Player* p;
// Looping On All Players
for (int i = 0; i < MaxPlayerCount; i++)
{
// Gets Current Player's address
p = pGrid->GetCurrentPlayer();
// Resets every player
p->Reset();
// Makes all the players return to cell number 1
pGrid->UpdatePlayerCell(p, start);
// Advances the player to reset the next one
pGrid->AdvanceCurrentPlayer();
}
// Resets the grid
pGrid->ResetGrid();
}