-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPumpkinPatch.cpp
More file actions
203 lines (191 loc) · 5.47 KB
/
PumpkinPatch.cpp
File metadata and controls
203 lines (191 loc) · 5.47 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/****************************
**Program: Final Project
**Name: Kirsten Carter
**Date: 6/3/2019
**Description: PumpkinPatch Class - Holds play function. Takes a pointer to the player, a reference to the vector named Inventory, and a reference to Steps. Inventory and Steps can be altered in this function.
** Takes the number of dead ferrets in your inventory and determines the odds for releasing Buckbeak
*****************************/
#include "PumpkinPatch.hpp"
#include <iostream>
#include "itemsHelper.hpp"
PumpkinPatch::PumpkinPatch()
{
}
void PumpkinPatch::play(People *player, std::vector<std::string> &inventory, int &steps)
{
if (steps >= 15)
{
std::cout << "The Ministry has beaten you to the Pumpkin Patch. You are too late to save Buckbeak." << std::endl;
player->setStrength(0);
}
else
{
//int playerChoice;
int numFerrets = 0;
bool buckbeak = false;
std::cout << "You made it to the Pumpkin Patch before the Ministry! To free Buckbeak you must first get him to fallow you. The more Dead Ferrets you have the easier it will be to convince him to move. You approach and bow holding the Ferrets you have collected at your side." << std::endl;
int size = inventory.size();
for(int i = 0; i<size; i++)
{
if(inventory[i] == "Dead Ferret")
{
++numFerrets;
}
}
std::cout << "You have " << numFerrets << " in your inventory \n" << std::endl;
while(buckbeak != true)
{
for (int i = 0; i < size; i++)
{
buckbeak = inventory[i] == "Buckbeak";
}
switch (numFerrets)
{
case 0:
case 1:
{
int chance = (rand() % (6 + 1));
if (chance == 6)
{
std::cout << "Even with your pitiful number of ferrets Buckbeak bows back and allows you to approach. You give him the ferrets and untie his lead from the steak in the ground." << std::endl;
if(size < 7)
{
itemAdd(inventory, "Buckbeak");
buckbeak = true;
} else
{
itemSwitch(inventory, "Buckbeak");
buckbeak = true;
}
} else
{
std::cout << "Buckbeak refuses to acknowledge you and your pitiful number of ferrets, try again." << std::endl;
}
}
break;
case 2:
{
int chance = (rand() % (6 + 2));
if (chance == 6)
{
std::cout << "With your 2 Ferrets Buckbeak bows back and allows you to approach. You give him the ferrets and untie his lead from the steak in the ground." << std::endl;
if (size < 7)
{
itemAdd(inventory, "Buckbeak");
buckbeak = true;
}
else
{
itemSwitch(inventory, "Buckbeak");
buckbeak = true;
}
}
else
{
std::cout << "With your 2 Ferrets Buckbeak refuses to acknowledge you, try again." << std::endl;
}
}
break;
case 3:
{
int chance = (rand() % (6 + 3));
if (chance == 6)
{
std::cout << "With your 3 Ferrets Buckbeak bows back and allows you to approach. You give him the ferrets and untie his lead from the steak in the ground." << std::endl;
if (size < 7)
{
itemAdd(inventory, "Buckbeak");
buckbeak = true;
}
else
{
itemSwitch(inventory, "Buckbeak");
buckbeak = true;
}
}
else
{
std::cout << "With your 3 Ferrets Buckbeak refuses to acknowledge you, try again." << std::endl;
}
}
break;
case 4:
{
int chance = (rand() % (6 + 4));
if (chance == 6)
{
std::cout << "With your 4 Ferrets Buckbeak bows back and allows you to approach. You give him the ferrets and untie his lead from the steak in the ground." << std::endl;
if (size < 7)
{
itemAdd(inventory, "Buckbeak");
buckbeak = true;
}
else
{
itemSwitch(inventory, "Buckbeak");
buckbeak = true;
}
}
else
{
std::cout << "With your 4 Ferrets Buckbeak refuses to acknowledge you, try again." << std::endl;
}
}
break;
case 5:
{
int chance = (rand() % (6 + 5));
if (chance == 6)
{
std::cout << "With your 5 Ferrets Buckbeak bows back and allows you to approach. You give him the ferrets and untie his lead from the steak in the ground." << std::endl;
if (size < 7)
{
itemAdd(inventory, "Buckbeak");
buckbeak = true;
}
else
{
itemSwitch(inventory, "Buckbeak");
buckbeak = true;
}
}
else
{
std::cout << "With your 5 Ferrets Buckbeak refuses to acknowledge you, try again." << std::endl;
}
}
break;
case 6:
default:
{
int chance = 6;
if (chance == 6)
{
std::cout << "With your 6 Ferrets Buckbeak bows back and allows you to approach. You give him the ferrets and untie his lead from the steak in the ground." << std::endl;
if (size < 7)
{
itemAdd(inventory, "Buckbeak");
buckbeak = true;
}
else
{
itemSwitch(inventory, "Buckbeak");
buckbeak = true;
}
}
else
{
std::cout << "With your 6 Ferrets Buckbeak refuses to acknowledge you, try again." << std::endl;
}
}
break;
}
}
std::cout << "Ok, we've got Buckbeak! Lets head to the Forbidden Forest." << std::endl;
player->setBuckbeak(true);
++steps;
}
}
PumpkinPatch::~PumpkinPatch()
{
}