-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrick.js
executable file
·835 lines (653 loc) · 27.2 KB
/
trick.js
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
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
class Trick {
static objs = []
static get_html () {
let html = `<div class="actions-container">
`
Object.keys(Trick.objs).forEach((key) => {
html += Trick.objs[key].get_html()
})
html += `</div>`
return html
}
constructor (action_obj, legend_html, act_fn) {
this.name = action_obj.name
this.action_obj = action_obj
this.class = 'Trick'
this.legend_html = legend_html
this.act_fn = act_fn
action_obj.meta_obj = this
Trick.objs[action_obj.name] = this
}
get_html () {
const habilities_html = `<b>Habilities:</b> ` + (this.action_obj.habilities == null ? "None" : this.action_obj.habilities.join(', '))
const damage_types_html = `<b>Damage types:</b> ` + (this.damage_types ? this.damage_types.join(', ') : '')
const races_html = (this.action_obj.for_all ? "All" : (this.action_obj.char_races.length == 0 ? "All" : this.action_obj.char_races.join(', ')))
const classes_html = (this.action_obj.for_all ? "All" : this.action_obj.char_classes.length == 0 ? "All" : this.action_obj.char_classes.join(', '))
const for_all_html = (this.action_obj.for_all ? "Yes" : "No")
let html = `<div class="action-container">
<div class="action-name">${this.name}</div>
<div class="action-description">${this.action_obj.description}</div>
<div class="action-difficulty"><b>Difficulty:</b> ${this.action_obj.difficulty}</div>
<div class="action-habilities">${habilities_html}</div>
<div class="action-char-level"><b>Char level:</b> ${this.action_obj.char_level}</div>
<div class="action-char-classes"><b>Char races:</b> ${races_html}</div>
<div class="action-char-races"><b>Char classes:</b> ${classes_html}</div>
<div class="action-char-races"><b>For all:</b> ${for_all_html}</div>
</div>
`
return html
}
act (tricker_name, hability, targets_names, tricker_d20 /* no damage type */) {
return this.act_fn(this.name, tricker_name, hability, targets_names, tricker_d20)
}
}
new Trick(new Action("Jungle Sedative", "Adds Sedated status: who is sedated loses 1 point from all habilities at each turn, it lasts 3 turns, and after it ends, the points are recovered but they get the Sleeping status.", 13, ["Intelligence"], 1, [], ["Chimera"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) - TH >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>TH - Target Hability</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20) - (target_hability)
const test_result = test_result_value >= difficulty
// sets the proper result object with an object already containing the abbreviations
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) - ${target_hability} = ${test_result_value} >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
const status_name = 'Sedated'
const status_obj = {
name: status_name,
... Char.status_objs[status_name]
}
status_obj.toll = JSON.parse(JSON.stringify(status_obj.toll))
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(target_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(target_obj, status_obj, tricker_obj)}
target_obj.status.push(status_obj)
status_turn.push(status_obj)
})
return result
})
new Trick(new Action("Minor Healing", "Recovers health points. Heals (50 + TRH + D20) points.", 11, ["Intelligence"], 1, [], ["Witch", "Chimera"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<div><b>HEAL:</b> 50 + TRH + D20</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const test_result_value = (tricker_hability + tricker_d20)
const test_result = test_result_value >= difficulty
const heal_result = 50 + tricker_hability + tricker_d20
// sets the proper result object with an object already containing the abbreviations
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
` + (test_result ? `<div><b>HEAL:</b> 50 + ${tricker_hability} + ${tricker_d20} = <b>${heal_result}</b> </div>` : '')
if (!test_result) {
return
}
if (target_obj.health.current + heal_result > target_obj.health.base) {
target_obj.health.current = target_obj.health.base
}
else {
target_obj.health.current += heal_result
}
})
return result
})
new Trick(new Action("Conjurate Animal Spirit", "If successful, allows to try a second attack.", 13, ["Intelligence"], 1, [], ["Chimera"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const test_result_value = tricker_hability + tricker_d20
const test_result = test_result_value > difficulty
result[tricker_name] = `
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
return result
})
new Trick(new Action("Bless", "Adds Blessed status, adds 3 hability points for all hablities, lasts 3 rounds, upon 1 player.", 16, ["Intelligence", "Charisma"], 1, [], ["Witch"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20)
const test_result = test_result_value >= difficulty
// sets the proper result object
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Blessed'
const status_obj = {
name: status_name,
... Char.status_objs[status_name]
}
status_obj.toll = JSON.parse(JSON.stringify(status_obj.toll))
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(target_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(target_obj, status_obj, tricker_obj)}
target_obj.status.push(status_obj)
status_turn.push(status_obj)
// adds given points to all habilities
Object.keys(target_obj.stats_objs.current).forEach((key) => {
target_obj.stats_objs.current[key] += status_obj.points
status_obj.toll.stats[key] += status_obj.points
})
})
return result
})
new Trick(new Action("Curse", "Adds Cursed status: subtracts 3 hability points for all habilities, lasting 3 rounds, upon 1 player.", 16, ["Intelligence", "Charisma"], 1, [], ["Witch", "Circus Artist"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) - TH >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>TH - Target Hability</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20) - (target_hability)
const test_result = test_result_value >= difficulty
// sets the proper result object
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) - ${target_hability} >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Cursed'
const status_obj = {
name: status_name,
... Char.status_objs[status_name]
}
status_obj.toll = JSON.parse(JSON.stringify(status_obj.toll))
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(target_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(target_obj, status_obj, tricker_obj)}
target_obj.status.push(status_obj)
status_turn.push(status_obj)
// take points from all habilities
Object.keys(target_obj.stats_objs.current).forEach((key) => {
target_obj.stats_objs.current[key] -= status_obj.points
status_obj.toll.stats[key] -= status_obj.points
})
})
return result
})
new Trick(new Action("Alchemical Imobilization", "Adds Imobilized status: who gets imobilized status can't act for 1 turn.", 11, ["Intelligence", "Charisma"], 1, [], ["Alchemist"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20) - (target_hability)
const test_result = test_result_value >= difficulty
// sets the proper result object
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) - ${target_hability} >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Imobilized'
const status_obj = {
name: status_name,
...Char.status_objs[status_name]
}
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(target_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(target_obj, status_obj, tricker_obj)}
target_obj.status.push(status_obj)
status_turn.push(status_obj)
})
return result
})
new Trick(new Action("Frenesi", "The player is brought to an altered state of belic trance and gains hability points temporarily. Adds Frenesi status: the player gets 3 more points on all habilities once the action is done, and it lasts 3 turns.", 13, ["Strength"], 1, [], ["Fighter", "Chimera"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
const test_result_value = tricker_hability + tricker_d20
//console.log('test_result_value', test_result_value)
const test_result = test_result_value > difficulty
//console.log('test_result', test_result)
result[tricker_name] = `
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return result
}
// setup status
const status_name = 'Frenesi'
const status_obj = {
name: status_name,
... Char.status_objs[status_name]
}
status_obj.toll = JSON.parse(JSON.stringify(status_obj.toll))
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(tricker_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(tricker_obj, status_obj)}
tricker_obj.status.push(status_obj)
status_turn.push(status_obj)
// adds given points to all habilities
Object.keys(tricker_obj.stats_objs.current).forEach((key) => {
tricker_obj.stats_objs.current[key] += status_obj.points
status_obj.toll.stats[key] += status_obj.points
})
return result
})
new Trick(new Action("Mirrors and Smoke", "Allows the Circus Artist to Hide more easily.", 11, ["Dextrity", "Charisma"], 1, [], ["Circus Artist"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
const test_result_value = tricker_hability + tricker_d20
const test_result = test_result_value > difficulty
result[tricker_name] = `
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Hidden'
const status_obj = {
name: status_name,
...Char.status_objs[status_name]
}
tricker_obj.status.push(status_obj)
status_turn.push(status_obj)
return result
})
new Trick(new Action("Lullaby", "Sings or plays a lullaby, that calms down an enemy and avoids being hit by such enemy unless it's attacked by her. Adds Pacified status.", 13, ["Charisma"], 1, [], ["Circus Artist"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) - TAH >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>TAH - Target Hability</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20) - (target_hability)
const test_result = test_result_value >= difficulty
// sets the proper result object
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) - ${target_hability} >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Pacified'
const status_obj = {
name: status_name,
... Char.status_objs[status_name]
}
status_obj.char_name = tricker_name
target_obj.status.push(status_obj)
status_turn.push(status_obj)
})
return result
})
new Trick(new Action("Hypnosis", "Makes someone else obey a single command.", 16, ["Charisma"], 1, [], ["Circus Artist"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) - TAH >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>TAH - Target Hability</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20) - (target_hability)
const test_result = test_result_value >= difficulty
// sets the proper result object
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) - ${target_hability} >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Hypnotized'
const status_obj = {
name: status_name,
...Char.status_objs[status_name]
}
status_obj.char_name = tricker_name
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(tricker_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(tricker_obj, status_obj)}
target_obj.status.push(status_obj)
status_turn.push(status_obj)
})
return result
})
new Trick(new Action("Possession", "Adds Possessed status to the target, which is controlled by a supernatural entity for 2 turns.", 11, ["Intelligence", "Charisma"], 1, [], ["Messiah"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) - TAH >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>TAH - Target Hability</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20) - (target_hability)
const test_result = test_result_value >= difficulty
// sets the proper result object
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) - ${target_hability} >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Possessed'
const status_obj = {
name: status_name,
...Char.status_objs[status_name]
}
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(target_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(target_obj, status_obj, tricker_obj)}
target_obj.status.push(status_obj)
status_turn.push(status_obj)
})
return result
})
new Trick(new Action("Unstoppable Blade", "Allows the Swordsman to break the weapon of an enemy.", 13, ["Dextrity", "Agility"], 1, [], ["Swordsman"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
const test_result_value = tricker_hability + tricker_d20
const test_result = test_result_value > difficulty
result[tricker_name] = `
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
// setup status
const status_name = 'Unstoppable Blade'
const status_obj = {
name: status_name,
...Char.status_objs[status_name]
}
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(tricker_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(tricker_obj, status_obj)}
tricker_obj.status.push(status_obj)
status_turn.push(status_obj)
return result
})
new Trick(new Action("Cover Fire", "Gives cover fire to protect an ally for a turn. Lasts 1 turn.", 16, ["Dextrity"], 1, [], ["Shooter"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20)
const test_result = test_result_value >= difficulty
// sets the proper result object
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Covered'
const status_obj = {
name: status_name,
...Char.status_objs[status_name]
}
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(target_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(target_obj, status_obj, tricker_obj)}
target_obj.status.push(status_obj)
status_turn.push(status_obj)
// adds given points to all habilities
Object.keys(target_obj.stats_objs.current).forEach((key) => {
target_obj.stats_objs.current[key] += status_obj.points
})
})
return result
})
new Trick(new Action("Accurate Shot", "Guarantees that if the shooter misses an attack, she causes at least 50 points of damage to the enemy.", 16, ["Dextrity"], 1, [], ["Shooter"], false, false, 1), `
<div><b>TEST:</b> (TRH + D20) >= DIF</div>
<ul>
<li>TRH - Tricker Hability</li>
<li>D20 - Tricker D20</li>
<li>DIF - Difficulty</li>
</ul>
`, (action_name, tricker_name, hability, targets_names, tricker_d20) => {
const action_obj = Action.objs[action_name]
const tricker_obj = Char.objs[tricker_name]
const difficulty = action_obj.difficulty
const tricker_hability = tricker_obj.stats_objs.current[hability]
const action_level = tricker_obj.actions_obj.actions_levels[action_name]
const result = {}
const combat_name = CombatView.combat_selector.selectedOptions[0].innerText
const combat_obj = Combat.objs[combat_name]
const status_turn = tricker_obj.status_turns
targets_names.forEach((target_name) => {
const target_obj = Char.objs[target_name]
const target_hability = target_obj.stats_objs.current[hability]
const test_result_value = (tricker_hability + tricker_d20)
const test_result = test_result_value >= difficulty
// sets the proper result object
result[target_obj.name] = `
<div><b>${target_name}</b></div>
<div><b>TEST:</b> (${tricker_hability} + ${tricker_d20}) >= ${difficulty} -> <b>${test_result ? 'Passed' : 'Failed'}</b></div>
`
if (!test_result) {
return
}
// setup status
const status_name = 'Accurate Shot'
const status_obj = {
name: status_name,
...Char.status_objs[status_name]
}
const old_turn = status_obj.turn
status_obj.turn = (skip_duration) => {old_turn(target_obj, status_obj, skip_duration)}
status_obj.turn(true)
const old_end = status_obj.end
status_obj.end = () => {old_end(target_obj, status_obj, tricker_obj)}
target_obj.status.push(status_obj)
status_turn.push(status_obj)
})
return result
})