-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopy.cpp
More file actions
63 lines (49 loc) · 1.45 KB
/
Copy pathCopy.cpp
File metadata and controls
63 lines (49 loc) · 1.45 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
#include "Copy.h"
#include "Action.h"
#include "Grid.h"
#include "CellPosition.h"
#include "Flag.h"
#include "Antenna.h"
void Copy::ReadActionParameters()
{
Grid* pGride = pManager->GetGrid();
Input* Pinp = pGride->GetInput();
pGride->GetOutput()->PrintMessage("Click on Cell to Copy");
copiedCELL = Pinp->GetCellClicked();
if (!copiedCELL.IsValidCell()) //checks if the cell is valid
{
pGride->PrintErrorMessage("Invalid Cell");
return;
}
}
void Copy::Execute()
{
Grid* pGride = pManager->GetGrid();
ReadActionParameters();
if (!copiedCELL.IsValidCell()) //checks if the cell is valid
{
pGride->PrintErrorMessage("The Cell is Invalid");
return;
}
GameObject* copiedOBJ = pGride->getGameobject(copiedCELL);
if (copiedOBJ == nullptr) //checks if the cell contains any object
{
pGride->PrintErrorMessage("The Cell doesnt contain any Object");
return;
}
if (dynamic_cast<Flag*>(copiedOBJ) != nullptr) //if it's a flag reject to copy
{
pGride->PrintErrorMessage("Error: The Cell contains a Flag object, copying is not allowed.");
return;
}
if (dynamic_cast<Antenna*>(copiedOBJ) != nullptr) //if it's a flag reject to copy
{
pGride->PrintErrorMessage("Error: The Cell contains an Antenna object, copying is not allowed.");
return;
}
pGride->SetClipboard(copiedOBJ); //setting clipboard
pGride->GetOutput()->PrintMessage("Object copied successfully");
}
Copy::~Copy()
{
}