-
Notifications
You must be signed in to change notification settings - Fork 1
/
yrdalgedal.html
607 lines (595 loc) · 32.2 KB
/
yrdalgedal.html
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Yrdal Gedal</title>
<link rel="stylesheet" type="text/css" href="css/browser_reset.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<style>
html {
background: url("images/Yrdal_Gedal.jpeg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
<script>
var dialoguecount = 0;
function stats() {
if (sessionStorage.getItem("ship") == "bloodstar") {
document.getElementById("shipicon").innerHTML = "<img src='images/Bloodstar.jpeg' width='150' alt='The Bloodstar ship' /><p style='font-size: 15px;'>Ship: Bloodstar</p><p style='font-size: 15px;'>HP: " + hp + "</p><p style='font-size: 15px;'>Bonus: Extra HP</p>";
} else if (sessionStorage.getItem("ship") == "blue fyre") {
document.getElementById("shipicon").innerHTML = "<img src='images/Blue_Fyre.png' width='150' alt='The Blue Fyre ship' /><p style='font-size: 15px;'>Ship: Blue Fyre</p><p style='font-size: 15px;'>HP: " + hp + "</p><p style='font-size: 10px;'>Bonus: 50% chance to attack twice</p>";
} else if (sessionStorage.getItem("ship") == "gator custom") {
document.getElementById("shipicon").innerHTML = "<img src='images/Gator_Custom.png' width='150' alt='The Gator Custom ship' /><p style='font-size: 15px;'>Ship: Gator Custom</p><p style='font-size: 15px;'>HP: " + hp + "</p><p style='font-size: 8px;'>Bonus: 100% more dmg with missiles</p>";
} else if (sessionStorage.getItem("ship") == "amboss") {
document.getElementById("shipicon").innerHTML = "<img src='images/Amboss.png' width='150' alt='The Amboss ship' /><p style='font-size: 15px;'>Ship: Amboss</p><p style='font-size: 15px;'>HP: " + hp + "</p><p style='font-size: 10px;'>Bonus: 40% dodge chance</p>";
} else if (sessionStorage.getItem("ship") == "dark angel") {
document.getElementById("shipicon").innerHTML = "<img src='images/Dark_Angel.jpeg' width='150' alt='The Dark Angel ship' /><p style='font-size: 15px;'>Ship: Dark Angel</p><p style='font-size: 15px;'>HP: " + hp + "</p><p style='font-size: 8px;'>Bonus: 300% more dmg under 50% HP</p>";
}
return false;
}
function continuebutton() {
dialoguecount += 1;
if (sessionStorage.getItem("victoryyrdalgedal") == null) {
gamestart();
} else {
afterbattle();
}
return false;
}
function gamestart() {
if (sessionStorage.getItem("victoryyrdalgedal") == "beaten") {
dialoguecount = -1;
}
if (dialoguecount == 0) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The Narrator<img src='images/Narrator.png' width='60' alt='The narrator' style='margin-right: 20px; margin-left: 20px;'/>After fending off the pirates, our brave hero ventures to do Gunant Breh's task in Yrdal Gedal, a Terran hub of trade.<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 1) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The Narrator<img src='images/Narrator.png' width='60' alt='The narrator' style='margin-right: 20px; margin-left: 20px;'/>After a moment's search, he finally finds Breh's convoy, safe and intact.<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 2) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Keith T. Maxwell<img src='images/Keith_T_Maxwell.png' width='50' alt='Keith T Maxwell icon' style='margin-right: 20px; margin-left: 20px;'/>Hey, there it is! Roger, zero one three zero speaking. I was asked to ensure your safety by Gunant Breh. I'll await your response.<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 3) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Terran<img src='images/Terran.png' width='50' alt='a Terran icon' style='margin-right: 20px; margin-left: 20px;'/>Unfamiliar craft approaching. All convoy units, proceed with caution.<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 4) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Keith T. Maxwell<img src='images/Keith_T_Maxwell.png' width='50' alt='Keith T Maxwell icon' style='margin-right: 20px; margin-left: 20px;'/>Wait, what? I'm friendly! It's not like I'm a pirate or anything!<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 5) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Terran<img src='images/Terran.png' width='50' alt='a Terran icon' style='margin-right: 20px; margin-left: 20px;'/>\"Pirate\" was heard on the comms. HOSTILE! I repeat, HOSTILE! All fighter units, engage the enemy!<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 6) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Keith T. Maxwell<img src='images/Keith_T_Maxwell.png' width='50' alt='Keith T Maxwell icon' style='margin-right: 20px; margin-left: 20px;'/>HEY! I'm not a pirate! Uh oh, this is bad.<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 7) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Keith T. Maxwell<img src='images/Keith_T_Maxwell.png' width='50' alt='Keith T Maxwell icon' style='margin-right: 20px; margin-left: 20px;'/>Blast, it must be my decades-old model of a ship that makes them think I'm a pirate. Like I scavenged it somewhere.<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 8) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Keith T. Maxwell<img src='images/Keith_T_Maxwell.png' width='50' alt='Keith T Maxwell icon' style='margin-right: 20px; margin-left: 20px;'/>Well, I have no choice but to fight. WHOA, there's a lot of them!<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
} else if (dialoguecount == 9) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The Narrator<img src='images/Narrator.png' width='60' alt='The narrator' style='margin-right: 20px; margin-left: 20px;'/>Will our hero make it out alive? Click \"continue\" and click \"Battle\"<button id='continuebutton' onclick='displayBattle()'>Continue</button><button id='continuebutton' onclick='displayBattle()'>Skip</button></div>";
}
return false;
}
function displayBattle() {
document.getElementById("displaybattle").innerHTML = "<button onclick='battle()' class='centrebutton'>Battle</button>";
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>BATTLE UNLOCKED</div>";
return false;
}
function randomInt(pmin, pmax) {
var randomnumber = Math.floor(Math.random() * (pmax - pmin + 1) + pmin);
return(randomnumber);
}
function autowin() {
victory = true;
victorycheck();
return false;
}
function getship() {
if (sessionStorage.getItem("ship") == "bloodstar") {
shipname = "Bloodstar";
shipimg = "Bloodstar.jpeg";
shipalt = "The Bloodstar ship";
} else if (sessionStorage.getItem("ship") == "blue fyre") {
shipname = "Blue Fyre";
shipimg = "Blue_Fyre.png";
shipalt = "The Blue Fyre ship";
} else if (sessionStorage.getItem("ship") == "gator custom") {
shipname = "Gator Custom";
shipimg = "Gator_Custom.png";
shipalt = "The Gator Custom ship";
} else if (sessionStorage.getItem("ship") == "amboss") {
shipname = "Amboss";
shipimg = "Amboss.png";
shipalt = "The Amboss ship";
} else if (sessionStorage.getItem("ship") == "dark angel") {
shipname = "Dark Angel";
shipimg = "Dark_Angel.jpeg";
shipalt = "The Dark Angel ship";
}
return false;
}
function createbattlefield() {
shields();
document.getElementById("dialoguebox").innerHTML = "";
document.getElementById("displaybattle").innerHTML = "<button onclick='battle()' class='centrebutton'>Battle</button><br><button onclick='autowin()' class='centrebutton'>Auto-Win</button>";
document.getElementById("shipicon").innerHTML = "<img src='images/'" + shipimg + " width='150' alt='" + shipalt + "' /><p style='font-size: 15px;'>Ship: " + shipname + "</p><p style='font-size: 15px;'>HP: " + hp + "</p><p style='font-size: 15px;'>Bonus: Extra HP</p>";
document.getElementById("battlefield").innerHTML = "<h2>Battlefield</h2><table id='battlefieldbox'><tr><td><img src='images/Terran_Enemy.jpeg' width='150' alt='Enemy Terran spaceship' style='" + enemyshieldup + "'/><p>Terran</p><p>HP: " + enemyhp + "</p></td></tr><tr><td><img src='images/" + shipimg + "' width='150' alt='" + shipalt + "' style='" + shieldup + "'><p>" + shipname + "</p><p>HP: " + hp + "</td></tr></table>";
document.getElementById("turnmenu").innerHTML = "<table><tr><td><p>Attack Menu</p><form id='attackmenu' name='Attack Menu' method='post'><p><input checked type='radio' id='Lasers' name='attack' value='lasers' />Lasers</p><p><input type='radio' id='Missiles' name='attack' value='missiles' />Missiles</p><p><input type='radio' id='Repair' name='attack' value='repair' />Repair</p></form></td><td><p>Defend Menu</p><form id='defend menu' name='Defend Menu' method='post'><p><input checked type='radio' id='Shield' name='defend' value='shield' />Shield</p><p><input type='radio' id='Hull' name='defend' value='hull' />Hull</p><p><input type='radio' id='Charge' name='defend' value='charge' />Charge</p></form></td></tr></table><br><p><button onclick='endturn()' class='centrebutton'>End Turn</button></p>";
stats();
return false;
}
function shields() {
if (charge == true) {
shieldup = "border: solid; border-color: red; border-width: 5px;";
} else if (shield == true) {
shieldup = "border: solid; border-color: blue; border-width: 5px;";
} else if (shield == false) {
shieldup = "";
}
if (enemycharge == true) {
enemyshieldup = "border: solid; border-color: red; border-width: 5px;";
} else if (enemyshield == true) {
enemyshieldup = "border: solid; border-color: blue; border-width: 5px;";
} else if (enemyshield == false) {
enemyshieldup = "";
}
return false;
}
function bloodstar() {
if (sessionStorage.getItem("ship") == "bloodstar") {
hp = 100;
maxhp = 100;
}
return false;
}
function bluefyre() {
if (sessionStorage.getItem("ship") == "blue fyre") {
if (randomInt(1, 2) == 1) {
enemyhp -= dmg;
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The Blue Fyre struck twice! You dealt " + dmg + " damage again!<button id='continuebutton' onclick='enemyturn()'>Continue</button></div>";
victorycheck();
} else {
enemyturn();
}
} else {
enemyturn();
}
return false;
}
function darkangel() {
if (sessionStorage.getItem("ship") == "dark angel") {
if (hp < (maxhp * 0.5)) {
dmg *= 4;
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The Dark Angel has powered up!<button id='continuebutton' onclick='enemyturn()'>Continue</button></div>";
}
}
return false;
}
function gatorcustom() {
if (sessionStorage.getItem("ship") == "gator custom") {
dmg *= 2;
}
return false;
}
function amboss() {
if (sessionStorage.getItem("ship") == "amboss") {
dodgechance = randomInt(1, 10);
if (dodgechance >= 1 && dodgechance <= 4) {
ambossdodge = true;
enemydmg = 0;
}
}
return false;
}
function raccoon() {
if (sessionStorage.getItem("devweapon") == "raccoon") {
dmg = enemyhp;
}
return false;
}
function enemyhplimit() {
if (enemyhp < 0) {
enemyhp = 0;
}
return false;
}
function hplimit() {
if (hp < 0) {
hp = 0;
}
return false;
}
function maxhplimit() {
if (hp > maxhp) {
hp = maxhp;
}
return false;
}
function lasers() {
if (charge == true || enemycharge == true) {
dmg = 10;
darkangel();
if (charge == true) {
if (randomInt(1, 4) == 1) {
dmg *= 5;
}
}
raccoon();
enemyhp -= dmg;
enemyhplimit();
if (charge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used lasers while charged! You dealt " + dmg + " damage!<button id='continuebutton' onclick='bluefyre()'>Continue</button></div>";
} else if (enemycharge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used lasers while the enemy was charged! You dealt " + dmg + " damage!<button id='continuebutton' onclick='bluefyre()'>Continue</button></div>";
}
victorycheck();
} else if (enemyshield == true) {
dmg = 10;
raccoon();
darkangel();
enemyhp -= dmg;
enemyhplimit();
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used lasers! You dealt " + dmg + " damage!<button id='continuebutton' onclick='bluefyre()'>Continue</button></div>";
victorycheck();
} else if (enemyshield == false) {
dmg = 5;
raccoon();
darkangel();
enemyhp -= dmg;
enemyhplimit();
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used lasers! You dealt " + dmg + " damage!<button id='continuebutton' onclick='bluefyre()'>Continue</button></div>";
victorycheck();
}
return false;
}
function missiles() {
if (charge == true || enemycharge == true) {
dmg = 10;
darkangel();
gatorcustom();
if (charge == true) {
if (randomInt(1, 4) == 1) {
dmg *= 5;
}
}
enemyhp -= dmg;
enemyhplimit();
if (charge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used missiles while charged! You dealt " + dmg + " damage!<button id='continuebutton' onclick='bluefyre()'>Continue</button></div>";
} else if (enemycharge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used missiles while the enemy was charged! You dealt " + dmg + " damage!<button id='continuebutton' onclick='bluefyre()'>Continue</button></div>";
}
victorycheck();
} else if (enemyshield == true) {
dmg = 5;
darkangel();
gatorcustom();
enemyhp -= dmg;
enemyhplimit();
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used missiles! You dealt " + dmg + " damage!<button id='continuebutton' onclick='bluefyre()'>Continue</button></div>";
victorycheck();
} else if (enemyshield == false) {
dmg = 10;
darkangel();
gatorcustom();
enemyhp -= dmg;
enemyhplimit();
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used missiles! You dealt " + dmg + " damage!<button id='continuebutton' onclick='bluefyre()'>Continue</button></div>";
victorycheck();
}
return false;
}
function repair() {
var healchance = randomInt(1, 10);
if (healchance == 1) {
hp += 20;
maxhplimit();
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used repair and got lucky! You healed 20 HP!<button id='continuebutton' onclick='enemyturn()'>Continue</button></div>";
} else {
hp += 10;
maxhplimit();
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You used repair! You healed 10 HP!<button id='continuebutton' onclick='enemyturn()'>Continue</button></div>";
}
return false;
}
function shieldZ() {
shield = true;
return false;
}
function hullZ() {
shield = false;
return false;
}
function chargeZ() {
charge = true;
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You are charging up!<button id='continuebutton' onclick='enemyturn()'>Continue</button></div>";
return false;
}
function enemylasers() {
if (enemycharge == true || charge == true) {
enemydmg = 10;
if (enemycharge == true) {
if (randomInt(1, 4) == 1) {
enemydmg *= 3;
}
}
amboss();
hp -= enemydmg;
hplimit();
defeatcheck();
if (enemycharge == true) {
if (ambossdodge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers while charged! You dodged the attack!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
} else {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers while charged! The enemy dealt " + enemydmg + " damage!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
}
} else if (charge == true) {
if (ambossdodge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers while you were charged! You dodged the attack!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
} else {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers while you were charged! The enemy dealt " + enemydmg + " damage!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
}
}
} else if (shield == true) {
enemydmg = 10;
amboss();
hp -= enemydmg;
hplimit();
defeatcheck();
if (ambossdodge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers! You dodged the attack!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
} else {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers! The enemy dealt " + enemydmg + " damage!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
}
defeatcheck();
} else if (shield == false) {
enemydmg = 5;
amboss();
hp -= enemydmg;
hplimit();
defeatcheck();
if (ambossdodge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers! You dodged the attack!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
} else {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers! The enemy dealt " + enemydmg + " damage!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
}
}
ambossdodge = false;
return false;
}
function enemymissiles() {
if (enemycharge == true || charge == true) {
enemydmg = 10;
if (enemycharge == true) {
if (randomInt(1, 4) == 1) {
enemydmg *= 3;
}
}
amboss();
hp -= enemydmg;
hplimit();
defeatcheck();
if (enemycharge == true) {
if (ambossdodge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers while charged! You dodged the attack!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
} else {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers while charged! The enemy dealt " + enemydmg + " damage!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
}
} else if (charge == true) {
if (ambossdodge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers while you were charged! You dodged the attack!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
} else {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used lasers while you were charged! The enemy dealt " + enemydmg + " damage!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
}
}
} else if (shield == true) {
enemydmg = 5;
amboss();
hp -= enemydmg;
hplimit();
defeatcheck();
if (ambossdodge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used missiles! You dodged the attack!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
} else {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used missiles! The enemy dealt " + enemydmg + " damage!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
}
} else if (shield == false) {
enemydmg = 10;
amboss();
hp -= enemydmg;
hplimit();
defeatcheck();
if (ambossdodge == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used missiles! You dodged the attack!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
} else {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy used missiles! The enemy dealt " + enemydmg + " damage!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
}
}
ambossdodge = false;
return false;
}
function enemyshieldZ() {
enemyshield = true;
enemycharge = false;
return false;
}
function enemyhullZ() {
enemyshield = false;
enemycharge = false;
return false;
}
function enemychargeZ() {
enemycharge = true;
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The enemy is charging up!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
return false;
}
function endturn() {
if (document.getElementById("Charge").checked) {
chargeZ();
} else if (document.getElementById("Lasers").checked) {
lasers();
} else if (document.getElementById("Missiles").checked) {
missiles();
} else if (document.getElementById("Repair").checked) {
repair();
}
if (document.getElementById("Shield").checked) {
charge = false;
shieldZ();
} else if (document.getElementById("Hull").checked) {
charge = false;
hullZ();
}
return false;
}
function enemyturn() {
createbattlefield();
defendchance = randomInt(1, 100);
if (defendchance < 1) {
enemyshieldZ();
} else if (defendchance >= 1 && defendchance <= 85) {
enemyhullZ();
} else if (defendchance >= 86 && defendchance <= 100 && enemycharge == false) {
enemychargeZ();
}
if (enemycharge == false) {
attackchance = randomInt(1, 2);
if (attackchance == 1) {
enemylasers();
} else if (attackchance == 2) {
enemymissiles();
}
}
return false;
}
function victorycheck() {
enemyhplimit();
if (enemyhp == 0) {
enemycount -= 1;
enemyhp = 50;
justkilledenemy = true;
document.getElementById("battlefield").innerHTML = "<h2>Battlefield</h2><table id='battlefieldbox'><tr><td><img src='images/explosion.png' width='150' alt='explosion, a very dead enemy'</p></td></tr><tr><td><img src='images/" + shipimg + "' width='150' alt='" + shipalt + "' style='" + shieldup + "'><p>" + shipname + "</p><p>HP: " + hp + "</td></tr></table>";
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>You defeated an enemy!<button id='continuebutton' onclick='battle()'>Continue</button></div>";
if (enemycount == 0) {
victory = true;
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The oncoming horde overwhelms you...<button id='continuebutton' onclick='afterbattle()'>Continue</button></div>";
afterbattle();
}
}
if (victory == true) {
dialoguecount = 0;
document.getElementById("battlefield").innerHTML = "<h2>Battlefield</h2><table id='battlefieldbox'><tr><td><img src='images/explosion.png' width='150' alt='explosion, a very dead enemy'</p></td></tr><tr><td><img src='images/" + shipimg + "' width='150' alt='" + shipalt + "' style='" + shieldup + "'><p>" + shipname + "</p><p>HP: " + hp + "</td></tr></table>";
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The oncoming horde overwhelms you...<button id='continuebutton' onclick='afterbattle()'>Continue</button></div>";
}
return false;
}
function defeatcheck() {
if (hp == 0) {
enemycount = 0;
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>GAME OVER.<button id='continuebutton' onclick='battle()'>Continue</button></div>";
document.getElementById("shipicon").innerHTML = "<img src='images/" + shipimg + "' width='150' alt='" + shipalt + "' /><p style='font-size: 15px;'>Ship: " + shipname + "</p><p style='font-size: 15px;'>HP: " + hp + "</p><p style='font-size: 15px;'>Bonus: Extra HP</p>";
document.getElementById("battlefield").innerHTML = "<h2>Battlefield</h2><table id='battlefieldbox'><tr><td><img src='images/Terran_Enemy.jpeg' width='150' alt='Enemy Terran spaceship' style='" + enemyshieldup + "'/><p>Terran</p><p>HP: " + enemyhp + "</p></td></tr><tr><td><img src='images/explosion.png' width='150' alt='explosion, you are dead'><p>" + shipname + "</p><p>HP: " + hp + "</td></tr></table>";
document.getElementById("turnmenu").innerHTML = "";
victory = false;
justkilledenemy = false;
hp = 50;
maxhp = 50;
bloodstar();
dmg;
shield = true;
shieldup;
charge = false;
ambossdodge = false;
enemycount = 5;
enemyhp = 50;
enemydmg;
enemyshield = false;
enemyshieldup;
enemycharge = false;
}
return false;
}
function battle() {
music.play();
if (justkilledenemy == true) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>NEW ENEMY!<button id='continuebutton' onclick='createbattlefield()'>Continue</button></div></div>";
justkilledenemy = false;
enemyshield = false;
enemycharge = false;
} else {
createbattlefield();
}
return false;
}
function afterbattle() {
music.pause();
sessionStorage.setItem("victoryyrdalgedal", "beaten");
if (dialoguecount == 0) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Keith T. Maxwell<img src='images/Keith_T_Maxwell.png' width='50' alt='Keith T Maxwell icon' style='margin-right: 20px; margin-left: 20px;'/>There are way too many of them! I can't win this!<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='nextroom()'>Skip</button></div>";
} else if (dialoguecount == 1) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Terran<img src='images/Terran.png' width='50' alt='a Terran icon' style='margin-right: 20px; margin-left: 20px;'/>Pirate! We have you surrounded! Surrender or we will open fire!<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='nextroom()'>Skip</button></div>";
} else if (dialoguecount == 2) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>Keith T. Maxwell<img src='images/Keith_T_Maxwell.png' width='50' alt='Keith T Maxwell icon' style='margin-right: 20px; margin-left: 20px;'/>Grr, I guess I have no choice. But how can I explain myself? They attacked me first, I had to fire back!<button id='continuebutton' onclick='continuebutton()'>Continue</button><button id='continuebutton' onclick='nextroom()'>Skip</button></div>";
} else if (dialoguecount == 3) {
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>The Narrator<img src='images/Narrator.png' width='60' alt='The narrator' style='margin-right: 20px; margin-left: 20px;'/>The Terran Federation surrounds our hero. They take him to a space station prison in a distant planet called Alioth...<button id='continuebutton' onclick='nextroom()'>Continue</button><button id='continuebutton' onclick='nextroom()'>Skip</button></div>";
}
return false;
}
function nextroom() {
sessionStorage.setItem("alioth", "alioth");
document.getElementById("mapbox").innerHTML = "<img src='images/Alioth.jpeg' width='60' alt='Alioth icon' style='margin-right: 20px; margin-left: 20px; '/><a href='alioth.html'>Alioth</a>";
document.getElementById("dialoguebox").innerHTML = "<div class='dialogue'>NEW MAP LOCATION UNLOCKED: Alioth</div>";
return false;
}
var shipname;
var shipimg;
var shipalt;
getship();
var victory = false;
var justkilledenemy = false;
var hp = 50;
var maxhp = 50;
bloodstar();
var dmg;
var shield = true;
var shieldup;
var charge = false;
var ambossdodge = false;
var enemycount = 5;
var enemyhp = 50;
var enemydmg;
var enemyshield = false;
var enemyshieldup;
var enemycharge = false;
</script>
</head>
<body>
<div class="box">
<h1>Yrdal Gedal</h1>
<p>A common hub for Terran traders around the galaxy, often attacked by pirates. Danger Level: High</p>
</div>
<div class="box">
<h2>Map</h2>
<p><img src='images/background.jpg' width='60' alt='Home page icon' style='margin-right: 20px; margin-left: 20px; '/><a href='index.html'>Home</a></p>
<p><img src='images/Deuter_V.jpeg' width='60' alt='Deuter V icon' style='margin-right: 20px; margin-left: 20px; '/><a href='deuterv.html'>Deuter V</a></p>
<p><img src='images/Yrdal_Gedal.jpeg' width='50' alt='Yrdal Gedal icon' style='margin-right: 20px; margin-left: 20px; '/><a href='yrdalgedal.html'>Yrdal Gedal</a><p>
<div id="mapbox"></div>
</div>
<div class="box">
<h2>Battle</h2>
<div id="displaybattle"></div>
<div id="battlefield"></div>
<div id="turnmenu"></div>
</div>
<div id="dialoguebox"></div>
<div id="shipicon"></div>
<div id="charactericon"></div>
<audio id="music" controls loop>
<source src="sound/Renegade_Justice.mp3" type="audio/mpeg">
</audio>
</body>
</html>
<script>
if (sessionStorage.getItem("alioth") != null) {
document.getElementById("mapbox").innerHTML = "<img src='images/Alioth.jpeg' width='60' alt='Alioth icon' style='margin-right: 20px; margin-left: 20px; '/><a href='alioth.html'>Alioth</a>";
}
document.getElementById("charactericon").innerHTML = "<img src='images/Keith_T_Maxwell.png' width='75' alt='Character icon of Keith T. Maxwell' /><p style='font-size: 10px;'>Name: Keith T. Maxwell</p><p style='font-size: 10px;'>Sex: Male</p><p style='font-size: 10px;'>Race: Terran</p>";
stats();
gamestart();
</script>