-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCutCardAction.cpp
More file actions
72 lines (65 loc) · 1.8 KB
/
CutCardAction.cpp
File metadata and controls
72 lines (65 loc) · 1.8 KB
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
64
65
66
67
68
69
70
71
72
#include "CutCardAction.h"
#include "Input.h"
#include "Output.h"
#include "Card.h"
#include "CardOne.h"
#include "CardTwo.h"
#include "CardThree.h"
#include "CardFour.h"
#include "CardFive.h"
#include "CardSix.h"
#include "CardSeven.h"
#include "CardEight.h"
#include "CardNine.h"
#include "CardTen.h"
#include "CardEleven.h"
#include "CardTwelve.h"
#include "CardThirteen.h"
CutCardAction::CutCardAction(ApplicationManager* pApp) : Action(pApp)
{
// Initializes the pManager pointer of Action with the passed pointer
}
CutCardAction::~CutCardAction()
{
}
bool CutCardAction::ReadActionParameters()
{
// Get a Pointer to the Input / Output Interfaces
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pOut->PrintMessage("Cut Card: Click On The Source Cell ...");
sourcecardPosition = pIn->GetCellClicked();
if (!sourcecardPosition.IsValidCell())
{
return false;
}
// Clear messages
pOut->ClearStatusBar();
return true;
}
void CutCardAction::Execute()
{
Grid* pGrid = pManager->GetGrid();
Output* pOut = pGrid->GetOutput();
if (!ReadActionParameters())
{
pGrid->PrintErrorMessage("Error: Invalid Cell ! Click to continue ...");
return;
}
GameObject* SourceObject = pGrid->GetSourceObject(sourcecardPosition);
if (Card* SourceCard = dynamic_cast<Card*>(SourceObject))
{
Card* prevClipboard = pGrid->GetClipboard();
if (prevClipboard)
{
if (prevClipboard->GetPosition().GetCellNum() == -1) delete prevClipboard;
}
pGrid->SetClipboard(SourceCard);
pGrid->PrintErrorMessage("Cut Card Action Happened Successfully ...");
//pGrid->RemoveObjectFromCell(sourcecardPosition);
return;
}
pGrid->PrintErrorMessage("Error: No Source Cards to Cut in this position ...");
return;
}