-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuff_processor.js
More file actions
executable file
·5248 lines (4863 loc) · 241 KB
/
buff_processor.js
File metadata and controls
executable file
·5248 lines (4863 loc) · 241 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
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
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var client_local = require('./data_tier_client.js');
var fs = require('fs');
client_local.setAddress("http://127.0.0.1:8081"); //default client setup
var BuffProcessor = function (unit_names, item_names, options) {
let no_buff_data_msg = "Message length is 0";
options = options || {};
unit_names = unit_names || {};
item_names = item_names || {};
let client = options.client || client_local;
function debug_log() {
if (options.verbose) {
console.log(...arguments);
}
}
function initializeNames(){
function setNameArrays() {
console.log("Getting new names.json");
let units = client.searchUnit({ name_id: "" });
let items = client.searchItem({ name_id: "" });
return Promise.all([units, items])
.then(function (results) {
let unitIDs = results[0];
let itemIDs = results[1];
let promises = [];
let itemCount = 0, unitCount = 0;
for (let unit of unitIDs) {
let curUnitPromise = client.getUnit(unit).then(function (unitResult) {
unit_names[unitResult.id.toString()] = (unitResult.translated_name || unitResult.name) + ` (${unitResult.id})`;
return;
});
promises.push(curUnitPromise);
}
for (let item of itemIDs) {
let curItemPromise = client.getItem(item).then(function (itemResult) {
item_names[itemResult.id.toString()] = (itemResult.translated_name || itemResult.name) + ` (${itemResult.id})`;
return;
});
promises.push(curItemPromise);
}
return Promise.all(promises);
}).then(function () {
let names = {
unit: unit_names,
item: item_names
};
fs.writeFileSync('./names.json', JSON.stringify(names), 'utf8');
console.log("Wrote names.json");
});
}
let loadPromise;
try {
if (fs.existsSync('./names.json')) {
let names = JSON.parse(fs.readFileSync('./names.json'));
unit_names = names.unit;
item_names = names.item;
loadPromise = Promise.resolve();
} else {
throw "No names.json found";
}
} catch (err) {
loadPromise = setNameArrays();
}
return loadPromise;
}
this.initializeNames = initializeNames;
//helper functions
function print_effect_legacy(effects) {
var print_array = function (arr) {
var text = "[";
for (var i in arr) {
if (arr[i] instanceof Array) text += print_array(arr[i]);
else if (arr[i] instanceof Object) text += JSON.stringify(arr[i]); //most likely a JSON object
else text += arr[i];
text += ",";
}
if (text.length > 1) {
text = text.substring(0, text.length - 1); //remove last comma
}
text += "]";
return text;
}
var text_arr = [];
//convert each effect into its own string
for (var param in effects) {
if (param !== "passive id" && param !== "effect delay time(ms)\/frame") {
var tempText = effects[param];
if (effects[param] instanceof Array) tempText = print_array(effects[param]); //parse array
else if (effects[param] instanceof Object) tempText = JSON.stringify(effects[param]); //parse JSON object
text_arr.push("" + param + ": " + tempText);
}
}
//convert array into a single string
var i = 0;
var text = "";
for (i = 0; i < text_arr.length; ++i) {
text += text_arr[i];
if (i + 1 != text_arr.length) text += " / ";
}
return text + "";
}
function to_proper_case(input) {
return `${input[0].toUpperCase()}${input.slice(1).toLowerCase()}`;
}
function get_polarized_number(number) {
if (number < 0) return number.toString();
else return "+" + number.toString();
}
function get_formatted_minmax(min, max) {
if (min !== max) {
if (max > 0) return min + "-" + max;
else return min + " to " + max;
}
else return min || max;
}
function multi_param_buff_handler(options) {
/*
options = {
all: array of objects with keys values and name; e.g. {value:50, name: "ATK"}
values: array of values, can contain indices of undefined
names: array of names for each value
special_case: {
isSpecialCase(value,names_array): given a value or names_array, return a bool for if params are a special case
func(value,names_array): handle the special case and return a string
}
prefix(names_arr) || prefix: if function, return a formatted string for a given array of names
if string, then this will be inserted before every value listing
numberFn(number): special function to get a specific formatted string for a value (like returning polarity or percent with number)
suffix(names_arr) || suffix: if function, return a formatted string for a given array of names
if string, then this will be appended after joining of names_arr
buff_separator: separator between buff names, default is "/"
message_separator: separator between different value strings, default is ", "
}
required: all or (values and names), special_case.func if special_case.isSpecialCase() is used
all else is optional
*/
if (!options) throw "multi_param_buff_handler: No options defined";
if (options.all) { //array of objects with keys value and name
options.values = [];
options.names = [];
for (let i = 0; i < options.all.length; ++i) {
let [curValue, curName] = [options.all[i]["value"], options.all[i]["name"]];
options.values.push(curValue);
options.names.push(curName);
}
}
if (!options.values || !options.names) throw "multi_param_buff_handler: No values, names, or all array defined";
//create a JSON object keyed by buff values
// debug_log(options);
let common_values = {}, msg = "";
for (let i = 0; i < options.values.length; ++i) {
if (options.values[i] !== undefined) { //in case some values are undefined
let curValue = options.values[i].toString();
if (!common_values[curValue]) {
common_values[curValue] = [];
};
//value of each key is an array of names with that shared value
common_values[curValue].push(options.names[i]);
}
}
// debug_log(common_values);
//create a string from common_values object
var msg_arr = []; //array of shared values
for (let v in common_values) {
let msg = "";
//handle special cases
if (options.special_case && options.special_case.isSpecialCase(v, common_values[v])) {
msg = options.special_case.func(v, common_values[v]);
if (msg.length > 0) msg_arr.push(msg);
continue;
}
//format output according to options
if (options.prefix) {
if (typeof options.prefix === "function") msg += options.prefix(common_values[v]);
else msg += options.prefix;
}
if (options.numberFn) msg += options.numberFn(v);
else msg += v;
if (typeof options.suffix === "function") msg += options.suffix(common_values[v]);
else {
msg += common_values[v].join(options.buff_separator || "/");
if (typeof options.suffix === "string") msg += options.suffix;
}
msg_arr.push(msg);
}
let result_msg = "";
result_msg += msg_arr.join(options.message_separator || ", ");
return result_msg;
}
this.multi_param_buff_handler = multi_param_buff_handler;
function hp_adr_buff_handler(hp, atk, def, rec, options) {
options = options || {};
options.all = options.all || [
{ value: hp, name: "HP" },
{ value: atk, name: "ATK" },
{ value: def, name: "DEF" },
{ value: rec, name: "REC" }
];
options.numberFn = options.numberFn || function (number) {
return `${get_polarized_number(number)}% `;
};
return multi_param_buff_handler(options);
}
function bc_hc_items_handler(bc, hc, item, options) {
options = options || {};
let extra_values = options.extra_values || {};
options.all = [
{ value: bc, name: "BC" },
{ value: hc, name: "HC" },
{ value: item, name: "Item" },
{ value: extra_values.zel, name: 'Zel'},
{ value: extra_values.karma, name: 'Karma'}
];
options.numberFn = function (number) {
return `${get_polarized_number(number)}% `;
};
return multi_param_buff_handler(options);
}
function bb_atk_buff_handler(bb, sbb, ubb, options) {
options = options || {};
options.all = options.all || [
{ value: bb, name: "BB" },
{ value: sbb, name: "SBB" },
{ value: ubb, name: "UBB" }
];
options.numberFn = options.numberFn || function (number) {
return `${get_polarized_number(number)}% `;
};
return multi_param_buff_handler(options);
}
function variable_elemental_mitigation_handler(effect,buff_keys) {
let elements = ['Fire', 'Water', 'Earth', 'Thunder', 'Light', 'Dark'];
let buffs = buff_keys || ['mitigate fire attacks (21)', 'mitigate water attacks (22)', 'mitigate earth attacks (23)', 'mitigate thunder attacks (24)', 'mitigate light attacks (25)', 'mitigate dark attacks (26)'];
let values = [];
for (let b of buffs) {
values.push(effect[b]);
}
let options = {
names: elements,
values: values,
numberFn: function (value) { return `${value}% `; },
suffix: " mitigation",
special_case: {
isSpecialCase: function (val, names) { return names.length >= 4; },
func: function (value, names) {
let msg = `${value}% `;
if (names.length < 6) {
for (let n of names) {
msg += n[0].toUpperCase();
}
} else {
msg += "all elemental";
}
msg += " mitigation";
return msg;
}
}
};
return multi_param_buff_handler(options);
}
function elemental_bool_handler(options) {
options.names = options.names || ['Fire', 'Water', 'Earth', 'Thunder', 'Light', 'Dark'];
options.numberFn = options.numberFn || function (d) { return ""; };
options.special_case = options.special_case || {
isSpecialCase: function (value, name_arr) { return value == "true" && name_arr.length === 6; },
func: function (value, names_array) {
return "all elemental";
}
}
return multi_param_buff_handler(options);
}
//give an options object with at least an array of values for each ailment
function ailment_handler(options) {
if (!options || !options.values) throw "ailment_handler: No options or values defined";
if (options.values.length === 6)
options.names = options.names || ["Injury", "Poison", "Sick", "Weaken", "Curse", "Paralysis"];
else if (options.values.length === 3)
options.names = options.names || ["ATK Down", "DEF Down", "REC Down"];
else if (options.values.length === 9)
options.names = options.names || ["Injury", "Poison", "Sick", "Weaken", "Curse", "Paralysis", "ATK Down", "DEF Down", "REC Down"];
options.numberFn = options.numberFn || function (value) {
return `${value}%`;
}
return multi_param_buff_handler(options);
}
function ailments_cured_handler(ailments_array) {
function contains_all_status_ailments(arr) {
var containsAll = true;
var ailments = ['poison', 'weaken', 'sick', 'injury', 'curse', 'paralysis'];
for (let a = 0; a < ailments.length; ++a) {
if (arr.indexOf(ailments[a]) === -1) {
containsAll = false; break;
}
}
return containsAll;
}
function contains_all_stat_reductions(arr) {
var containsAll = true;
var ailments = ['atk down', 'def down', 'rec down'];
for (let a = 0; a < ailments.length; ++a) {
if (arr.indexOf(ailments[a]) === -1) {
containsAll = false; break;
}
}
return containsAll;
}
var msg = "";
if (ailments_array.length === 9) {
msg += "all ailments";
} else if (ailments_array.length === 6 && contains_all_status_ailments(ailments_array)) {
msg += "all status ailments";
} else if (ailments_array.length === 3 && contains_all_stat_reductions(ailments_array)) {
msg += "all status reductions";
} else {
msg += ailments_array.join("/");
}
return msg;
}
function get_target(area, type, options) {
debug_log("Received target data",area,type, options);
options = options || {};
let isPassive = options.isPassive|| options.sp || false;
if (typeof area === "object" && area["target type"] && area["target area"]) {
type = area["target type"];
area = area["target area"];
} else if (typeof type === "object" && type["target type"] && type["target area"]) {
area = type["target area"];
type = type["target type"];
}else if (typeof area === "object" && area["passive target"]) {
type = area['passive target'];
isPassive = true;
} else if (typeof type === "object" && type["passive target"]) {
type = type['passive target'];
isPassive = true;
}
if(type !== 'party' && type !== 'self' && type !== 'enemy'){ //default to self
if(!options.isLS){
debug_log("Defaulting to self");
type = "self";
}else{
type = 'party';
}
}
let prefix = options.prefix || "to ";
let suffix = options.suffix || "";
//special case for when options.prefix is ""
if (typeof options.prefix === "string" && options.prefix.length === 0)
prefix = "";
if(!options.isPassive){
if (area === "single" && type === "self") {
return ` ${prefix}self${suffix}`;
} else if (area === "aoe" && type === "party") {
return ` ${prefix}allies${suffix}`;
} else if (area === "aoe" && type === "enemy") {
return ` ${prefix}enemies${suffix}`;
} else if (area === "single" && type === "enemy") {
return ` ${prefix}an enemy${suffix}`;
} else if (area === "single" && type === "party") {
return ` ${prefix}an ally${suffix}`;
} else {
return ` (${area},${type})`;
}
}else{
if(type === 'self'){
return ` ${prefix}self${suffix}`;
}else if(type === 'party'){
return ` ${prefix}allies${suffix}`;
}else{
return ` (${type})`;
}
}
}
function get_turns(turns, msg, sp, buff_desc) {
let turnMsg = "";
if ((msg.length === 0 && sp) || (turns === 0 && !sp) || (turns && sp) || (turns !== undefined && turns !== 0)) {
if (msg.length === 0 && sp) turnMsg = `Allows current ${buff_desc}${(buff_desc.toLowerCase().indexOf("buff") === -1) ? " buff(s)" : ""} to last for additional `;
else turnMsg += ` for `;
turnMsg += `${turns} ${(+turns === 1 ? "turn" : "turns")}`;
}
return turnMsg;
}
function regular_atk_helper(effect) {
let msg = "";
// if (effect["bb flat atk"]) msg += " (+" + effect["bb flat atk"] + " flat ATK)";
if (effect["bb bc%"]) msg += ", innate " + get_polarized_number(effect["bb bc%"]) + "% BC drop rate";
if (effect["bb crit%"]) msg += ", innate " + get_polarized_number(effect["bb crit%"]) + "% crit rate";
if (effect["bb hc%"]) msg += ", innate " + get_polarized_number(effect["bb hc%"]) + "% HC drop rate";
return msg;
}
function base_buffed_resistance_handler(base,buffed,buff_name){
if(base === 100 && buffed === 100){
return buff_name;
}else{
let options = {
all: [
{ value: base, name: "base" },
{ value: buffed, name: "buffed" }
],
numberFn: (d) => { return `${get_polarized_number(d)}% `; }
}
let resist = multi_param_buff_handler(options);
if (resist.length > 0) {
resist += ` ${buff_name}`;
}
return resist;
}
}
var buff_types = {
attack: `unit attacks enemy`,
buff: `unit gains some sort of enhancement to their stats or attacks, can last more than one turn`,
debuff: `unit's attack inflicts some ailment onto the enemy`,
effect: `buff does something directly to the unit(s) on that turn; multiple instances of itself on the same turn will stack`,
passive: `always active`,
conditional: 'only activates when certain criteria are met',
timed: `only active for a certain amount of time`,
none: `buff doesn't do anything; either bugged or developer value`,
unknown: `it is unknown what buffs of these types do or how to interpret them correctly`
};
var proc_buffs = {
'1': {
desc: "Regular Attack",
type: ["attack"],
notes: ["Unless otherwise specified, the attack will always be toward the enemy"],
func: function (effect, other_data) {
other_data = other_data || {};
let damage_frames = other_data.damage_frames || {};
var numHits = damage_frames.hits || "NaN";
var msg = "";
if (!other_data.sp) {
msg += numHits.toString() + ((numHits === 1) ? " hit " : " hits ");
}
let damage = [];
if (effect["bb atk%"]) damage.push(`${effect["bb atk%"]}%`);
if (effect["bb dmg%"]) damage.push(`${effect["bb dmg%"]}%`); //case when using a burst from bbs.json
switch (damage.length) {
case 1: msg += `${damage[0]} `; break;
case 2: msg += `${damage[0]} (${damage[1]} power) `; break;
default: break;
}
if (other_data.sp) msg += "to BB ATK%";
if (!other_data.sp) {
msg += (effect["target area"].toUpperCase() === "SINGLE") ? "ST" : effect["target area"].toUpperCase();
}
let extra = [];
if (effect["bb flat atk"]) extra.push("+" + effect["bb flat atk"] + " flat ATK");
if (damage_frames["hit dmg% distribution (total)"] !== undefined && damage_frames["hit dmg% distribution (total)"] !== 100)
extra.push(`at ${damage_frames["hit dmg% distribution (total)"]}% power`);
if (extra.length > 0) msg += ` (${extra.join(", ")})`;
msg += regular_atk_helper(effect);
if (!other_data.sp) {
if (effect["target type"] !== "enemy") msg += ` to ${effect["target type"]}`;
}
return msg;
}
},
'2': {
desc: "Burst Heal",
type: ["effect"],
notes: ["if no hits are mentioned, then the burst heal happens all at once", "over multiple hits means that for every hit, units heal a fraction of the burst heal"],
func: function (effect, other_data) {
let damage_frames = other_data.damage_frames || {};
var msg = get_formatted_minmax(effect['heal low'], effect['heal high']) + " HP burst heal ";
msg += "(+" + effect['rec added% (from healer)'] + "% healer REC)";
if (damage_frames.hits > 1)
msg += " over " + damage_frames.hits + " hits";
// msg += " (" + effect["target area"] + "," + effect["target type"] + ")";
if (!other_data.sp) msg += get_target(effect, other_data);
return msg;
}
},
'3': {
desc: "Heal over Time (HoT)",
type: ["buff"],
func: function (effect, other_data) {
other_data = other_data || {};
var msg = "";
if (effect["gradual heal low"] || effect['gradual heal high']) {
msg = get_formatted_minmax(effect["gradual heal low"], effect["gradual heal high"]) + " HP HoT";
msg += " (+" + effect["rec added% (from target)"] + "% target REC)";
}
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data);
msg += get_turns(effect["gradual heal turns (8)"], msg, other_data.sp, this.desc);
return msg;
}
},
'4': {
desc: "BB Gauge Refill",
type: ["effect"],
notes: ["This effect is similar to the regular BC insta-fill buff (proc 31), but has the option of filling a percentage of the BB gauge", "Filling 100% of own BB gauge means that the gauge will be refilled to SBB if it's unlocked"],
func: function (effect, other_data) {
var msg = "";
if (effect["bb bc fill%"]) {
if (effect["bb bc fill%"] !== 100)
msg += `${get_polarized_number(effect["bb bc fill%"])}% BB gauge of`;
else
msg += "Fills BB gauge of";
}
if (effect["bb bc fill"]) {
if (effect["bb bc fill%"]) msg += " and ";
msg += `${get_polarized_number(effect["bb bc fill"])} BC fill to`;
}
if (!other_data.sp) msg += get_target(effect, other_data, {
prefix: ''
});
if (effect["bb bc fill%"] === 100) {
msg += " to max";
}
return msg;
}
},
'5': {
desc: "Regular and Elemental ATK/DEF/REC/Crit Rate",
type: ["buff"],
func: function (effect, other_data) {
var msg = "";
if (effect["atk% buff (1)"] || effect["def% buff (3)"] || effect["rec% buff (5)"]) { //regular tri-stat
msg += hp_adr_buff_handler(undefined, effect["atk% buff (1)"], effect["def% buff (3)"], effect["rec% buff (5)"]);
}
if (effect["crit% buff (7)"]) {//crit rate buff
if (msg.length > 0) msg += ", ";
msg += get_polarized_number(effect["crit% buff (7)"]) + "% crit rate";
}
if (effect["atk% buff (2)"] || effect["def% buff (4)"] || effect["rec% buff (6)"]) {//decreased buffs
if (msg.length > 0) msg += ", ";
msg += hp_adr_buff_handler(undefined, effect["atk% buff (2)"], effect["def% buff (4)"], effect["rec% buff (6)"]);
}
if (effect["atk% buff (13)"] || effect["def% buff (14)"] || effect["rec% buff (15)"]) { //elemental tri-stat
msg += hp_adr_buff_handler(undefined, effect["atk% buff (13)"], effect["def% buff (14)"], effect["rec% buff (15)"]);
}
if (effect["crit% buff (16)"]) { //elemental crit buff
if (msg.length > 0) msg += ", ";
msg += get_polarized_number(effect["crit% buff (16)"]) + "% crit rate";
}
if (effect['element buffed'] !== "all") {
msg += " of " + to_proper_case(effect['element buffed'] || "null");
}
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data);
msg += get_turns(effect["buff turns"], msg, other_data.sp, this.desc);
return msg;
}
},
'6': {
desc: "BC/HC/Item Drop Rate",
type: ["buff"],
func: function (effect, other_data) {
debug_log('proc 6', effect);
var msg = "";
if (effect["bc drop rate% buff (10)"] || effect["hc drop rate% buff (9)"] || effect["item drop rate% buff (11)"])
msg += bc_hc_items_handler(effect["bc drop rate% buff (10)"], effect["hc drop rate% buff (9)"], effect["item drop rate% buff (11)"]) + " droprate";
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data);
msg += get_turns(effect["drop rate buff turns"], msg, other_data.sp, this.desc);
return msg;
}
},
'7': {
desc: "Guaranteed Angel Idol (AI)",
type: ["buff"],
notes: ["This is the one that is guaranteed to work; no chance of failing", "if you see false in the result, please let the developer (BluuArc) know"],
func: function (effect, other_data) {
var info_arr = [];
if (effect["angel idol buff (12)"] !== true) info_arr.push(effect["angel idol buff (12)"]);
info_arr.push(`recover ${effect["angel idol recover hp%"] || 100}% HP on use`);
let msg = `gives Angel Idol (${info_arr.join(", ")})`;
if (!other_data.sp) msg += get_target(effect, other_data);
return msg;
}
},
'8': {
desc: "Increase Max HP",
type: ["buff"],
func: function (effects, other_data) {
let msg = "";
if (effects["max hp increase"]) {
msg = `${get_polarized_number(effects["max hp increase"])} HP boost to max HP`;
} else {
msg = `${get_polarized_number(effects["max hp% increase"])}% Max HP`;
}
if (!other_data.sp) msg += get_target(effects, other_data);
return msg;
}
},
'9': {
desc: "ATK/DEF/REC down to enemy",
type: ["debuff"],
notes: ['Not sure if this is implemented properly on SP for unit 30517 or 61027'],
func: function (effect, other_data) {
var msg = "";
let chance, amount; //used to check values for SP
//case that both buffs are present with same proc chance
if (effect['buff #1'] !== undefined && effect['buff #2'] !== undefined && effect['buff #1']['proc chance%'] === effect['buff #2']['proc chance%']) {
debug_log("entered double branch");
let debuff1 = effect['buff #1'];
let debuff2 = effect['buff #2'];
chance = debuff1['proc chance%'];
let atk = debuff1['atk% buff (1)'] || debuff2['atk% buff (1)'] || debuff1['atk% buff (2)'] || debuff2['atk% buff (2)'];
let def = debuff1['def% buff (3)'] || debuff2['def% buff (3)'] || debuff1['def% buff (4)'] || debuff2['def% buff (4)'] || debuff1['def% buff (14)'] || debuff2['def% buff (14)'];
let rec = debuff1['rec% buff (5)'] || debuff2['rec% buff (5)'] || debuff1['rec% buff (6)'] || debuff2['rec% buff (6)'];
amount = atk || 0 + def || 0 + rec || 0;
msg += debuff1['proc chance%'] + "% chance to inflict " + hp_adr_buff_handler(undefined, atk, def, rec);
} else if (effect['buff #1']) {
let debuff = effect['buff #1'];
chance = debuff['proc chance%'];
let atk = debuff['atk% buff (1)'] || debuff['atk% buff (2)'];
let def = debuff['def% buff (3)'] || debuff['def% buff (4)'] || debuff['def% buff (14)'];
let rec = debuff['rec% buff (5)'] || debuff['rec% buff (6)'];
amount = atk || 0 + def || 0 + rec || 0;
msg += debuff['proc chance%'] + "% chance to inflict " + hp_adr_buff_handler(undefined, atk, def, rec);
} else if (effect['buff #2']) {
if (msg.length > 0) msg += ", ";
let debuff = effect['buff #2'];
chance = debuff['proc chance%'];
let atk = debuff['atk% buff (1)'] || debuff['atk% buff (2)'];
let def = debuff['def% buff (3)'] || debuff['def% buff (4)'] || debuff['def% buff (14)'];
let rec = debuff['rec% buff (5)'] || debuff['rec% buff (6)'];
amount = atk || 0 + def || 0 + rec || 0;
msg += debuff['proc chance%'] + "% chance to inflict " + hp_adr_buff_handler(undefined, atk, def, rec);
}
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!chance && !amount && other_data.sp) msg = "";
msg += get_turns(effect["buff turns"], msg, other_data.sp, this.desc);
if (effect['element buffed'] !== 'all') msg += ` of ${to_proper_case(effect['element buffed'] || "null")} types`;
// msg += ` for ${effect["buff turns"]} ${effect["buff turns"] === 1 ? "turn" : "turns"}`;
if (!other_data.sp) msg += get_target(effect, other_data);
return msg;
}
},
'10': {
desc: "Status Ailment Removal",
type: ["effect"],
notes: ["if you see false in the result, please let the developer (BluuArc) know", 'This seems similar to proc 38, the usual status removal buff'],
func: function (effect, other_data) {
let msg = "Removes all status ailments";
if (effect["remove all status ailments"] !== true) {
msg += ` ${effect["remove all status ailments"]}) `;
}
if (!other_data.sp) msg += get_target(effect, undefined, {
prefix: 'from '
});
return msg;
}
},
'11': {
desc: "Inflict Status Ailment",
type: ["debuff"],
notes: ["Some bursts have a 'null' parameter; it's currently unknown as to what it does"],
func: function (effect, other_data) {
let options = {};
options.values = [
effect["injury%"],
effect["poison%"],
effect["sick%"],
effect["weaken%"],
effect["curse%"],
effect["paralysis%"]
];
options.suffix = function (names) {
if (names.length === 6) {
return " chance to inflict any status ailment";
} else {
return ` chance to inflict ${names.join("/")}`;
}
}
let msg = ailment_handler(options);
if (msg.length === 0 && (!effect[null] || !other_data.sp)) throw no_buff_data_msg;
if (effect[null]) {
if (msg.length === 0)
msg += `Unknown param 'null' (${effect[null]})`;
else
msg += `, Unknown param 'null' (${effect[null]})`;
}
if (!other_data.sp) msg += get_target(effect, other_data);
return msg;
}
},
'12': {
desc: "Guaranteed Revive",
type: ["effect"],
notes: ["As of June 2017, this is only found on at least one NPC attack and some items"],
func: function (effect, other_data) {
let revive_target = get_target(effect, other_data, {
prefix: "",
suffix: ""
});
let msg = `revive${revive_target} with ${effect['revive to hp%']}% HP`;
return msg;
}
},
'13': {
desc: "Random Target (RT) Attack",
type: ["attack"],
func: function (effect, other_data) {
other_data = other_data || {};
let damage_frames = other_data.damage_frames || {};
var numHits = effect.hits || "NaN";
// var numHits = effect.hits;
let msg = "";
if (!other_data.sp) {
msg += numHits.toString() + ((numHits === 1) ? " hit" : " hits");
}
if (effect["bb atk%"]) msg += ` ${effect["bb atk%"]}%`;
if (!other_data.sp) msg += " ";
else msg += " to BB ATK%";
if (!other_data.sp) {
if (effect["random attack"] === false) msg += (effect["target area"].toUpperCase() === "SINGLE") ? "ST" : effect["target area"].toUpperCase();
else msg += "RT";
}
let extra = [];
if (effect["bb flat atk"]) extra.push("+" + effect["bb flat atk"] + " flat ATK");
if (damage_frames["hit dmg% distribution (total)"] !== undefined && damage_frames["hit dmg% distribution (total)"] !== 100)
extra.push(`at ${damage_frames["hit dmg% distribution (total)"]}% power`);
if (extra.length > 0) msg += ` (${extra.join(", ")})`;
msg += regular_atk_helper(effect);
if (!other_data.sp) {
if (effect["target type"] !== "enemy") msg += ` to ${effect["target type"]}`;
}
return msg;
}
},
'14': {
desc: "HP Draining Attack",
type: ["attack"],
notes: ["Unless otherwise specified, the attack will always be toward the enemy"],
func: function (effect, other_data) {
other_data = other_data || {};
let damage_frames = other_data.damage_frames || {};
var numHits = damage_frames.hits || "NaN";
var msg = "";
if (!other_data.sp) {
msg += numHits.toString() + ((numHits === 1) ? " hit" : " hits");
}
let damage = [];
if (effect["bb atk%"]) damage.push(`${effect["bb atk%"]}%`);
if (effect["bb dmg%"]) damage.push(`${effect["bb dmg%"]}%`); //case when using a burst from bbs.json
switch (damage.length) {
case 1: msg += ` ${damage[0]}`; break;
case 2: msg += ` ${damage[0]} (${damage[1]} power)`; break;
default: break;
}
if (!other_data.sp) msg += " ";
else msg += " to BB ATK%";
if (!other_data.sp) {
msg += (effect["target area"].toUpperCase() === "SINGLE") ? "ST" : effect["target area"].toUpperCase();
}
let extra = [];
if (effect["bb flat atk"]) extra.push("+" + effect["bb flat atk"] + " flat ATK");
extra.push(`heal ${get_formatted_minmax(effect["hp drain% low"], effect["hp drain% high"])}% of damage dealt`);
if (damage_frames["hit dmg% distribution (total)"] !== undefined && damage_frames["hit dmg% distribution (total)"] !== 100)
extra.push(`at ${damage_frames["hit dmg% distribution (total)"]}% power`);
if (extra.length > 0) msg += ` (${extra.join(", ")})`;
msg += regular_atk_helper(effect);
if (!other_data.sp) {
if (effect["target type"] !== "enemy") msg += ` to ${effect["target type"]}`;
}
return msg;
}
},
'16': {
desc: "Elemental Mitigation",
type: ["buff"],
notes: ["This is different from proc ID 39 in that each element can have a different value of mitigation; otherwise it's almost the same"],
func: function (effect, other_data) {
let msg = variable_elemental_mitigation_handler(effect);
if (effect['mitigate all attacks (20)'] !== undefined) {
if (msg.length > 0) msg += ", ";
msg += `${effect['mitigate all attacks (20)']}% all attack mitigation`;
}
if (!other_data.sp) msg += get_target(effect, other_data);
msg += get_turns(effect['buff turns'], msg, other_data.sp, this.desc);
return msg;
}
},
'17': {
desc: "Status Negation/Resistance",
type: ["buff"],
func: function (effect, other_data) {
let options = {};
options.values = [
effect["resist injury% (33)"],
effect["resist poison% (30)"],
effect["resist sick% (32)"],
effect["resist weaken% (31)"],
effect["resist curse% (34)"],
effect["resist paralysis% (35)"]
];
options.suffix = function (names) {
if (names.length === 6) {
return " all status ailments";
} else {
return ` ${names.join("/")}`;
}
};
options.numberFn = function (value) {
if (value == 100)
return "Negates";
else
return `${value}% resistance to`;
};
options.special_case = {
isSpecialCase: function (value, names) {
// debug_log("Received:", value, names.length, value == 100, names.length === 6);
return value == 0 || names.length === 6;
},
func: function (value, names) {
if(value == 0) return "";
if(value == 100)
return "Negates all status ailments";
else
return `${value}% resistance to all status ailments`;
}
};
let msg = "";
if (effect["resist injury% (33)"] || effect["resist poison% (30)"] || effect["resist sick% (32)"] ||
effect["resist weaken% (31)"] || effect["resist curse% (34)"] || effect["resist paralysis% (35)"])
msg += ailment_handler(options);
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data, {
prefix: 'for '
});
msg += get_turns(effect['resist status ails turns'], msg, other_data.sp, this.desc);
return msg;
}
},
'18': {
desc: "Mitigation",
type: ["buff"],
func: function (effect, other_data) {
var msg = "";
if (effect['dmg% reduction']) msg += `${effect["dmg% reduction"]}% mitigation`;
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data);
msg += get_turns(effect['dmg% reduction turns (36)'], msg, other_data.sp, this.desc);
return msg;
}
},
'19': {
desc: "BC Fill per Turn",
type: ["buff"],
func: function (effect, other_data) {
var msg = "";
if (effect['increase bb gauge gradual']) msg += get_polarized_number(effect["increase bb gauge gradual"]) + " BC/turn";
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data);
msg += get_turns(effect['increase bb gauge gradual turns (37)'], msg, other_data.sp, this.desc);
return msg;
}
},
'20': {
desc: "BC Fill on Hit",
type: ["buff"],
func: function (effect, other_data) {
var msg = "";
if (effect["bc fill when attacked%"] || effect["bc fill when attacked low"] || effect["bc fill when attacked high"]) {
if (effect["bc fill when attacked%"] !== undefined && effect["bc fill when attacked%"] !== 100) {
msg += `${effect["bc fill when attacked%"]}% chance to fill `;
} else if (effect["bc fill when attacked%"] !== undefined && effect["bc fill when attacked%"] === 100) {
msg += "Fills ";
}
msg += `${get_formatted_minmax(effect["bc fill when attacked low"], effect["bc fill when attacked high"])} BC when hit`;
}
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data);
msg += get_turns(effect["bc fill when attacked turns (38)"], msg, other_data.sp, this.desc);
return msg;
}
},
'22': {
desc: "Defense Ignore",
type: ["buff"],
func: function (effect, other_data) {
var msg = "";
if (effect['defense% ignore']) msg += `${effect['defense% ignore']}% DEF ignore`;
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data, {
prefix: "to attacks of "
});
msg += get_turns(effect["defense% ignore turns (39)"], msg, other_data.sp, this.desc);
return msg;
}
},
'23': {
desc: "Spark Damage",
type: ["buff"],
func: function (effect, other_data) {
var msg = "";
if (effect["spark dmg% buff (40)"]) msg += get_polarized_number(effect["spark dmg% buff (40)"]) + "% spark DMG";
if (msg.length === 0 && !other_data.sp) throw no_buff_data_msg;
if (!other_data.sp) msg += get_target(effect, other_data, {
prefix: "to attacks of "
});
msg += get_turns(effect["buff turns"], msg, other_data.sp, this.desc);
return msg;
}
},
'24': {
desc: "Stat Conversion",
type: ["buff"],
func: function (effect, other_data) {
let msg = "";
if (effect['converted attribute'] || effect['atk% buff (46)'] || effect['def% buff (47)'] || effect['rec% buff (48)']) {
let source_buff = (effect['converted attribute'] !== undefined) ? (effect['converted attribute'] || "null").toUpperCase().slice(0, 3) : undefined;
if (source_buff === "ATT") source_buff = "ATK";
let options = {
suffix: " conversion",
};
if (source_buff) {
options.numberFn = function (value) { return `${value}% ${source_buff}->` };