-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCutCardAction.cpp
More file actions
35 lines (34 loc) · 1009 Bytes
/
CutCardAction.cpp
File metadata and controls
35 lines (34 loc) · 1009 Bytes
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
#include "CutCardAction.h"
CutCardAction::CutCardAction(ApplicationManager* pApp) : Action(pApp)
{
}
void CutCardAction::ReadActionParameters()
{
Grid* pGrid = pManager->GetGrid();
Input* pIn = pGrid->GetInput();
Output* pOut = pGrid->GetOutput();
pOut->PrintMessage("CutCardAction: Click on the source card !");
cardPos = pIn->GetCellClicked();
}
void CutCardAction::Execute()
{
ReadActionParameters();
if (cardPos.IsValidCell())
{
Grid* pGrid = pManager->GetGrid();
if (pGrid->GetClipboard())
if (pGrid->GetGameObjectOfCell(pGrid->GetClipboard()->GetPosition()) != pGrid->GetClipboard())
{
pGrid->AddObjectToCell(pGrid->GetClipboard());
pGrid->SetClipboard(nullptr);
}
GameObject* pObj = pGrid->GetGameObjectOfCell(cardPos);
if (dynamic_cast<Card*>(pObj))
{
pObj = pGrid->RemoveObjectFromCell(cardPos);
pGrid->SetClipboard((Card*)pObj);
Card::SetCardCount(Card::GetCardCount() -1);
pGrid->PrintErrorMessage("Cut to clipboard, click to continue...");
}
}
}