-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCutCardAction.cpp
63 lines (51 loc) · 1.77 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "CutCardAction.h"
#include "Input.h"
#include "Output.h"
#include "Grid.h"
#include "Card.h"
#include "Cell.h"
#include "CellPosition.h"
#include "CopyCardAction.h"
CutCardAction::CutCardAction(ApplicationManager* pApp):Action(pApp)
{
}
void CutCardAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput(); // Get a Pointer to the Input / Output Interfaces
pOut->PrintMessage("Click on the card you want to Cut...."); //Tells the user to click on the card he wants to Cut
CutCell = pIn->GetCellClicked();
pOut->ClearStatusBar();
}// Reads CutCardAction action parameters Cell Position
void CutCardAction::Execute()
{
ReadActionParameters();
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
if (CutCell.IsValidCell() == false)
{
pOut->PrintMessage("Invalid Cell...");
}
else if (!(pGrid->HasCard(CutCell)))
{
pOut->PrintMessage("The Cell selected has no Card....");
}
else if (pGrid->HasCard(CutCell) && CutCell.IsValidCell()) //Check if the cell chosen has a card or not.
{
pGrid->SetClipboard(CutCell); //Sets the ClipBoard with the cell position of the cell the player clicked onto
/*Card* pCard = new Card(0);
*pCard = *pGrid->GetClipboard();*/
pOut->PrintMessage("Card Cut Succesfully....");
pGrid->RemoveObjectFromCell(CutCell);
/*Card* CutCard = pGrid->GetClipboard();
CutCard->SetPosition(7, 2);
int action;
action = pGrid->RemoveObjectFromCell(CutCell);
*/
}
}// Cuts the card from the cell selected
CutCardAction::~CutCardAction()
{
}// A Virtual Destructor