-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHWHAdvPathExt.user.js
More file actions
445 lines (419 loc) · 24.1 KB
/
Copy pathHWHAdvPathExt.user.js
File metadata and controls
445 lines (419 loc) · 24.1 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
// ==UserScript==
// @name HWHAdvPathExt
// @name:en HWHAdvPathExt
// @name:ru HWHAdvPathExt
// @namespace HWHAdvPathExt
// @version 0.0.20.6
// @description Extension for HeroWarsHelper script - Modifies the adventure button to use predefined paths directly within the script, allowing modification before starting.
// @description:en Extension for HeroWarsHelper script
// @description:ru Расширение для скрипта HeroWarsHelper
// @author ZingerY & CR3 Cappu Red + Pizza Clan + Sniper677 (Modified by AI)
// @license Copyright ZingerY & orb
// @homepage https://github.com/Sniper677/HWH_Addon_Scripts
// @icon https://cdn0.iconfinder.com/data/icons/superheros-1/512/Superheroes-04-512.png
// @match https://www.hero-wars.com/*
// @match https://www.hero-wars.cn/*
// @match https://apps-1701433570146040.apps.fbsbx.com/*
// @run-at document-start
// @grant none
// @downloadURL https://github.com/Sniper677/HWH_Addon_Scripts/raw/refs/heads/main//HWHAdvPathExt.user.js
// @updateURL https://github.com/Sniper677/HWH_Addon_Scripts/raw/refs/heads/main//HWHAdvPathExt.meta.js
// ==/UserScript==
(function () {
if (!this.HWHClasses) {
console.log('%cObject for extension not found', 'color: red');
return;
}
console.log('%cStart Extension ' + GM_info.script.name + ', v' + GM_info.script.version + ' by ' + GM_info.script.author, 'color: green');
// --- START - NEW STYLE FEATURE ---
function injectCustomStyles() {
const style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = `
.PopUp_Container:has(.HWHAPE-SelectPath-UI) {
/* Defines max-width of 1st 'Select Path' popup */
/* It breaks up the path input box and the cancel button */
max-width: 530px;
}
.PopUp_Container:has(.HWHAPE-SelectPath-UI) .PopUp_buttonText {
white-space: normal !important; /* Allows the text to wrap to the next line */
word-break: break-all !important; /* Forces long strings like paths to break */
text-align: left !important; /* Aligns the wrapped text to the left for readability */
line-height: 1.2 !important; /* Adds some space between wrapped lines */
}
.PopUp_Container:has(.HWHAPE-SelectPath-UI) .HWHAPE-PathButton {
/* Sets fixed width for the path buttons in 1st popup */
width: 470px;
}
.PopUp_Container:has(.HWHAPE-ReviewPath-UI) {
/* Defines max-width of 2nd 'Review Path' popup */
max-width: 480px;
}
`;
document.head.appendChild(style);
console.log('%c' + GM_info.script.name + ': Scoped styles injected.', 'color: cyan');
}
// --- END - NEW STYLE FEATURE ---
injectCustomStyles();
const { addExtentionName, getSaveVal, I18N, popup, setSaveVal } = HWHFuncs;
addExtentionName(GM_info.script.name, GM_info.script.version, GM_info.script.author);
// This object now contains separate keys for 'adventure' and 'storm' paths.
const defaultWays = {
adventure: {
//Galahad, adv #1 -> DONE
"adv_strongford_2pl_easy": {
/* Solfors paths */
blue: { path: '01,02,03,05,06(2xB)', label: 'Sol_A' },
orange: { path: '01,02,04,07,06(2xB)', label: 'Sol_B' },
green: { path: '', label: '3 Sol_C' },
/* Goodwin paths */
yellow: { path: '', label: 'Gdwn_A' },
purple: { path: '', label: 'Gdwn_B' },
red: { path: '', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Ginger, adv #2 -> DONE
"adv_valley_3pl_easy": {
/* Solfors paths */
blue: { path: '01,02,05,08,09,11(B)', label: 'Sol_A' },
orange: { path: '01,03,06,09,11(2xB)', label: 'Sol_B' },
green: { path: '01,04,07,10,09,11(B)', label: 'Sol_C' },
/* Goodwin paths */
yellow: { path: '', label: 'Gdwn_A' },
purple: { path: '', label: 'Gdwn_B' },
red: { path: '', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '01,02,05,08,09,06', label: 'NoWait_1' },
black: { path: '01,04,07,10,09,11(B)', label: 'NoWait_2' },
brown: { path: '01,03,06,09,11(2xB)', label: 'NoWait_3' }
},
//Orion, adv #3 -> DONE
"adv_ghirwil_3pl_easy": {
/* Solfors paths */
blue: { path: '01,04,12,13,08', label: 'Sol_A' },
orange: { path: '01,05,06,09,11(2xB)', label: 'Sol_B' },
green: { path: '01,02,03,07,10,11(B)', label: 'Sol_C' },
/* Goodwin paths */
yellow: { path: '', label: 'Gdwn_A' },
purple: { path: '', label: 'Gdwn_B' },
red: { path: '', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '01,04,12,13,08', label: 'NoWait_1' },
black: { path: '01,05,06,07,10,11(B)', label: 'NoWait_2' },
brown: { path: '01,02,03,07,06,09', label: 'NoWait_3' }
},
//Cleaver, adv #4 -> DONE
"adv_angels_3pl_easy_fire": {
/* Solfors paths */
blue: { path: '01,02,04,07,18,08,12,19,22,23(2xB)', label: 'Sol_A' },
orange: { path: '01,05,24,25,09,14,15,20,22,23(2xB)', label: 'Sol_B' },
green: { path: '01,03,06,11,17,10,16,21,22,23(2xB)', label: 'Sol_C' },
/* Goodwin paths */
yellow: { path: '', label: 'Gdwn_A' },
purple: { path: '', label: 'Gdwn_B' },
red: { path: '', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Galahad, adv #5 -> DONE
"adv_strongford_3pl_normal_2": {
/* Solfors paths */
blue: { path: '01,05,09,10,14,17,20,27,25,21,24(B)', label: 'Sol_A' },
orange: { path: '01,04,06,10,11,15,19,18,24(3xB)', label: 'Sol_B' },
green: { path: '01,02,07,08,12,16,23,26,25,22', label: 'Sol_C' },
/* Goodwin paths */
yellow: { path: '', label: 'Gdwn_A' },
purple: { path: '', label: 'Gdwn_B' },
red: { path: '', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Ginger, adv #6 -> DONE
"adv_valley_3pl_normal": {
/* Solfors paths */
blue: { path: '01,02,04,07,10,13,16,19,24,22,25(B)', label: 'Sol_A' },
orange: { path: '01,05,07,08,11,14,17,20,23,25(B)', label: 'Sol_B' },
green: { path: '01,03,06,09,12,15,18,21,26,25(B)', label: 'Sol_C' },
/* Goodwin paths */
yellow: { path: '01,02,04,07,10,13,16,19,24,22,25(B)', label: 'Gdwn_A' },
purple: { path: '01,03,06,09,12,15,18,21,26,23,25(B)', label: 'Gdwn_B' },
red: { path: '01,05,07,08,11,14,17,20,22,25(B)', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Orion, adv #7 -> DONE
"adv_ghirwil_3pl_normal_2": {
/* Solfors paths */
blue: { path: '01,08,01,11,12,15,12,11,21,25,27(B)', label: 'Sol_A' },
orange: { path: '01,11,10,14,17,13,19,20,24,27(2xB)', label: 'Sol_B' },
green: { path: '01,07,03,04,05,09,16,23,22,26,27(B)', label: 'Sol_C' },
/* Goodwin paths */
yellow: { path: '01,11,10,11,12,15,12,11,21,25,27(B)', label: 'Gdwn_A' },
purple: { path: '01,07,03,04,03,06,13,19,20,24,27(B)', label: 'Gdwn_B' },
red: { path: '', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '01,07,01,11,10,14,17,13,19,20,24', label: 'NoWait_1' },
black: { path: '01,08,01,11,21,25,27(B),26,22,23,16', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Cleaver, adv #8 -> DONE
"adv_angels_3pl_normal": {
/* Solfors paths */
blue: { path: '01,03,02,06,07,09,10,13,17,16,20,22,21,28,32(2xB)', label: 'Sol_2' },
orange: { path: '01,03,05,07,09,11,14,18,20,22,24,27,30,26,29,25', label: 'Sol_1' },
green: { path: '01,03,04,08,07,09,11,15,19,20,22,23,31,32(3xB)', label: 'Sol_3' },
/* Goodwin paths */
yellow: { path: '01,03,04,08,07,09,10,13,17,16,20,22,23,31,32(2xB)', label: 'Gdwn_A' },
purple: { path: '01,03,05,07,09,11,14,18,20,22,24,27,30,26,32(2xB)', label: 'Gdwn_B' },
red: { path: '01,03,02,06,07,09,11,15,19,20,22,21,28,29,25', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Galahad, adv #9 -> DONE
"adv_strongford_3pl_hard_2": {
/* Sol_paths */
blue: { path: '01,02,06,10,15,20,14,24,29,25,36,39,42,44,45(2xB)', label: 'Sol_2-3' },
orange: { path: '01,03,08,12,11,07,16,21,26,30,31,32,35,37,40,45(B)', label: 'Sol_1-x' },
green: { path: '01,03,04,13,19,18,23,17,22,38,41,43,46,45(2xB)', label: 'Sol_3-2' },
/* Goodwin paths */
yellow: { path: '01,02,06,10,15,07,16,17,23,22,27,32,35,37,40,45(B)', label: 'Gdwn_A' },
purple: { path: '01,03,08,12,11,18,19,28,34,33,38,41,43,46,45(2xB)', label: 'Gdwn_B' },
red: { path: '01,02,05,09,14,20,26,21,30,36,39,42,44,45(3xB)', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Ginger, adv #10 -> DONE
"adv_valley_3pl_hard": {
/* Solfors paths */
blue: { path: '01,03,02,06,11,17,25,30,35,34,29,24,21,17,12,07', label: 'Sol_3' },
orange: { path: '01,04,08,13,18,22,26,31,36,40,45,44,43,38,33,28', label: 'Sol_1' },
green: { path: '01,05,09,14,19,23,27,32,37,42,48,51,50,49,46,52(B)', label: 'Sol_2' },
/* Goodwin paths */
yellow: { path: '', label: 'Gdwn_A' },
purple: { path: '', label: 'Gdwn_B' },
red: { path: '', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Orion, adv #11 -> DONE
"adv_ghirwil_3pl_hard": {
/* Solfors paths */
blue: { path: '01,02,03,06,07,12,11,15,21,27,36,39,40,41,37(2xB)', label: 'Sol_2-1' },
orange: { path: '01,02,04,06,08,12,17,18,19,25,31,30,29,28,22,16', label: 'Sol_1-x' },
green: { path: '01,02,05,06,09,13,14,20,26,32,38,35,33,34,37(2xB)', label: 'Sol_3-1' },
/* Goodwin paths */
yellow: { path: '01,02,04,06,09,13,18,17,16,22,28,29,30,31,25,19', label: 'Gdwn_A' },
purple: { path: '01,02,03,06,08,12,11,15,21,27,36,34,33,35,37(2xB)', label: 'Gdwn_B' },
red: { path: '01,02,05,06,10,13,14,20,26,32,38,41,40,39,37(2xB)', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Cleaver, adv #12
"adv_angels_3pl_hard": {
/* Solfors paths */
blue: { path: '01,09,03,06,10,22,31,36,35,29,34,29,30,21,13', label: 'Sol_2-3' },
orange: { path: '01,05,12,15,28,20,12,14,26,18,19,20,27(B)', label: 'Sol_3-1+2' },
green: { path: '01,08,02,04,07,16,23,32,33,25,24,17,11', label: 'Sol_1-3' },
/* Goodwin paths */
yellow: { path: '01,02,08,11,07,04,07,16,23,32,33,25,34,29,35,36', label: 'Gdwn_1-x' },
purple: { path: '01,03,09,13,10,06,10,22,31,30,21,30,15,28,20,27(B)', label: 'Gdwn_2-3' },
red: { path: '01,05,12,14,24,17,24,25,26,18,19,20,27', label: 'Gdwn_2-x' },
/* NoWait paths */
white: { path: '01,08,02,04,07,16,23,32,23,24,14,26,25,24,17,11', label: '1 NoWait_1' },
black: { path: '01,09,01,05,12,15,28,29,34,25,26,18,19,20,27(B)', label: '2 NoWait_2' },
brown: { path: '01,03,06,10,22,31,36,31,30,21,13', label: '3 NoWait_3' }
},
//Galahad, adv #13 - map #9 (probably hard or higher) -> DONE
"adv_strongford_3pl_hell": {
/* Solfors paths */
blue: { path: '01,02,06,12,15,20,14,24,29,25,35,38,41,43,44(B)', label: 'Sol_2-1' },
orange: { path: '01,03,08,09,13,07,16,21,26,30,31,42,34,36,39', label: 'Sol_1-2' },
green: { path: '01,03,04,10,19,18,23,17,22,37,40,32,45,44(B)', label: 'Sol_3-1' },
/* Goodwin paths */
yellow: { path: '01,02,05,11,14,20,26,21,30,35,38,41,43,44(B)', label: 'Gdwn_2-1' },
purple: { path: '01,02,06,12,15,07,16,17,23,22,27,42,34,36,39', label: 'Gdwn_1-x' },
red: { path: '01,03,08,09,13,18,19,28,00,33,37,40,32,45,44(B)', label: 'Gdwn_3-1' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Ginger, adv #13 - map #10 (probably hard or highere) -> DONE
"adv_valley_3pl_hell": {
/* Solfors paths */
blue: { path: '01,03,02,06,11,17,25,30,35,34,29,24,21,17,12,07', label: 'Sol_1-x' },
orange: { path: '01,04,08,13,18,22,26,31,36,40,45,44,43,38,33,28', label: 'Sol_2-1' },
green: { path: '01,05,09,14,19,23,27,32,37,42,48,51,50,49,46,52(B)', label: 'Sol_3-x' },
/* Goodwin paths */
yellow: { path: '', label: 'Gdwn_A' },
purple: { path: '', label: 'Gdwn_B' },
red: { path: '', label: 'Gdwn_C' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Orion, adv #13 - map #11 (probably hard or higher) -> DONE
"adv_ghirwil_3pl_hell": {
/* Solfors paths */
blue: { path: '01,02,03,06,07,12,11,15,21,27,36,39,40,41', label: 'Sol_2-3' },
orange: { path: '01,02,04,06,08,12,17,18,19,25,31,30,29,28,22,16', label: 'Sol_1-x' },
green: { path: '01,02,05,06,09,13,14,20,26,32,38,35,33,34', label: 'Sol_3-2' },
/* Goodwin paths */
yellow: { path: '01,02,03,06,08,12,11,15,21,27,36,34,33,35,37', label: 'Gdwn_2-3' },
purple: { path: '01,02,04,06,09,13,18,17,16,22,28,29,30,31,25,19', label: 'Gdwn_1-x' },
red: { path: '01,02,05,06,10,13,14,20,26,32,38,41,40,39,37', label: 'Gdwn_3-2' },
/* NoWait paths */
white: { path: '', label: 'NoWait_1' },
black: { path: '', label: 'NoWait_2' },
brown: { path: '', label: 'NoWait_3' }
},
//Cleaver, adv #13 - map #12 (probably hard or higher)
"adv_angels_3pl_hell": {
/* Solfors paths */
blue: { path: '01,09,03,05,10,22,31,36,35,29,32,29,30,21,13', label: 'Sol_2' },
orange: { path: '01,08,12,15,28,20,12,14,26,18,19,20,27(B)', label: 'Sol_3' },
green: { path: '01,07,02,04,06,16,23,33,34,25,24,17,11', label: 'Sol_1' },
/* Goodwin paths */
yellow: { path: '01,02,04,06,16,23,33,34,25,32,29,28,20,27(B)', label: 'Gdwn_2' },
purple: { path: '01,07,11,17,24,14,26,18,19,20,27,20,12,8', label: 'Gdwn_1' },
red: { path: '01,09,03,05,10,22,31,36,31,30,15,28,29,30,21,13', label: 'Gdwn_3' },
/* NoWait paths */
white: { path: '01,07,02,04,06,16,23,33,23,24,14,26,25,24,17,11', label: '1 NoWait_1' },
black: { path: '01,09,01,08,12,15,28,29,32,25,26,18,19,20,27(B)', label: '2 NoWait_2' },
brown: { path: '01,09,03,05,10,22,31,36,35,29,32,29,30,21,13', label: '3 NoWait_3' }
}
},
storm: {
"tempest_3_3": {
blue: { path: '01,02,03,04,05,56,55,53,50,49,48,45,46,43,41,39,38,40,36,35,33,31,29,28,27,25,26,22,21,20,17,18,15,13,10,09,11,07,08', label: 'Path 1 - left' },
orange: { path: '01,02,05,04,03,07,09,10,13,11,15,17,20,21,18,22,25,27,28,26,29,31,33,35,36,38,39,41,40,43,45,48,49,46,50,53,55,56,54,52,06,08', label: 'Path 2 - right' },
green: { path: '01,02,05,04,03,07,09,10,13,11,15,17,20,21,18,22,25,27,28,26,29,31,33,35,36,38,39,41,40,43,45,48,49,46,50,53,55,56,54,51,47,44,42,37,32,30,24,23,19,16,14,12,08,06,52,57', label: 'Path 3 (Full Clearance)' },
black: { path: '08,12,14,16,19,23,24,30,32,37,42,44,47,51,52(B)', label: 'Inner 1 - right' },
white: { path: '08,06,52,51,47,44,42,37,32,30,24,23,19,16,14,12', label: 'Inner 2 - left' },
}
}
};
const originalExecuteAdventure = HWHClasses.executeAdventure;
class ExtCombinedAdventureStorm extends originalExecuteAdventure {
async getPath() {
console.log(`Current adventure type: ${this.type}, Map Identifier: ${this.mapIdent}`);
const adventureTypeKey = this.type === 'solo' ? 'storm' : 'adventure';
const currentAdventureWays = defaultWays[adventureTypeKey] ? defaultWays[adventureTypeKey][this.mapIdent] : undefined;
const oldVal = getSaveVal('HWHAPE_AdvPath', '');
const keyPath = `HWHAPE_AdvPath:${this.mapIdent}`;
// We need a way to reference the input field later.
let inputFieldRef = {};
const popupButtons = [
{
msg: I18N('START_ADVENTURE'),
placeholder: 'click on a path or enter your own path',
isInput: true,
default: getSaveVal(keyPath, oldVal),
result: 'input_value',
// This is a custom property to hold a reference to the input element
inputRef: inputFieldRef
},
{
msg: I18N('BTN_CANCEL'),
result: false,
isCancel: true
}
];
// Note: The popup implementation in HwH needs to assign the input element to `button.inputRef.current`
// Since we cannot modify HwH's popup, we will retrieve the final input value in a different way.
const colorEmojis = {
blue: '🔵', orange: '🟠', green: '🟢',
yellow: '🟡', purple: '🟣', red: '🔴',
white: '⚪', black: '⚫', brown: '🟤'
};
if (currentAdventureWays) {
const orderedColors = ['blue', 'orange', 'green', 'yellow', 'purple', 'red', 'white', 'black', 'brown'];
orderedColors.forEach((color) => {
const pathData = currentAdventureWays[color];
if (pathData && pathData.path) {
let buttonLabel = '<div class="HWHAPE-PathButton">';
buttonLabel += `${colorEmojis[color] || '⚪'} ${pathData.label} | ${pathData.path}`;
buttonLabel += '</div>'
popupButtons.unshift({
msg: buttonLabel,
result: pathData.path,
isPathButton: true
});
}
});
} else {
console.log(`%cNo predefined paths for ${adventureTypeKey} map: ${this.mapIdent}`, 'color: yellow');
}
// Wrap the title in a unique class to identify this specific popup in CSS
//let answer = await popup.confirm('Choose or Enter a Path', popupButtons);
let answer = await popup.confirm('<div class="HWHAPE-SelectPath-UI">Select or Custom Path</div>', popupButtons);
if (typeof answer === 'string' && answer.length > 0 && answer !== 'input_value') {
const newPopupButtons = [
{
msg: I18N('START_ADVENTURE'),
placeholder: 'click on a path or enter your own path',
isInput: true,
default: answer,
result: 'input_value'
},
{
msg: I18N('BTN_CANCEL'),
result: false,
isCancel: true
}
];
answer = await popup.confirm('<div class="HWHAPE-ReviewPath-UI">Review and Confirm the Path</div>', newPopupButtons);
}
// This is the key change: When the user confirms, the popup implementation in HwH returns the input value.
// If the user cancels, it returns false.
if (answer === 'input_value') {
// The HwH popup returns the input string, not 'input_value' when confirmed.
// This part of the logic from the previous script might be based on a misunderstanding of the popup's return.
// Let's assume the popup returns the final string directly.
// The check `!answer` will handle the cancel case.
} else if (!answer) {
this.terminatеReason = I18N('BTN_CANCELED');
return false;
}
// Remove brackets, text inside them, and all whitespace from the answer
answer = answer.replace(/\(.*?\)/g, '').replace(/\s+/g, '');
let path = answer.split(',');
if (path.length < 2) path = answer.split('-');
if (path.length < 2) {
this.terminatеReason = I18N('MUST_TWO_POINTS');
return false;
}
for (let p in path) {
path[p] = +path[p].trim();
if (Number.isNaN(path[p])) {
this.terminatеReason = I18N('MUST_ONLY_NUMBERS');
return false;
}
}
if (!this.checkPath(path)) {
return false;
}
setSaveVal(keyPath, answer);
return path;
}
}
HWHClasses.executeAdventure = ExtCombinedAdventureStorm;
})();