-
Notifications
You must be signed in to change notification settings - Fork 1
/
CopyCardAction.cpp
47 lines (39 loc) · 991 Bytes
/
CopyCardAction.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
#include "CopyCardAction.h"
#include "Input.h"
#include "Output.h"
#include "Grid.h"
CopyCardAction::CopyCardAction(ApplicationManager* pApp) :Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
void CopyCardAction::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 CopyCardAction::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);
pOut->PrintMessage("Card Copied!");
}
}
CopyCardAction::~CopyCardAction()
{
}