-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsim.js
More file actions
451 lines (406 loc) · 13.8 KB
/
sim.js
File metadata and controls
451 lines (406 loc) · 13.8 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
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
function onFileLoad(elementId, event) {
//SpoilerJSON = JSON.parse(event.target.result);
SpoilerLines = event.target.result.split('\n');
readLog();
}
function readLog() {
simActive = true;
document.getElementById("simLog").style.display = "inline-block";
document.getElementById("gossips_option").value = "ON";
var starting_mask = "";
for(i = 0; i < SpoilerLines.length; i++) {
if(SpoilerLines[i].indexOf("->") >= 0) {
loc = SpoilerLines[i].split("->")[0].trim();
item = SpoilerLines[i].split("->")[1].trim().replaceAll("*", "").replaceAll("^", "");
if(Locations.indexOf(loc) != -1) {
SpoilerLocToItem[loc] = item;
}
else if(Locations.indexOf("h_"+loc) != -1) {
SpoilerHintDict["h_"+loc] = item;
}
}
if(SpoilerLines[i].includes("200000--dfbfc-d800000-"))
starting_mask = "Deku Mask";
else if(SpoilerLines[i].includes("200000--dfbfc-da00000-"))
starting_mask = "Goron Mask";
else if(SpoilerLines[i].includes("200000--dfbfc-dc00000-"))
starting_mask = "Zora Mask";
else if(SpoilerLines[i].includes("200000--ffbfc-d800000-"))
starting_mask = "Fierce Deity's Mask";
}
if(document.getElementById("settings_option").value == "BLITZ" || document.getElementById("settings_option").value == "S3" || document.getElementById("settings_option").value == "S4" || document.getElementById("settings_option").value == "S5" || document.getElementById("settings_option").value == "EASTER" || document.getElementById("settings_option").value == "SCRUBS"){
SpoilerLocToItem["Starting Song"] = "Epona's Song";
document.getElementById("Starting Song").value = SpoilerItemToInput["Epona's Song"];
}
if(starting_mask != "") {
SpoilerLocToItem["Starting Item"] = starting_mask;
document.getElementById("Starting Item").value = SpoilerItemToInput[starting_mask];
}
}
function onChooseFile(event, onLoadFileHandler) {
if (typeof window.FileReader !== 'function')
throw ("The file API isn't supported on this browser.");
let input = event.target;
if (!input)
throw ("The browser does not properly implement the event object");
if (!input.files)
throw ("This browser does not support the `files` property of the file input.");
if (!input.files[0])
return undefined;
let file = input.files[0];
let fr = new FileReader();
fr.onload = onLoadFileHandler;
fr.readAsText(file);
}
function simProcessHint(gossip) {
hint = SpoilerHintDict[gossip];
for(var i = 0; i < hintStrings1.length; i++)
hint = hint.replace(hintStrings1[i], "");
if(hint.includes("Way of the Hero")) {
hint = hint.replace(" is on the Way of the Hero...", "");
if(simWothCounter <= 5) {
if(simWothsEntered[hint] == undefined)
simWothsEntered[hint] = 1;
else
simWothsEntered[hint] += 1;
if(simWothsEntered[hint] == 1) {
document.getElementById("woth_input" + simWothCounter).value = SpoilerAreaToInput[hint];
simWothCounter += 1;
}
}
}
else if(hint.includes("foolish choice")) {
hint = hint.replace(" is a foolish choice...", "");
if(simBarrenCounter <= 5) {
if(simBarrensEntered[hint] == undefined)
simBarrensEntered[hint] = 1;
else
simBarrensEntered[hint] += 1;
if(simBarrensEntered[hint] == 1) {
document.getElementById("barren_input" + simBarrenCounter).value = SpoilerAreaToInput[hint];
simBarrenCounter += 1;
}
}
}
else if(hint.includes("foolish except for its song")) {
hint = hint.replace(" is foolish except for its song...", "");
if(simBarrenCounter <= 5) {
if(simBarrensEntered[hint] == undefined)
simBarrensEntered[hint] = 1;
else
simBarrensEntered[hint] += 1;
if(simBarrensEntered[hint] == 1) {
document.getElementById("barren_input" + simBarrenCounter).value = "*"+SpoilerAreaToInput[hint];
simBarrenCounter += 1;
}
}
}
else { // always or sometimes hint
hint = hint.replaceAll(" not required", "");
hint = hint.replaceAll(" required", "");
if(hint.includes("Letter to Kafei Delivery")) {
for(var i = 0; i < hintStrings2.length; i++)
hint = hint.replace(hintStrings2[i], ":");
hint = hint.replace("...", "");
hint = hint.replaceAll(" then ", ":");
hint = hint.replaceAll(" then the ", ":");
let loc = hint.split(":")[0];
if(Locations.indexOf("Kafei") < 0) {
console.log("Could not fill in the hint. Kafei is not a known location.");
return;
}
if(hintIndexes.indexOf("Kafei") == -1) {
console.log("Could not fill in the hint. Kafei is not in the list of hinted locations.");
return;
}
for(var j = 1; j <=3; j++) {
let item = hint.split(":")[j];
if(item.startsWith("a "))
item = item.replace("a ", "");
if(item.startsWith("an "))
item = item.replace("an ", "");
if(item.startsWith("the "))
item = item.replace("the ", "");
let loc_input = "ka"+j;
let item_input = "x";
if(SpoilerItemToInput[item] != undefined)
item_input = SpoilerItemToInput[item];
if(document.getElementById("hintInput").value.includes(loc_input + " \n"))
document.getElementById("hintInput").value = document.getElementById("hintInput").value.replace(loc_input + " \n", loc_input + " " + item_input + "\n");
else if(!document.getElementById("hintInput").value.includes(loc_input + " " + item_input + "\n"))
document.getElementById("hintInput").value += loc_input + " " + item_input + "\n";
}
}
else if(hint.includes("Ranch Sisters Defense")) {
for(var i = 0; i < hintStrings2.length; i++)
hint = hint.replace(hintStrings2[i], ":");
hint = hint.replace("...", "");
hint = hint.replaceAll(" then ", ":");
hint = hint.replaceAll(" then the ", ":");
let loc = hint.split(":")[0];
if(Locations.indexOf("Aliens Defense") < 0) {
console.log("Could not fill in the hint. Aliens Defense is not a known location.");
return;
}
if(hintIndexes.indexOf("Aliens Defense") == -1) {
console.log("Could not fill in the hint. Aliens Defense is not in the list of hinted locations.");
return;
}
let loc_inputs = ["", "ali", "cre"]
for(var j = 1; j <=2; j++) {
let item = hint.split(":")[j];
if(item.startsWith("a "))
item = item.replace("a ", "");
if(item.startsWith("an "))
item = item.replace("an ", "");
if(item.startsWith("the "))
item = item.replace("the ", "");
let loc_input = loc_inputs[j];
let item_input = "x";
if(SpoilerItemToInput[item] != undefined)
item_input = SpoilerItemToInput[item];
if(document.getElementById("hintInput").value.includes(loc_input + " \n"))
document.getElementById("hintInput").value = document.getElementById("hintInput").value.replace(loc_input + " \n", loc_input + " " + item_input + "\n");
else if(!document.getElementById("hintInput").value.includes(loc_input + " " + item_input + "\n"))
document.getElementById("hintInput").value += loc_input + " " + item_input + "\n";
}
}
else if(hint.includes("Swamp Archery") && hint.includes("then")) {
for(var i = 0; i < hintStrings2.length; i++)
hint = hint.replace(hintStrings2[i], ":");
hint = hint.replace("...", "");
hint = hint.replaceAll(" then ", ":");
hint = hint.replaceAll(" then the ", ":");
let loc = hint.split(":")[0];
if(Locations.indexOf("Swamp Archery #1") < 0) {
console.log("Could not fill in the hint. Swamp Archery is not a known location.");
return;
}
if(hintIndexes.indexOf("Swamp Archery #1") == -1) {
console.log("Could not fill in the hint. Swamp Archery is not in the list of hinted locations.");
return;
}
let loc_inputs = ["", "sar", "sar2"]
for(var j = 1; j <=2; j++) {
let item = hint.split(":")[j];
if(item.startsWith("a "))
item = item.replace("a ", "");
if(item.startsWith("an "))
item = item.replace("an ", "");
if(item.startsWith("the "))
item = item.replace("the ", "");
let loc_input = loc_inputs[j];
let item_input = "x";
if(SpoilerItemToInput[item] != undefined)
item_input = SpoilerItemToInput[item];
if(document.getElementById("hintInput").value.includes(loc_input + " \n"))
document.getElementById("hintInput").value = document.getElementById("hintInput").value.replace(loc_input + " \n", loc_input + " " + item_input + "\n");
else if(!document.getElementById("hintInput").value.includes(loc_input + " " + item_input + "\n"))
document.getElementById("hintInput").value += loc_input + " " + item_input + "\n";
}
}
else {
for(var i = 0; i < hintStrings2.length; i++)
hint = hint.replace(hintStrings2[i], ":");
hint = hint.replace("...", "");
hint = hint.replace("Town Archery 1", "Town Archery #1");
hint = hint.replace("Swamp Archery 1", "Swamp Archery #1");
hint = hint.replace("Swamp Archery 2", "Swamp Archery #2");
hint = hint.replace("Bank Reward 3", "Bank Reward #3");
hint = hint.replace("Beaver Race 1", "Beaver Race #1");
let loc = hint.split(":")[0];
let item = hint.split(":")[1];
if(item.startsWith("a "))
item = item.replace("a ", "");
if(item.startsWith("an "))
item = item.replace("an ", "");
if(item.startsWith("the "))
item = item.replace("the ", "");
if(Locations.indexOf(loc) < 0) {
console.log("Could not fill in the hint. " + loc + " is not a known location.");
return;
}
if(hintIndexes.indexOf(loc) == -1) {
console.log("Could not fill in the hint. " + loc + " is not in the list of hinted locations.");
return;
}
let loc_input = hintInputs[hintIndexes.indexOf(loc)];
let item_input = "x";
if(SpoilerItemToInput[item] != undefined)
item_input = SpoilerItemToInput[item];
if(document.getElementById("hintInput").value.includes(loc_input + " \n"))
document.getElementById("hintInput").value = document.getElementById("hintInput").value.replace(loc_input + " \n", loc_input + " " + item_input + "\n");
else if(!document.getElementById("hintInput").value.includes(loc_input + " " + item_input + "\n"))
document.getElementById("hintInput").value += loc_input + " " + item_input + "\n";
}
}
}
var SpoilerItemToInput = {
"Bow Upgrade" : "bow",
"Fire Arrow" : "fir",
"Ice Arrow" : "ice",
"Light Arrow" : "lig",
"Moon's Tear" : "moo",
"Land Title Deed" : "lan",
"Swamp Title Deed" : "swa",
"Mountain Title Deed" : "mou",
"Ocean Title Deed" : "oce",
"Bomb Bag Upgrade" : "bom",
"Magic Bean" : "bea",
"Room Key" : "roo",
"Letter to Mama" : "spe",
"Powder Keg" : "pow",
"Pictograph Box" : "pic",
"Lens of Truth" : "len",
"Hookshot" : "hoo",
"Great Fairy's Sword" : "gfs",
"Letter to Kafei" : "let",
"Pendant of Memories" : "pen",
"Empty Bottle" : "bot",
"Bottle of Red Potion" : "bot",
"Bottle of Chateau Romani" : "bot",
"Milk Bottle" : "bot",
"Bottle of Gold Dust" : "gol",
"Postman's Hat" : "pos",
"All-Night Mask" : "all",
"Blast Mask" : "bla",
"Stone Mask" : "sto",
"Great Fairy's Mask" : "gre",
"Deku Mask" : "dek",
"Keaton Mask" : "kea",
"Bremen Mask" : "bre",
"Bunny Hood" : "bun",
"Don Gero's Mask" : "don",
"Mask of Scents" : "sce",
"Goron Mask" : "gor",
"Romani's Mask" : "rom",
"Circus Leader's Mask" : "cir",
"Kafei's Mask" : "kaf",
"Couple's Mask" : "cou",
"Mask of Truth" : "tru",
"Zora Mask" : "zor",
"Kamaro's Mask" : "kam",
"Gibdo Mask" : "gib",
"Garo's Mask" : "gar",
"Captain's Hat" : "cap",
"Giant's Mask" : "gia",
"Fierce Deity's Mask" : "fie",
"Sword Upgrade" : "swo",
"Mirror Shield" : "mir",
"Magic Power Upgrade" : "mag",
"Wallet Upgrade" : "wal",
"Song of Healing" : "soh",
"Epona's Song" : "epo",
"Song of Storms" : "sos",
"Sonata of Awakening" : "son",
"Goron Lullaby" : "lul",
"Goron Lullaby Upgrade" : "lul",
"New Wave Bossa Nova" : "nov",
"Elegy of Emptiness" : "ele",
"Oath to Order" : "oat"
}
var SmallGildedItems = [
"Moon's Tear",
"Land Title Deed",
"Swamp Title Deed",
"Mountain Title Deed",
"Ocean Title Deed",
"Magic Bean",
"Room Key",
"Letter to Mama",
"Letter to Kafei",
"Pendant of Memories"
];
var LargeGildedItems = [
"Bow Upgrade",
"Fire Arrow",
"Ice Arrow",
"Light Arrow",
"Bomb Bag Upgrade",
"Powder Keg",
"Pictograph Box",
"Lens of Truth",
"Hookshot",
"Great Fairy's Sword",
"Empty Bottle",
"Bottle of Red Potion",
"Bottle of Chateau Romani",
"Milk Bottle",
"Bottle of Gold Dust",
"Postman's Hat",
"All-Night Mask",
"Blast Mask",
"Stone Mask",
"Great Fairy's Mask",
"Deku Mask",
"Keaton Mask",
"Bremen Mask",
"Bunny Hood",
"Don Gero's Mask",
"Mask of Scents",
"Goron Mask",
"Romani's Mask",
"Circus Leader's Mask",
"Kafei's Mask",
"Couple's Mask",
"Mask of Truth",
"Zora Mask",
"Kamaro's Mask",
"Gibdo Mask",
"Garo's Mask",
"Captain's Hat",
"Giant's Mask",
"Fierce Deity's Mask",
"Sword Upgrade",
"Mirror Shield",
"Magic Power Upgrade",
"Wallet Upgrade",
"Heart Container",
"Bombers' Notebook",
"Spin Attack Mastery",
"Double Defense"
];
var LargeGildedJunkItems = [
"Heart Container",
"Bombers' Notebook",
"Spin Attack Mastery",
"Double Defense"
];
var SpoilerAreaToInput = {
"Clock Tower Rooftop" : "clo",
"South Clock Town" : "sct",
"North Clock Town" : "nct",
"West Clock Town" : "wct",
"Laundry Pool" : "lau",
"East Clock Town" : "ect",
"Stock Pot Inn" : "inn",
"Termina Field" : "fie",
"Road to Southern Swamp" : "rsw",
"Southern Swamp" : "swa",
"Deku Palace" : "pal",
"Woodfall" : "woo",
"Milk Road" : "mil",
"Romani Ranch" : "ran",
"Mountain Village" : "mou",
"Twin Islands" : "twi",
"Goron Village" : "gor",
"Path to Snowhead" : "psn",
"Great Bay Coast" : "gre",
"Zora Cape" : "cap",
"Zora Hall" : "hal",
"Pirates' Fortress Exterior" : "ext",
"Pirates' Fortress Sewer" : "sew",
"Pirates' Fortress Interior" : "int",
"Pinnacle Rock" : "pin",
"Road to Ikana" : "rik",
"Ikana Graveyard" : "gra",
"Ikana Canyon" : "can",
"Secret Shrine" : "shr",
"Beneath the Well" : "wel",
"Ikana Castle" : "cas",
"Stone Tower" : "sto",
"Woodfall Temple" : "wft",
"Snowhead Temple" : "sht",
"Great Bay Temple" : "gbt",
"Stone Tower Temple" : "stt"
}