-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkshop.cpp
More file actions
108 lines (92 loc) · 2.51 KB
/
Copy pathWorkshop.cpp
File metadata and controls
108 lines (92 loc) · 2.51 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "Workshop.h"
#include "Player.h"
#include "Grid.h"
#include "Input.h"
#include "Output.h"
Workshop::Workshop(const CellPosition & workshopPosition):GameObject( workshopPosition)
{
}
void Workshop::Draw(Output * pOut) const
{
pOut->DrawWorkshop(position);
}
void Workshop::Apply(Grid * pGrid, Player * pPlayer)
{
void Workshop::Apply(Grid * pGrid, Player * pPlayer)
{
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pPlayer->SetHealth(10);
if (!pGrid || !pPlayer)
return;
pOut->PrintMessage("You Reached a Workshop! Your health has been restored. Choose an option: 1. Double Laser 2. Toolkit 3. Hack Device ");
int choice = pIn->GetInteger(pOut);
switch (choice)
{
case 1:
pPlayer->EquipDoubleLaser();
pOut->PrintMessage("You have got Double Laser! Your attacks will have 2 damages.");
break;
case 2:
pPlayer->AddToolkit();
pOut->PrintMessage("You have got a Toolkit! You can now repair health instantly.");
break;
case 3:
pPlayer->AddHackDevice();
pOut->PrintMessage("You purchased a Hack Device! You will prevent your opponent from playing.");
break;
default:
pOut->PrintMessage("Invalid choice. No upgrade selected.");
break;
}
pOut->ClearStatusBar();
}
}
void Workshop::Save(ofstream& OutFile, type Type, int n)
{
if (Type == workshops)
{
OutFile << "Workshop n" << n << " cell = " << position.GetCellNumFromPosition(position) << "\n";
}
}
void Workshop::Load(ifstream& Infile)
{
int workcell;
Infile >> workcell; //get the cell number of saved workshop
position = position.GetCellPositionFromNum(workcell);
}
Workshop::~Workshop()
{
}
void Workshop::Apply(Grid * pGrid, Player * pPlayer)
{
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
pPlayer->SetHealth(10);
if (!pGrid || !pPlayer)
return;
pOut->PrintMessage("You Reached a Workshop! Your health has been restored. Choose an option: 1. Double Laser 2. Toolkit 3. Hack Device ");
int choice = pIn->GetInteger(pOut);
switch (choice)
{
case 1:
pPlayer->EquipDoubleLaser();
pOut->PrintMessage("You have got Double Laser! Your attacks will have 2 damages.");
break;
case 2:
pPlayer->AddToolkit();
pOut->PrintMessage("You have got a Toolkit! You can now repair health instantly.");
break;
case 3:
pPlayer->AddHackDevice();
pOut->PrintMessage("You purchased a Hack Device! You will prevent your opponent from playing.");
break;
default:
pOut->PrintMessage("Invalid choice. No upgrade selected.");
break;
}
pOut->ClearStatusBar();
}
Workshop::~Workshop()
{
}