forked from ahmedibrahim404/Snakes_Ladders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewGameAction.cpp
57 lines (40 loc) · 1.09 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
#include "NewGameAction.h"
#include "Grid.h"
#include "Output.h"
#include "Input.h"
#include "Player.h"
#include "CardNine.h"
#include "CardTen.h"
#include "CardEleven.h"
NewGameAction::NewGameAction(ApplicationManager* pApp) : Action(pApp)
{
}
void NewGameAction::ReadActionParameters()
{
}
void NewGameAction::Execute()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
CellPosition c1(1);
Player* currentPlayer;
// Reset Players
for (int i = 0; i < MaxPlayerCount; i++)
{
pGrid->setCurrentPlayer(i);
currentPlayer = pGrid->GetCurrentPlayer();
currentPlayer->ResetAll();
pGrid->UpdatePlayerCell(currentPlayer, c1);
}
// Set the first player to current player
pGrid->setCurrentPlayer(0);
pGrid->SetEndGame(false);
// Remove ownerships of the stations (cards 9-11) from players
CardNine::setOwner(NULL);
CardTen::setOwner(NULL);
CardEleven::setOwner(NULL);
pOut->PrintMessage("New Game!");
}
NewGameAction::~NewGameAction()
{
}