-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCutCardAction.cpp
49 lines (41 loc) · 1.03 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
49
#include "CutCardAction.h"
#include "Input.h"
#include "Output.h"
#include "Grid.h"
#include "Card.h"
CutCardAction::CutCardAction(ApplicationManager* pApp) :Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
void CutCardAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Click on the source cell");
cardpos = pIn->GetCellClicked();
if (cardpos.HCell() == -1)
{
pGrid->PrintErrorMessage("Please click on a valid cell, Click to continue...");
}
}
void CutCardAction::Execute()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
ReadActionParameters();
pCard = pGrid->GetCardFromPosition(cardpos);
if (pCard == NULL)
{
pOut->PrintMessage("There is no card here!");
}
else {
pGrid->SetClipboard(pCard->GetCopy(cardpos));
pGrid->RemoveObjectFromCell(cardpos);
pOut->PrintMessage("Card Cut!");
}
}
CutCardAction::~CutCardAction()
{
}