forked from ahmedibrahim404/Snakes_Ladders
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CutCardAction.cpp
48 lines (37 loc) · 1.1 KB
/
CutCardAction.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
#include "CutCardAction.h"
#include "Grid.h"
#include "Card.h"
CutCardAction::CutCardAction(ApplicationManager* pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
CutCardAction::~CutCardAction()
{
}
void CutCardAction::ReadActionParameters()
{
// Get a Pointer to the Input / Output Interfaces
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Please click on the card you want to cut ...");
CardPos = pIn->GetCellClicked();
}
void CutCardAction::Execute()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
ReadActionParameters();
pCard = pGrid->GetCard(CardPos); // Make the pointer point to the card that'll be cut
if (pCard == NULL) // If there is no card at the selected cell
{
pOut->PrintMessage("Invalid location!");
}
else
{
pGrid->SetClipboard(pCard->GetCopy(CardPos));
pGrid->RemoveObjectFromCell(CardPos);
pOut->PrintMessage("Card is cut succesfully!");
}
}