-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fightroom2.cs
334 lines (202 loc) · 11.4 KB
/
Fightroom2.cs
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B.O.O.T.Y
{
class FightRoom2: Room
{
InputManager InputManager = new InputManager();
public FightRoom2()
{
Console.WriteLine("You enter another cave, but this time you hear the enemy before it attacks");
}
// Se Room för att få en bättre förklaring
public override Enemy EnterRoom()
{
return base.EnterRoom();
}
//Denna metod har hand om hela fighten när spelaren går in i ett fightroom, parametrarna som tas in är spelaren och den fienden som slumpades fram i EnterRoom
//Denna metod innehåller 9 olika scenarion som beror på vad fienden slumpar fram för val och vad spelaren själv väljer
//Se FightRoom för en tydligare förklaring
public override int Battle(ThePirates player, Character foe)
{
Console.WriteLine("You enter a room that seems to be pretty quiet. The cave is humongos with a little hole at the top for light to stream trhough");
Console.WriteLine("However when you are distracted by the little hole you hear a screah and the tap of feet");
Console.WriteLine("You tell your man to get ready for a scrap");
//Det finns nio olika senarion som kan hända beroende på spelaren och fiendens val
//fiendes val kommer att slumpas fram varje omgång
foe = EnterRoom(); // Det som retunardes från EnterRoom vilket var en enemy, kommer sparas i character foe. Det är den karaktären som spelaren kommer slåss mot
while (player.hp > 0 && foe.hp > 0)// Denna loop kommer köras så länge som båda kämparnas hp är över 0
{
Console.WriteLine("What would you like to do, press 1, 2 or 3 to decide");
Console.WriteLine("1.Attack");
Console.WriteLine("2.Dodge");
Console.WriteLine("3.Charm");
string input = Console.ReadLine();
input = InputManager.NumberChose(input);
int randomNumber = generator.Next(0, 2);
if (input == "1" && randomNumber == 0)// if player attack and foe attack, Både spelaren och fienden kommer ta skada
{
Console.WriteLine("You attacked and your foe attacked");
int playerAttack = player.Attack();
int foeAttack = foe.Attack();
player.hp = player.GetDamaged(foeAttack);
foe.hp = foe.GetDamaged(playerAttack);
Console.WriteLine("You did " + playerAttack + " points of damage");
Console.WriteLine("The foe did " + foeAttack + " points of damage");
Console.WriteLine("your hp is at " + player.hp);
}
else if (input == "1" && randomNumber == 1) // if player attack and foe dodge
// Om spelaren lyckas få en högre accuracy än fiendens dodge kommer spelaren skada fienden, annars kommer fienden komma undan och ingen tar skada
{
Console.WriteLine("You attacked and your foe dodged");
int playerAccuracy = player.HittingTarget();
int foeDodge = foe.Dodge();
if (playerAccuracy >= foeDodge)
{
int playerAttack = player.Attack();
foe.hp = foe.GetDamaged(playerAttack);
Console.WriteLine("The foe did not manage to dodge");
Console.WriteLine("You did " + playerAttack + " points of damage");
}
else if (foeDodge > playerAccuracy)
{
Console.WriteLine("The foe manage to dodge");
}
}
else if (input == "1" && randomNumber == 2)// if player attack and foe charm // spelarens accuracy måste vara högre än fiendens charm. Är den det kommer fienden ta skada annars tar spelaren skada
{
Console.WriteLine("You attacked and your foe tried to charm you");
int playerAccuracy = player.HittingTarget();
int foeCharm = foe.Charm();
if (playerAccuracy > foeCharm)
{
int playerAttack = player.Attack();
foe.hp = foe.GetDamaged(playerAttack);
Console.WriteLine("The foe did not manage to charm you");
Console.WriteLine("You did " + playerAttack + " points of damage");
}
else if (foeCharm >= playerAccuracy)
{
player.hp = player.hp - 8;
Console.WriteLine("The foe did manage to charm you");
Console.WriteLine("you took 8 damage");
}
}
else if (input == "2" && randomNumber == 0) //if player dodge and foe attack
// Om spelaren lyckas få en högre dex score än fiendens accuracy kommer spelaren undan och ingen tar skada, annars träffar fienden spelaren och den tar skada
{
Console.WriteLine("You dodged and your foe tried to attack you");
int foeAccuracy = foe.HittingTarget();
int playerDodge = player.Dodge();
if (foeAccuracy >= playerDodge)
{
int foeAttack = foe.Attack();
player.hp = player.GetDamaged(foeAttack);
Console.WriteLine("The foe did " + foeAttack + " points of damage");
Console.WriteLine("your hp is at " + player.hp);
}
else if (playerDodge > foeAccuracy)
{
Console.WriteLine("you managed to dodge the attack");
}
}
else if (input == "2" && randomNumber == 1) //if player dodge and foe dodge // Båda tar skydd och ingen tar skada eller får konsekvenser
{
Console.WriteLine("You both tried to dodge");
}
else if (input == "2" && randomNumber == 2)// if player dodge and foe charm
// spelarens dex score måste vara högre än fiendens charm. Är den det kommer spelaren undan och ingen tar skada om fiendens charm är högre än spelarens dex kommer spelaren ta skada
{
Console.WriteLine("You dodged and your foe tried to charm you");
int playerDodge = player.Dodge();
int foeCharm = foe.Charm();
if (playerDodge >= foeCharm)
{
Console.WriteLine("You managed to dodge the attack");
}
else if (foeCharm > playerDodge)
{
player.hp = player.hp - 8;
Console.WriteLine("The foe did 8 points of damage");
Console.WriteLine("your hp is at " + player.hp);
}
}
else if (input == "3" && randomNumber == 0) //if player charm and foe attack// spelarens charm score måste vara högre än fiendens accuracy. Är den det kommer fienden ta skada annars tar spelaren skada
{
Console.WriteLine("You tried to charm and your foe tried to attack you");
int foeAccuracy = foe.HittingTarget();
int playerCharm = player.Charm();
if (foeAccuracy > playerCharm)
{
Console.WriteLine("You didn`t manage to charm your foe");
int foeAttack = foe.Attack();
player.hp = player.GetDamaged(foeAttack);
Console.WriteLine("The foe did " + foeAttack + " points of damage");
Console.WriteLine("your hp is at " + player.hp);
}
else if (playerCharm >= foeAccuracy)
{
foe.hp = foe.hp - 8;
Console.WriteLine("Your foe didn´T manage to get to you within time, your charm was a success");
Console.WriteLine("You dealt 8 damage to the foe");
}
}
else if (input == "3" && randomNumber == 1) //if player charm and foe dodge
{// spelarens charm score måste vara högre än fiendens dex. Är den det kommer fienden ta skada, däremot om fiendens dex score är högre än spelarens charm tar ingen skada
Console.WriteLine("You tried to charm and your foe tried to dodge");
int foeDodge = foe.Dodge();
int playerCharm = player.Charm();
if (foeDodge >= playerCharm)
{
Console.WriteLine("The foe managed to dodge");
}
else if (playerCharm > foeDodge)
{
foe.hp = foe.hp - 8;
Console.WriteLine("You dealt 8 damage to the foe");
}
}
else if (input == "3" && randomNumber == 2)// if player charm and foe charm // Om fiendens charm är högst tar spelaren skada men om spelarens charm är högst tar fienden skada
{
Console.WriteLine("You and your foe tried to charm each other");
int playerCharm = player.Charm();
int foeCharm = foe.Charm();
if (foeCharm > playerCharm)
{
player.hp = player.hp - 8;
Console.WriteLine("You suffered 8 damage");
Console.WriteLine("Your hp at " + player.hp + " points");
}
else if (playerCharm > foeCharm)
{
foe.hp = foe.hp - 8;
Console.WriteLine("You dealt 8 damage to the foe");
}
else if (playerCharm == foeCharm)
{
Console.WriteLine("nothing happened you both charmed the the same amount");
}
}
}
if (player.hp > 0 && foe.hp < 0) //Kommer retunera spelarens hp om spelaren lever
{
Console.WriteLine("Hurray you do not die");
return player.hp;
}
else if (player.hp < 0 && foe.hp > 0)//Kommer retunera spelarens hp om fienden lever
{
Console.WriteLine("oh no you died");
return player.hp;
}
else if (player.hp < 0 && foe.hp < 0)//Kommer retunera spelarens hp om spelaren oc fienden är döda
{
Console.WriteLine("oh no you died, but so is your foe");
return player.hp;
}
return player.hp;
}
}
}