-
Notifications
You must be signed in to change notification settings - Fork 12
/
script.js
7871 lines (7333 loc) · 296 KB
/
script.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
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
let Cards = []; //怪物数据
let Skills = []; //技能数据
let PlayerDatas = []; //玩家数据
let currentLanguage; //当前语言
let currentDataSource; //当前数据
let currentPlayerData; //当前玩家数据
let defaultLevel = 99; //默认等级
const teamBigBoxs = []; //储存全部teamBigBox
const allMembers = []; //储存所有成员,包含辅助
let controlBox; //储存整个controlBox
let statusLine; //储存状态栏
let formationBox; //储存整个formationBox
let editBox; //储存整个editBox
let showSearch; //整个程序都可以用的显示搜索函数
let qrcodeReader; //二维码读取
let qrcodeWriter; //二维码输出
let selectedDeviceId; //视频源id
const dataStructure = 5; //阵型输出数据的结构版本
const cfgPrefix = "PADDF-"; //设置名称的前缀
const className_displayNone = "display-none";
const dataAttrName = "data-value"; //用于储存默认数据的属性名
const isGuideMod = Boolean(Number(getQueryString("guide"))); //是否以图鉴模式启动
const svgNS = "http://www.w3.org/2000/svg"; //svg用的命名空间
//用油猴扩展装上,把GM_xmlhttpRequest引入的脚本
const ExternalLinkScriptURL = "https://greasyfork.org/scripts/458521";
const paddbPathPrefix = "/team/"; //PADDB的获取队伍网址格式
const uploadMessage = "Use PADDashFormation to read the Team URL and restore correct team for ID > 9934.\nhttps://github.com/Mapaler/PADDashFormation";
if (location.search.includes('&')) {
location.search = location.search.replace(/&/ig, '&');
}
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js', {scope: './'})
.then(function(registration) {
console.debug('service worker 注册成功',registration);
}).catch(function(error) {
console.error('servcie worker 注册失败',error);
});
} else {
console.error('浏览器不支持 servcie worker');
}
//一开始就加载当前语言
if (currentLanguage == undefined)
{
const parameter_i18n = getQueryString(["l","lang"]); //获取参数指定的语言
const browser_i18n = navigator.language; //获取浏览器语言
if (parameter_i18n) //有指定语言的话,只找i18n完全相同的
{
currentLanguage = languageList.find(lang => lang.i18n == parameter_i18n) || languageList[0];
}
if (!currentLanguage) //如果还没有就直接搜索浏览器语言
{
currentLanguage = languageList.find(lang => { //筛选出符合的语言
if (lang.i18n_RegExp)
{
return lang.i18n_RegExp.test(browser_i18n); //匹配正则表达式
}else
{
return browser_i18n.includes(lang.i18n); //文字上的搜索包含
}
}) || languageList[0]; //没有找到指定语言的情况下,自动用第一个语言(英语)
}
//因为Script在Head里面,所以可以这里head已经加载好可以使用
document.head.querySelector("#language-css").href = `languages/${currentLanguage.i18n}.css`;
}
//一开始就加载当前数据
if (currentDataSource == undefined)
{
const parameter_dsCode = getQueryString("s"); //获取参数指定的数据来源
currentDataSource = dataSourceList.find(ds => ds.code == parameter_dsCode) || dataSourceList[0]; //筛选出符合的数据源
}
const dbName = "PADDF";
let db = null;
const DBOpenRequest = indexedDB.open(dbName, 4);
DBOpenRequest.onsuccess = function(event) {
db = event.target.result; //DBOpenRequest.result;
console.log("PADDF:数据库已可使用");
loadData();
};
DBOpenRequest.onerror = function(event) {
// 错误处理
console.log("PADDF:数据库无法启用,删除可能存在的异常数据库。",event);
indexedDB.deleteDatabase(dbName); //直接把整个数据库删掉
console.log("也可能是隐私模式导致无法启用数据库,于是尝试不保存的情况下读取数据。");
loadData();
//alert('Some errors have occurred, please refresh the page.');
//history.go(); //直接强制刷新
};
DBOpenRequest.onupgradeneeded = function(event) {
let db = event.target.result;
let store;
switch (true)
{
case event.oldVersion < 2:
store = db.createObjectStore("cards");
store = db.createObjectStore("skills");
case event.oldVersion < 3:
store = db.createObjectStore("palyer_datas", { keyPath: 'name' });
}
// 使用事务的 oncomplete 事件确保在插入数据前对象仓库已经创建完毕
store.transaction.oncomplete = function(event) {
console.log("PADDF:数据库建立完毕");
};
};
class Plus extends Array {
constructor(hp = 0 , atk = 0, rcv = 0) {
super(3);//建立 Array
if (Array.isArray(hp) && hp.length >= 3 //传入数组的形式
&& hp.every(n=>Number.isInteger(n))) {
this[0] = hp[0];
this[1] = hp[1];
this[2] = hp[2];
} else { //传入三个数字的形式
if (!Number.isInteger(hp) || !Number.isInteger(atk) || !Number.isInteger(rcv)) throw new TypeError("传入的 +值 不是整数");
this[0] = hp;
this[1] = atk;
this[2] = rcv;
}
}
get hp() {
return this[0];
}
set hp(num) {
if (!Number.isInteger(num)) throw new TypeError("传入的 HP +值 不是整数");
if (num < 0 || num > 99) throw new RangeError("HP +值应为 0-99 之间的整数");
this[0] = num;
}
get atk() {
return this[1];
}
set atk(num) {
if (!Number.isInteger(num)) throw new TypeError("传入的 ATK +值 不是整数");
if (num < 0 || num > 99) throw new RangeError("ATK +值应为 0-99 之间的整数");
this[1] = num;
}
get rcv() {
return this[2];
}
set rcv(num) {
if (!Number.isInteger(num)) throw new TypeError("传入的 RCV +值 不是整数");
if (num < 0 || num > 99) throw new RangeError("RCV +值应为 0-99 之间的整数");
this[2] = num;
}
get is297() {
return (this[0] + this[1] + this[2]) === 297;
}
}
class LatentAwakening extends Array {
blocks = 6;
constructor(arg = []) {
super();//建立 Array
if (typeof arg === "bigint" ||
typeof arg === "number" && Number.isInteger(arg) ||
typeof arg === "string" && /^\d+$/.test(arg)
){ //单个大数字模式
let latentNumber = BigInt(arg);
//console.log("原始数字",latentNumber.toString(2));
const latentVersion = latentNumber & 0b111n; //记录版本,111是用几位来做记录,也就是最多7位
latentNumber >>= 3n; //右移3位
//console.log("读取潜觉记录位数",latentNumber.toString(2));
const changeLatentBlocksNum = Boolean(latentNumber & 1n); //1时就是开孔了
latentNumber >>= 1n; //右移1位
//console.log("读取潜觉格子数是否改变",latentNumber.toString(2));
if (changeLatentBlocksNum)
{
this.blocks = Number(latentNumber & 0b1111n);
latentNumber >>= 4n;
//console.log("读取潜觉格子数",latentNumber.toString(2));
}
const rightNumn = latentVersion > 6n ? 7n : 5n; //右移的距离
const getbnum = (1n << rightNumn) - 1n; //逻辑与的数字 //latentVersion > 6 ? 0b1111111n : 0b11111n;
while (latentNumber > 0n)
{
const latentId = Number(latentNumber & getbnum);
this.push(latentId);
//判断是几格,然后直接右移几次
const useHole = latentUseHole(latentId);
latentNumber >>= rightNumn * BigInt(useHole);
}
} else if (Array.isArray(arg)) {
Object.assign(this, arg);
}
}
get usedHole() {
return this.reduce((p,v)=>p + latentUseHole(v),0);
}
toBigInt() {
//直接使用目前的最新版本
const leftNumn = 0b111n;
//重复添加潜觉
let latentNum = this.reduceRight((pre,latentId, idx)=>{
const useHole = latentUseHole(latentId);
const latentIdn = BigInt(latentId);
for (let i=1; i <= useHole; i++) {
pre <<= leftNumn;
pre |= latentIdn;
}
return pre;
}, 0n);
//添加使用的格子数
latentNum <<= 4n;
latentNum |= BigInt(this.blocks);
//添加是否已打开格子
latentNum <<= 1n;
latentNum |= this.blocks > 6 ? 1n : 0n;
//潜觉版本,直接来最新版本
latentNum <<=3n;
latentNum |= latentVersion;
return BigInt.asUintN(64, latentNum);;
}
}
class Member2 {
id = 0; //原始id
changes = null; //变身后id
level = 1; //等级
awakening = 0; //觉醒数量
superAwakening= 0; //超觉醒ID
#plus = new Plus(); //加值
#latentAwakening = new LatentAwakening(); //潜在觉醒
skillLevel = 0; //技能等级
assistMember = null; //辅助对象的引用
//下面是游戏状态
skillQuantity = 0; //技能填充量
evolveSkillStage = null; //储存进化类技能的当前等级
attrChange = null; //改变为什么颜色
get hasAssist() {
return assistMember instanceof Member2;
}
removeAssist() {
this.assistMember = null;
}
constructor(oldMember = {}, assistMember = null)
{
if (assistMember instanceof Member2) {
this.assistMember = assistMember;
assistMember.removeAssist();
}
if (oldMember instanceof Member2) {
Object.assign(this, oldMember);
}
}
get card() {
return Cards[this.id] ?? Cards[0];
}
get plus() {
return this.#plus;
}
set plus(arr) {
if (!Array.isArray(arr) || !arr.every(n=>Number.isInteger(n)))
throw new TypeError("直接设定 +值 应当为整形数组");
this.#plus[0] = arr[0];
this.#plus[1] = arr[1];
this.#plus[2] = arr[2];
}
get latentAwakening() {
return this.#latentAwakening;
}
set latentAwakening(arr) {
if (!Array.isArray(arr) || !arr.every(n=>Number.isInteger(n)))
throw new TypeError("直接设定 潜在觉醒 应当为整形数组");
this.#latentAwakening.length = arr.length;
for (let i=0;i<arr.length;i++) {
this.#latentAwakening[i] = arr[i];
}
}
get needExp() {
const expArray = [
Math.round(valueAt(this.level, 99, this.card.exp)) //99级以内的经验
];
if (this.level > 99)
expArray.push(Math.max(0, Math.min(this.level, 110) - 100) * 5000000);
if (this.level > 110)
expArray.push(Math.max(0, Math.min(this.level, 120) - 110) * 20000000);
return expArray;
}
getWorkingAwakenings(states) {
const {outsideOfDungeon, awakningsBind, removeAssist, slotBind} = states;
if (slotBind) return [];
//封觉醒时,语音、心横仍然生效
const awaknings = this.card.awakenings.slice(0, this.awakening);
if (this.hasAssist && !removeAssist) //有武器并且没有禁武器时
awaknings.push(...this.assistMember.getAwakenings(states));
return awaknings;
}
getAbilities(states) {
const {outsideOfDungeon, awakningsBind, removeAssist, dungeonEnchance} = states;
const abilities = {
hp: {base: 0, plus: 0, assist: 0, awaknings: 0},
atk: {base: 0, plus: 0, assist: 0, awaknings: 0},
rcv: {base: 0, plus: 0, assist: 0, awaknings: 0},
}
return abilities;
}
}
class Card {
flags = 0;
id = 0;
name = null;
attrs = [];
types = [];
isUltEvo = false;
rarity = 0;
cost = 0;
maxLevel = 0;
feedExp = 0;
isEmpty = true;
sellPrice = 0;
hp = null;
atk = null;
rcv = null;
exp = null;
activeSkillId = 0;
leaderSkillId = 0;
enemy = null;
evoBaseId = null;
evoMaterials = [];
unevoMaterials = [];
awakenings = [];
superAwakenings = [];
evoRootId = 0;
seriesId = 0;
sellMP = 0;
latentAwakeningId = 0;
collabId = 0;
altName = [];
limitBreakIncr = 0;
voiceId = 0;
orbSkinOrBgmId = 0;
specialAttribute = null;
searchFlags = [];
#leaderSkillTypes = null;
gachaGroupsFlag = 0;
badgeId = 0;
syncAwakening = null;
syncAwakeningConditions = [];
unk01 = null;
unk02 = null;
unk03 = null;
unk04 = null;
unk05 = null;
unk06 = null;
unk07 = null;
unk08 = null;
static fixId(id, reverse = false){
if (id === 0xFFFF) return id;
return reverse ? (id >= 9900 ? id + 100 : id) : (id >= 10000 ? id - 100 : id);
}
constructor(data){
if (Array.isArray(data)) {
this.fromOfficialData(data);
} else {
const classPrototype = Card.prototype;
for (let key in data) {
const propertyDescriptor = Object.getOwnPropertyDescriptor(classPrototype, key);
if (propertyDescriptor &&
!propertyDescriptor.writable &&
!propertyDescriptor.set)
continue;
this[key] = data[key];
}
}
}
fromOfficialData(data) {
const e = data.entries();
function readCurve(entries) {
return {
min: entries.next().value?.[1],
max: entries.next().value?.[1],
scale: entries.next().value?.[1],
};
}
this.id = Card.fixId(e.next().value?.[1]); //ID
this.name = e.next().value?.[1]; //名字
this.attrs.push(e.next().value?.[1]); //属性1
this.attrs.push(e.next().value?.[1]); //属性2
this.isUltEvo = e.next().value?.[1] !== 0; //是否究极进化
this.types.push(e.next().value?.[1]); //类型1
this.types.push(e.next().value?.[1]); //类型2
this.rarity = e.next().value?.[1]; //星级
this.cost = e.next().value?.[1]; //cost
this.unk01 = e.next().value?.[1]; //未知01
this.maxLevel = e.next().value?.[1]; //最大等级
this.feedExp = e.next().value?.[1]; //1级喂食经验,需要除以4
this.isEmpty = e.next().value?.[1] === 1; //空卡片?
this.sellPrice = e.next().value?.[1]; //1级卖钱,需要除以10
this.hp = readCurve(e); //HP增长
this.atk = readCurve(e); //攻击增长
this.rcv = readCurve(e); //回复增长
this.exp = { min: 0, max: e.next().value?.[1], scale: e.next().value?.[1] }; //经验增长
this.activeSkillId = e.next().value?.[1]; //主动技
this.leaderSkillId = e.next().value?.[1]; //队长技
this.enemy = { //作为怪物的数值
countdown: e.next().value?.[1],
hp: readCurve(e),
atk: readCurve(e),
def: readCurve(e),
maxLevel: e.next().value?.[1],
coin: e.next().value?.[1],
exp: e.next().value?.[1],
skills: []
};
this.evoBaseId = Card.fixId(e.next().value?.[1]); //进化基础ID
this.evoMaterials.push(...([ //进化素材
e.next().value?.[1],
e.next().value?.[1],
e.next().value?.[1],
e.next().value?.[1],
e.next().value?.[1]
].map(n=>Card.fixId(n,false))));
this.unevoMaterials.push(...([ //退化素材
e.next().value?.[1],
e.next().value?.[1],
e.next().value?.[1],
e.next().value?.[1],
e.next().value?.[1]
].map(n=>Card.fixId(n,false))));
this.unk02 = e.next().value?.[1]; //未知02
this.unk03 = e.next().value?.[1]; //未知03
this.unk04 = e.next().value?.[1]; //未知04
this.unk05 = e.next().value?.[1]; //未知05
this.unk06 = e.next().value?.[1]; //未知06
this.unk07 = e.next().value?.[1]; //未知07
const numSkills = e.next().value?.[1]; //几种敌人技能
for (let si = 0; si < numSkills; si++) {
this.enemy.skills.push({
id: e.next().value?.[1],
ai: e.next().value?.[1],
rnd: e.next().value?.[1]
});
}
const numAwakening = e.next().value?.[1]; //觉醒个数
for (let ai = 0; ai < numAwakening; ai++) {
this.awakenings.push(e.next().value?.[1]);
}
this.superAwakenings.push(...(e.next().value?.[1].split(',').filter(Boolean).map(strN=>parseInt(strN,10)))); //超觉醒
this.evoRootId = Card.fixId(e.next().value?.[1]); //进化链根ID
this.seriesId = e.next().value?.[1]; //系列ID
this.types.push(e.next().value?.[1]); //类型3
this.sellMP = e.next().value?.[1]; //卖多少MP
this.latentAwakeningId = e.next().value?.[1]; //潜在觉醒ID
this.collabId = e.next().value?.[1]; //合作ID
this.flags = e.next().value?.[1];
this.altName.push(...e.next().value?.[1].split("|").filter(Boolean)); //替换名字(分类标签)
this.limitBreakIncr = e.next().value?.[1]; //110级增长
this.voiceId = e.next().value?.[1]; //语音觉醒的ID
this.orbSkinOrBgmId = e.next().value?.[1]; //珠子皮肤ID
this.specialAttribute = e.next().value?.[1]; //特别属性,比如黄龙
this.searchFlags.push(e.next().value?.[1], e.next().value?.[1]); //队长技搜索类型,解析写在这里会导致文件太大,所以写到前端去了
this.gachaGroupsFlag = e.next().value?.[1]; //目前猜测是桶ID
this.unk08 = e.next().value?.[1]; //未知08
this.attrs.push(e.next().value?.[1]); //属性3
this.badgeId = e.next().value?.[1]; //抽到后获取的徽章ID
this.syncAwakening = e.next().value?.[1]; //同步觉醒
const numSyncAkCondition = e.next().value?.[1]; //同步觉醒条件数量
for (let ci = 0; ci < numSyncAkCondition; ci++) {
this.syncAwakeningConditions.push({
id: Card.fixId(e.next().value?.[1]), //怪物ID
level: e.next().value?.[1], //怪物等级
skillLeval: e.next().value?.[1], //怪物技能等级
});
}
this.attrs = this.attrs.filter(n=>Number.isInteger(n) && n>=0);
this.types = this.types.filter(n=>Number.isInteger(n) && n>=0);
const last = e.next();
if (!last.done)
console.debug(`有新增数据/residue data for #%d: %o`, this.id , last.value);
}
get activeSkill(){
return Skills[this.activeSkillId];
}
get leaderSkill(){
return Skills[this.leaderSkillId];
}
get canAssist(){ //是否能当二技
return Boolean(this.flags & 1<<0);
}
get enabled(){ //是否已启用
return Boolean(this.flags & 1<<1);
}
get stackable(){ //flag有1<<3时,不合并占一格,没有时则根据类型进行合并(目前合并已经不占格子)
const specialType = [0,12,14,15];
return Boolean(this.flags & 1<<3) &&
this.types.some(t=>specialType.includes(t)); //0進化用;12能力覺醒用;14強化合成用;15販賣用默认合并
}
get onlyAssist(){ //是否只能当二技
return Boolean(this.flags & 1<<4);
}
get skillBanner(){ //是否支持8个潜觉
return Boolean(this.flags & 1<<5);
}
get onlyAssist(){ //是否有技能横幅
return Boolean(this.flags & 1<<6);
}
get leaderSkillTypes(){
if (this.#leaderSkillTypes == null) {
this.#leaderSkillTypes = new LeaderSkillType(this);
}
return this.#leaderSkillTypes;
}
}
//队长技能类型的翻译
class LeaderSkillType{
#card = null;
#flags = [];
#matchMode = null;
#restriction = null;
#appendEffects = null;
constructor(flags1, flags2){
if (flags1 instanceof Card || Array.isArray(flags1.searchFlags)) {
this.#card = flags1;
} else if (Array.isArray(flags1)) {
this.#flags.push(...flags1);
} else {
this.#flags.push(flags1, flags2);
}
}
get matchMode(){
if (this.#matchMode == null) {
this.#matchMode = new LeaderSkillType_MatchingStyle(this.#card ?? this.#flags);
}
return this.#matchMode;
}
get restriction(){
if (this.#restriction == null) {
this.#restriction = new LeaderSkillType_Restriction_Bind(this.#card ?? this.#flags);
}
return this.#restriction;
}
get appendEffects(){
if (this.#appendEffects == null) {
this.#appendEffects = new LeaderSkillType_ExtraEffects(this.#card ?? this.#flags);
}
return this.#appendEffects;
}
}
class LeaderSkillType_MatchingStyle {
#card = null;
#flags = [];
constructor(arg){
if (arg instanceof Card || Array.isArray(arg.searchFlags)) {
this.#card = arg;
} else {
this.#flags = arg;
}
}
get multipleAttr(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 0)}
get rowMatch(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 1)}
get combo(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 2)}
get sameColor(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 3)}
get LShape(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 4)}
get crossMatch(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 5)}
get heartCrossMatch(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 6)}
get remainOrbs(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 7)}
get enhanced5Orbs(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 8)}
}
class LeaderSkillType_Restriction_Bind {
#card = null;
#flags = [];
constructor(arg){
if (arg instanceof Card || Array.isArray(arg.searchFlags)) {
this.#card = arg;
} else {
this.#flags = arg;
}
}
get attrEnhance(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 9)}
get typeEnhance(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 10)}
get board7x6(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 11)}
get noSkyfall(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 12)}
get HpRange(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 13)}
get useSkill(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 14)}
get moveTimeDecrease_Fixed(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 15)}
get minMatchLen(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 16)}
get specialTeam(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 17)}
get effectWhenRecover(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 18)}
}
class LeaderSkillType_ExtraEffects {
#card = null;
#flags = [];
constructor(arg){
if (arg instanceof Card || Array.isArray(arg.searchFlags)) {
this.#card = arg;
} else {
this.#flags = arg;
}
}
get addCombo(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 21)}
get fixedFollowAttack(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 22)}
get scaleFollowAttack(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 23)}
get reduce49down(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 24)}
get reduce50(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 25)}
get reduce51up(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 26)}
get moveTimeIncrease(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 20)}
get rateMultiplyExp_Coin(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 27)}
get rateMultiplyDrop(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 28)}
get voidPoison(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 29)}
get counterAttack(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 30)}
get autoHeal(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 31)}
get unbindAwokenBind(){return Boolean(this.#card?.searchFlags?.[0] ?? this.#flags[0] & 1 << 19)}
get resolve(){return Boolean(this.#card?.searchFlags?.[1] ?? this.#flags[1] & 1 << 0)}
get predictionFalling(){return Boolean(this.#card?.searchFlags?.[1] ?? this.#flags[1] & 1 << 1)}
}
class Team extends Array {
badge = 0;
helperTeam = null;
switchesLeader = null;
constructor(memberCount = 6) {
super(memberCount);//建立 Array
}
get leader1(){
return this[0];
}
get leader2(){
//当有 helperTeam 时,使用另一个队伍的队长
return helperTeam instanceof Team ? this.helperTeam.leader1 : this[5];
}
}
class Formation2 {
teams = [];
title = null;
description = null;
dungeonEnchancement = {
attrs: [],
types: [],
rarities: [],
collabIds: [],
gachaIds: [],
rate: {
hp: 1,
atk: 1,
rcv: 1
},
benefitOfYinYang: 0,
currentStage: 0,
};
constructor(teamCount) {
this.teams.length = teamCount;
const menbersCount = teamCount === 2 ? 5 : 6;
for (let i=0; i<teamCount; i++) {
this.teams[i] = new Team(menbersCount);
}
if (teamCount === 2) { //当为2人对物时,互相设定为互助队伍
this.teams[0].helperTeam = this.teams[1];
this.teams[1].helperTeam = this.teams[0];
}
}
}
class Skill {
id = 0;
name = null;
description = null;
type = 0;
maxLevel = 0;
initialCooldown = 0;
unk = 0;
params = [];
#parsed = null;
constructor(data, i){
if (Array.isArray(data)) {
this.id = i;
this.fromOfficialData(data);
} else {
const classPrototype = Skill.prototype;
for (let key in data) {
const propertyDescriptor = Object.getOwnPropertyDescriptor(classPrototype, key);
if (propertyDescriptor &&
!propertyDescriptor.writable &&
!propertyDescriptor.set)
continue;
this[key] = data[key];
}
}
}
fromOfficialData(data) {
const e = data.entries();
this.name = e.next().value?.[1];
this.description = e.next().value?.[1];
this.type = e.next().value?.[1];
this.maxLevel = e.next().value?.[1];
this.initialCooldown = e.next().value?.[1];
this.unk = e.next().value?.[1];
let last = null;
while (last = e.next(), !last.done) {
this.params.push(last.value[1]);
}
}
get parsed() {
if (this.#parsed == null) {
this.#parsed = Skill.skillParser(this);
}
return this.#parsed;
}
static skillParser(skill) {
if (!(skill instanceof Skill)) throw new TypeError("传入的 技能 不是 Skill 类");
return skillParser(skill.id);
}
}
//队员基本的留空
var Member = function(id = 0) {
this.id = id;
this.ability = [0, 0, 0];
this.abilityNoAwoken = [0, 0, 0];
};
//让 Member 能直接获取 card
Object.defineProperty(Member.prototype, "card", {
get() { return Cards[this.id] ?? Cards[0]; }
})
Member.prototype.effectiveAwokens = function(assist) {
const memberCard = this.card;
let enableAwoken = memberCard?.awakenings?.slice(0, this.awoken) || [];
//单人、3人时,大于等于100级且297时增加超觉醒
if ((solo || teamsCount === 3) && this.sawoken > 0 &&
(this.level >= 100 && this.plus.every(p=>p>=99) ||
this.sawoken === memberCard.syncAwakening)
) {
enableAwoken.push(this.sawoken);
}
//添加武器
if (assist instanceof Member && assist?.card?.awakenings?.includes(49)) {
enableAwoken.push(...assist.card.awakenings.slice(0, assist.awoken));
}
return enableAwoken;
}
Member.prototype.getAttrsTypesWithWeapon = function(assist) {
let memberCard = this.card, assistCard = assist?.card,
assistAwakenings = assistCard?.awakenings?.slice(0, assist.awoken);
if (this.id <= 0 || !memberCard) return null; //跳过 id 0
let attrs = [...memberCard.attrs]; //属性数量固定,因此用固定的数组
let types = new Set(memberCard.types); //Type 用Set,确保不会重复
let changeAttr = null, appendTypes = [];
if (assistAwakenings?.includes(49)) { //如果有武器
//更改副属性
changeAttr = assistAwakenings.find(ak=>ak >= 91 && ak <= 95); //筛选出武器觉醒
if (changeAttr) attrs[1] = changeAttr - 91; //变换为属性
//添加类型
appendTypes = assistAwakenings.filter(ak=>ak >= 83 && ak <= 90) //筛选出武器觉醒
.map(type=> typekiller_for_type.find(t=>(type - 52) === t.awoken).type);//变换为类型
appendTypes = new Set(appendTypes); //变为 Set
appendTypes = appendTypes.difference(types); //去除重复的
types = types.union(appendTypes); //添加到类型里
}
return {
attrs, isChangeAttr: Boolean(changeAttr),
"types": [...types], isAppendType: Boolean(appendTypes?.size), "appendTypes": [...appendTypes]
};
}
Member.prototype.outObj = function() {
const m = this;
if (m.id == 0) return null;
let obj = [m.id];
if (m.level != undefined) obj[1] = m.level;
if (m.awoken != undefined) obj[2] = m.awoken;
if (m.plus != undefined && Array.isArray(m.plus) && m.plus.length >= 3 && (m.plus[0] + m.plus[1] + m.plus[2]) != 0) {
if (m.plus[0] === m.plus[1] && m.plus[0] === m.plus[2]) { //当3个加值一样时只生成第一个减少长度
obj[3] = m.plus[0];
} else {
obj[3] = m.plus;
}
}
if (Array.isArray(m?.latent) && m.latent.length >= 1) obj[4] = m.latent;
if (m?.sawoken >= 0) obj[5] = m.sawoken;
const card = Cards[m.id] || Cards[0]; //怪物固定数据
const skill = Skills[card.activeSkillId];
//有技能等级,并且技能等级低于最大等级时才记录技能
if (m.skilllevel != undefined && m.skilllevel < skill.maxLevel) obj[6] = m.skilllevel;
return obj;
};
Member.prototype.loadObj = function(m, dataVersion) {
if (m == undefined) //如果没有提供数据,直接返回默认
{
this.id = 0;
return;
}
if (dataVersion == undefined) dataVersion = 1;
this.id = dataVersion > 1 ? m[0] : m.id;
this.level = dataVersion > 1 ? m[1] : m.level;
this.awoken = dataVersion > 1 ? m[2] : m.awoken;
if (dataVersion > 1) {
if (isNaN(m[3]) || m[3] == null) {
this.plus = m[3];
} else {
const singlePlus = parseInt(m[3], 10); //如果只有一个数字时,复制3份
this.plus = [singlePlus, singlePlus, singlePlus];
}
} else {
this.plus = m.plus;
}
if (!Array.isArray(this.plus)) this.plus = [0, 0, 0]; //如果加值不是数组,则改变
this.latent = dataVersion > 1 ? m[4] : m.latent;
if (Array.isArray(this.latent) && dataVersion <= 2) this.latent = this.latent.map(l => l >= 13 ? l + 3 : l); //修复以前自己编的潜觉编号为官方编号
if (!Array.isArray(this.latent)) this.latent = []; //如果潜觉不是数组,则改变
this.sawoken = dataVersion > 1 ?
(dataVersion < 5 ?
Cards[this.id].superAwakenings[m[5]] //第四版前,是超觉醒的顺序
: m[5] ) //第5版开始,超觉醒使用觉醒编号而不是顺序
: m.sawoken;
this.skilllevel = m[6] || null;
};
Member.prototype.loadFromMember = function(m) {
if (m == undefined) //如果没有提供数据,直接返回默认
{
return;
}
this.id = m.id;
};
//只用来防坐的任何队员
var MemberDelay = function() {
this.id = -1;
};
MemberDelay.prototype = Object.create(Member.prototype);
MemberDelay.prototype.constructor = MemberDelay;
//辅助队员
var MemberAssist = function() {
this.level = 0;
this.awoken = 0;
this.plus = [0, 0, 0];
Member.call(this);
};
MemberAssist.prototype = Object.create(Member.prototype);
MemberAssist.prototype.constructor = MemberAssist;
MemberAssist.prototype.loadFromMember = function(m) {
if (m == undefined) //如果没有提供数据,直接返回默认
{
return;
}
this.id = m.id;
if (m.level != undefined) this.level = m.level;
if (m.awoken != undefined) this.awoken = m.awoken;
if (m.plus != undefined && Array.isArray(m.plus) && m.plus.length >= 3 && (m.plus[0] + m.plus[1] + m.plus[2]) > 0) this.plus = JSON.parse(JSON.stringify(m.plus));
if (m.skilllevel != undefined) this.skilllevel = m.skilllevel;
};
//正式队伍
var MemberTeam = function() {
this.latent = [];
MemberAssist.call(this);
//sawoken作为可选项目,默认不在内
};
MemberTeam.prototype = Object.create(MemberAssist.prototype);
MemberTeam.prototype.constructor = MemberTeam;
MemberTeam.prototype.loadFromMember = function(m) {
if (m == undefined) //如果没有提供数据,直接返回默认
{
return;
}
this.id = m.id;
if (m.level != undefined) this.level = m.level;
if (m.awoken != undefined) this.awoken = m.awoken;
if (Array.isArray(m?.plus) && m.plus.length >= 3 && (m.plus[0] + m.plus[1] + m.plus[2]) > 0) this.plus = JSON.parse(JSON.stringify(m.plus));
if (Array.isArray(m?.latent) && m.latent.length >= 1) this.latent = JSON.parse(JSON.stringify(m.latent));
if (m.sawoken != undefined) this.sawoken = m.sawoken;
if (Array.isArray(m?.ability) && m.ability.length >= 3) this.ability = JSON.parse(JSON.stringify(m.ability));
if (Array.isArray(m?.abilityNoAwoken) && m.abilityNoAwoken.length >= 3) this.abilityNoAwoken = JSON.parse(JSON.stringify(m.abilityNoAwoken));
if (m.skilllevel != undefined) this.skilllevel = m.skilllevel;
};
let Formation = function(teamCount, memberCount) {
this.title = "";
this.detail = "";
this.teams = [];
this.dungeonEnchance = {
attrs: [],
types: [],
rarities: [],
collabs: [],
gachas: [],
rate: {
hp: 1,
atk: 1,
rcv: 1
}
}
for (let ti = 0; ti < teamCount; ti++) {
const team = [
[], //队员
[], //辅助
0, //徽章
0, //队长更换序号
];
for (let mi = 0; mi < memberCount; mi++) {
team[0].push(new MemberTeam());
team[1].push(new MemberAssist());
}
this.teams.push(team);
}
};
//初始化队伍结构
let formation = new Formation(teamsCount, teamsCount == 2 ? 5 : 6);
Formation.prototype.outObj = function() {
const obj = {};
if (this?.title?.length > 0) obj.t = this.title;
if (this?.detail?.length > 0) obj.d = this.detail;
obj.f = this.teams.map(t => {
const teamArr = [];
teamArr[0] = t[0].map(m =>
m.outObj()
).deleteLatter();
teamArr[1] = t[1].map(m =>
m.outObj()
).deleteLatter();
if (t[2]) teamArr[2] = t[2];
if (t[3]) teamArr[3] = t[3];
return teamArr;
});
let dge = this.dungeonEnchance;
if (Object.values(dge.rate).some(rate => rate != 1) || dge.benefit || dge.stage>1) obj.r = [
[Bin.enflags(dge.types),Bin.enflags(dge.attrs),Bin.enflags(dge.rarities),dge.collabs.length ? dge.collabs : 0, Bin.enflags(dge.gachas)].deleteLatter(0), //类型,属性,星级
[dge.rate.hp,dge.rate.atk,dge.rate.rcv].deleteLatter(1),
dge.benefit || 0, //地下城阴阳加护
dge.stage || 1 //地下城层数
];
obj.v = dataStructure;
/*if (obj.f.every(team=>team[0].length == 0 && team[1].length == 0 && team[2] == undefined) &&
!obj.t &&
!obj.d)
return null;*/
return obj;
};
Formation.prototype.loadObj = function(f) {
let dge = this.dungeonEnchance;
if (f == undefined) //如果没有提供数据,要返回空的
{
this.title = "";
this.detail = "";
this.teams.forEach(function(t, ti) {
t[0].forEach(function(m, mi) {
m.loadObj(null);
});
t[1].forEach(function(m, mi) {
m.loadObj(null);
});
t[2] = 1;
t[3] = 0;
});
dge.rarities.length = 0;
dge.attrs.length = 0;
dge.types.length = 0;
dge.rate.hp = 1;
dge.rate.atk = 1;
dge.rate.rcv = 1;
dge.benefit = 0;
dge.stage = 1;
return;
}
const dataVeision = f?.v ?? (f.f ? 2 : 1); //是第几版格式
this.title = dataVeision > 1 ? f.t : f.title;
this.detail = dataVeision > 1 ? f.d : f.detail;
const loadTeamArr = dataVeision > 1 ? f.f : f.team;
this.teams.forEach(function(t, ti) {
const tf = loadTeamArr[ti];
if (tf) {
t[0].forEach(function(m, mi) {
const fm = tf[0][mi];
m.loadObj(fm, dataVeision);
});
t[1].forEach(function(m, mi) {
const fm = tf[1][mi];
m.loadObj(fm, dataVeision);
});
t[2] = dataVeision > 3 ? //徽章
(dataVeision < 5 && tf[2] == 50 ? PAD_PASS_BADGE : tf[2]) //5版开始月卡徽章用开关1<<7来识别
: badgeConvert(tf[2]); //1、2版老数据的徽章
t[3] = tf[3] ?? 0; //队长
}
});
function badgeConvert(old)
{
switch (old)
{
case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8: {
return old + 1;
}
case 9: {
return 11;
}
case 10:case 11:case 12: {
return old + 7;
}