forked from Nishisonic/UnexpectedDamage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnexpectedDamage.js
2395 lines (2282 loc) · 101 KB
/
UnexpectedDamage.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
//#region Library
Calendar = Java.type("java.util.Calendar")
TimeZone = Java.type("java.util.TimeZone")
DataType = Java.type("logbook.data.DataType")
AppConstants = Java.type("logbook.constants.AppConstants")
BattlePhaseKind = Java.type("logbook.dto.BattlePhaseKind")
EnemyShipDto = Java.type("logbook.dto.EnemyShipDto")
ShipDto = Java.type("logbook.dto.ShipDto")
Item = Java.type("logbook.internal.Item")
Ship = Java.type("logbook.internal.Ship")
//#endregion
//#region 全般
/** バージョン */
var VERSION = 1.51
/** バージョン確認URL */
var UPDATE_CHECK_URL = "https://raw.githubusercontent.com/Nishisonic/UnexpectedDamage/master/update2.txt"
/** ファイルの場所 */
var FILE_URL = [
"https://raw.githubusercontent.com/Nishisonic/UnexpectedDamage/master/drop_unexpectedDamage.js",
"https://raw.githubusercontent.com/Nishisonic/UnexpectedDamage/master/UnexpectedDamage.js",
"https://raw.githubusercontent.com/Nishisonic/UnexpectedDamage/master/dropstyle.js",
]
/** 保存場所 */
var EXECUTABLE_FILE = [
"script/drop_unexpectedDamage.js",
"script/UnexpectedDamage.js",
"script/dropstyle.js",
]
/** ログファイル保存の場所 */
var LOG_FILE = "damage.log"
/** ScriptData用 */
var data_prefix = "damage_"
var isAkakari = AppConstants.NAME.indexOf("赤仮") >= 0
//#endregion
//#region 艦これ計算部分
/**
* 昼戦火力算出
* @param {java.util.Date} date 戦闘日時
* @param {logbook.dto.BattlePhaseKind} kind 戦闘の種類
* @param {0|1|2|3} friendCombinedKind 自軍側連合種別(0=なし,1=機動,2=水上,3=輸送)
* @param {Boolean} isEnemyCombined 敵軍は連合艦隊か
* @param {Number} attackNum 攻撃側艦数(警戒陣用)
* @param {[number,number,number]} formation 昼戦[自軍陣形,敵軍陣形,交戦形態]
* @param {AttackDto} attack 攻撃データ
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} attacker 攻撃艦
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} defender 防御艦
* @param {ShipHpDto} attackerHp 攻撃艦Hp
* @param {Boolean} shouldUseSkilled 熟練度を使用すべきか
* @param {FleetDto} origins 攻撃側艦隊
* @return {AntiSubmarinePower|DayBattlePower} 昼戦火力
*/
var getDayBattlePower = function (date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp, shouldUseSkilled, origins) {
if (isSubMarine(defender)) {
// 対潜水艦
return new AntiSubmarinePower(date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp, shouldUseSkilled, origins)
} else {
// 対水上艦
return new DayBattlePower(date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp, shouldUseSkilled, origins)
}
}
/**
* 雷撃戦火力算出
* @param {java.util.Date} date 戦闘日時
* @param {logbook.dto.BattlePhaseKind} kind 戦闘の種類
* @param {0|1|2|3} friendCombinedKind 自軍側連合種別(0=なし,1=機動,2=水上,3=輸送)
* @param {Boolean} isEnemyCombined 敵軍は連合艦隊か
* @param {Number} attackNum 攻撃側艦数(警戒陣用)
* @param {[number,number,number]} formation 昼戦[自軍陣形,敵軍陣形,交戦形態]
* @param {AttackDto} attack 攻撃データ
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} attacker 攻撃艦
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} defender 防御艦
* @param {ShipHpDto} attackerHp 攻撃艦Hp
* @return {TorpedoPower} 雷撃火力
*/
var getTorpedoPower = function (date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp) {
return new TorpedoPower(date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp)
}
/**
* 夜戦火力算出
* @param {java.util.Date} date 戦闘日時
* @param {logbook.dto.BattlePhaseKind} kind 戦闘の種類
* @param {0|1|2|3} friendCombinedKind 自軍側連合種別(0=なし,1=機動,2=水上,3=輸送)
* @param {Boolean} isEnemyCombined 敵軍は連合艦隊か
* @param {Number} attackNum 攻撃側艦数(警戒陣用)
* @param {[number,number,number]} formation 夜戦[自軍陣形,敵軍陣形,交戦形態]
* @param {[Number,Number]} touchPlane 夜間触接
* @param {AttackDto} attack 攻撃データ
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} attacker 攻撃艦
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} defender 防御艦
* @param {ShipHpDto} attackerHp 攻撃艦Hp
* @param {Boolean} shouldUseSkilled 熟練度を使用すべきか
* @param {FleetDto} origins 攻撃側艦隊
* @return {AntiSubmarinePower|NightBattlePower} 夜戦火力
*/
var getNightBattlePower = function (date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, touchPlane, attack, attacker, defender, attackerHp, shouldUseSkilled, origins) {
if (isSubMarine(defender)) {
// 対潜水艦
return new AntiSubmarinePower(date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp, shouldUseSkilled, origins)
} else {
// 対水上艦
return new NightBattlePower(date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, touchPlane, attack, attacker, defender, attackerHp, shouldUseSkilled, origins)
}
}
/**
* レーダー射撃戦火力算出
* @param {java.util.Date} date 戦闘日時
* @param {logbook.dto.BattlePhaseKind} kind 戦闘の種類
* @param {0|1|2|3} friendCombinedKind 自軍側連合種別(0=なし,1=機動,2=水上,3=輸送)
* @param {Boolean} isEnemyCombined 敵軍は連合艦隊か
* @param {Number} attackNum 攻撃側艦数(警戒陣用)
* @param {[number,number,number]} formation レーダー射撃戦[自軍陣形,敵軍陣形,交戦形態]
* @param {AttackDto} attack 攻撃データ
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} attacker 攻撃艦
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} defender 防御艦
* @param {ShipHpDto} attackerHp 攻撃艦Hp
* @param {Boolean} shouldUseSkilled 熟練度を使用すべきか
* @param {FleetDto} origins 攻撃側艦隊
* @return {AntiSubmarinePower|NightBattlePower} 夜戦火力
*/
var getRadarShootingPower = function (date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp, shouldUseSkilled, origins) {
if (isSubMarine(defender)) {
// 対潜水艦
return new AntiSubmarinePower(date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp, shouldUseSkilled, origins, true)
} else {
// 対水上艦
return new NightBattlePower(date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, [-1, -1], attack, attacker, defender, attackerHp, shouldUseSkilled, origins)
}
}
/**
* 昼戦の攻撃種別
* BattleMain.setOptionsAtHougeki(slotitemMasterIDs:Array, type:int) に準ずる
* @param {AttackDto} attack 攻撃データ
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} attacker 攻撃艦
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} defender 防御艦
* @return {0|1|2|3} 攻撃手段(0=砲撃,1=空撃,2=爆雷,3=雷撃)
*/
var getAttackTypeAtDay = function (attack, attacker, defender) {
// ロケットフラグ判定
// 大発エフェクトid取得
if (attacker.shipId === 352) {
if (isSubMarine(defender)) {
if (getItems(attacker).some(function (item) { return item.type2 === 8 && item.param.taisen > 0 || item.type2 === 7 || item.type2 === 25 })) {
return 1
} else {
return 2
}
} else if (getItems(attacker).some(function (item) { return item.type2 === 8 })) {
return 1
} else {
return 0
}
}
if (attacker.stype === 7 || attacker.stype === 11 || attacker.stype === 18) {
return 1
}
if (isSubMarine(defender)) {
if (attacker.stype === 6 || attacker.stype === 10 || attacker.stype === 16 || attacker.stype === 17) {
return 1
} else {
return 2
}
}
if (Number(attack.showItem[0]) !== -1 && (Item.get(attack.showItem[0]).type2 === 5 || Item.get(attack.showItem[0]).type2 === 32)) {
return 3
}
return 0
}
/**
* 夜戦の攻撃種別
* BattleMain.setOptionsAtNight(slotitemMasterIDs:Array, specialFlag:int, yasen_kubo:Boolean) に準ずる
* @param {AttackDto} attack 攻撃データ
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} attacker 攻撃艦
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} defender 防御艦
* @return {0|1|2|3} 攻撃手段(0=砲撃,1=空撃,2=爆雷,3=雷撃)
*/
var getAttackTypeAtNight = function (attack, attacker, defender) {
// ロケットフラグ判定
// 大発エフェクトid取得
// 夜戦空母攻撃判定
if (attacker.stype === 7) {
if (isSubMarine(defender)) {
return 2
}
}
if (attacker.stype === 7 || attacker.stype === 11 || attacker.stype === 18) {
if (attacker.shipId === 353 || attacker.shipId === 432 || attacker.shipId === 433) {
return 0
} else if (attacker.name === "リコリス棲姫") {
return 0
} else if (attacker.name === "深海海月姫") {
return 0
} else {
return 1
}
}
if (isSubMarine(attacker)) {
return 3
}
if (isSubMarine(defender)) {
if (attacker.stype === 6 || attacker.stype === 10 || attacker.stype === 16 || attacker.stype === 17) {
return 1
} else {
return 2
}
}
if (Number(attack.showItem[0]) !== -1 && (Item.get(attack.showItem[0]).type2 === 5 || Item.get(attack.showItem[0]).type2 === 32)) {
return 3
}
return 0
}
/**
* 潜水艦かどうか
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} ship 艦
* @return {boolean} 潜水艦か
*/
var isSubMarine = function (ship) {
return ship.stype === 13 || ship.stype === 14
}
/**
* 陸上型かどうか(艦これの書き方)
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} ship 艦
* @return {boolean} 陸上型か
*/
var isGround = function (ship) {
return ship.param.soku <= 0
}
/**
* 艦の装備を取得する(補強増設装備も取得)
* その際、積んでいないスロは削除される
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} ship 艦
* @return {[logbook.dto.ItemDto]} 装備
*/
var getItems = function (ship) {
var items = Java.from(ship.item2.toArray())
if (ship instanceof ShipDto) items.push(ship.slotExItem)
return items.filter(function (item) { return item !== null })
}
//#region 対潜関連
/**
* 対潜関連処理
* @param {java.util.Date} date 戦闘日時
* @param {logbook.dto.BattlePhaseKind} kind 戦闘の種類
* @param {0|1|2|3} friendCombinedKind 自軍側連合種別(0=なし,1=機動,2=水上,3=輸送)
* @param {Boolean} isEnemyCombined 敵軍は連合艦隊か
* @param {Number} attackNum 攻撃側艦数(警戒陣用)
* @param {[number,number,number]} formation 昼戦[自軍陣形,敵軍陣形,交戦形態]
* @param {AttackDto} attack 攻撃データ
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} attacker 攻撃艦
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} defender 防御艦
* @param {ShipHpDto} attackerHp 攻撃艦Hp
* @param {FleetDto} origins 攻撃側艦隊
* @param {Boolean} shouldUseSkilled 熟練度を使用すべきか
* @param {Boolean} isRadarShooting レーダー射撃戦か(default=false)
*/
var AntiSubmarinePower = function (date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp, shouldUseSkilled, origins, isRadarShooting) {
this.date = date
this.kind = kind
this.friendCombinedKind = friendCombinedKind
this.isEnemyCombined = isEnemyCombined
this.attackNum = attackNum
this.formation = formation
this.attack = attack
this.attacker = attacker
this.defender = defender
this.attackerHp = attackerHp
this.items = getItems(attacker)
this.shouldUseSkilled = shouldUseSkilled
this.origins = origins
this.isRadarShooting = !!isRadarShooting
/**
* キャップ値
* ~2017/11/10 17:07?:100
* 2017/11/10 17:07?~:150
*/
this.CAP_VALUE = getJstDate(2017, 11, 10, 17, 7, 0).before(this.date) ? 150 : 100
}
/**
* 対潜火力(基本攻撃力)を返します
* @return {Number} 対潜火力(基本攻撃力)
*/
AntiSubmarinePower.prototype.getBasePower = function () {
// レーダー射撃戦専用処理
if (this.isRadarShooting) {
return Math.sqrt(this.attacker.raisou) * 2
}
// フィットボーナス
var equipmentBonus = function (date, attacker, items) {
var BONUS_LIST = {
// 大鷹
526: {
82: {param:1, date: getJstDate(2018, 8, 30, 18, 0, 0)}, // 九七式艦攻(九三一空)
302: {param:1, date: getJstDate(2018, 8, 30, 18, 0, 0)}, // 九七式艦攻(九三一空/熟練)
305: {param:1, date: getJstDate(2018, 8, 30, 18, 0, 0)}, // Ju87C改二(KMX搭載機)
306: {param:1, date: getJstDate(2018, 8, 30, 18, 0, 0)}, // Ju87C改二(KMX搭載機/熟練)
},
380: 526, // 大鷹改
529: 526, // 大鷹改二
// 神鷹
534: {
82: 1, // 九七式艦攻(九三一空)
302: 1, // 九七式艦攻(九三一空/熟練)
305: 3, // Ju87C改二(KMX搭載機)
306: 3, // Ju87C改二(KMX搭載機/熟練)
},
// 神鷹改
381: 534,
// 神鷹改二
536: 534,
// 神風
471: {
47: {param: 3, date: getJstDate(2019, 1, 22, 12, 0, 0)} // 三式水中探信儀
},
476: 471, // 神風改
473: 471, // 春風
363: 471, // 春風改
43: 471, // 時雨
243: 471, // 時雨改
145: 471, // 時雨改二
457: 471, // 山風
369: 471, // 山風改
122: 471, // 舞風
294: 471, // 舞風改
425: 471, // 朝霜
344: 471, // 朝霜改
// 潮
16: {
47: {param: 2, date: getJstDate(2019, 1, 22, 12, 0, 0)} // 三式水中探信儀
},
233: 16, // 潮改
407: 16, // 潮改二
36: 16, // 雷
236: 16, // 雷改
414: 16, // 山雲
328: 16, // 山雲改
167: 16, // 磯風
320: 16, // 磯風改
557: 16, // 磯風乙改
170: 16, // 浜風
312: 16, // 浜風改
558: 16, // 浜風乙改
527: 16, // 岸波
686: 16, // 岸波改
// 伊勢改二
553: {
322: 1, // 瑞雲改二(六三四空)
323: 2, // 瑞雲改二(六三四空/熟練)
324: 1, // オ号観測機改
325: 2, // オ号観測機改二
326: 2, // S-51J
327: 3, // S-51J改
},
// 日向改二
554: {
322: 1, // 瑞雲改二(六三四空)
323: 2, // 瑞雲改二(六三四空/熟練)
324: 1, // オ号観測機改
325: 2, // オ号観測機改二
326: 3, // S-51J
327: 4, // S-51J改
},
ctype: {
// 球磨型
4: {
304: 1, // S9 Osprey
},
// 川内型
16: 4,
// 長良型
20: 4,
// 阿賀野型
41: 4,
// Gotland級
89: {
304: 2, // S9 Osprey
},
},
}
if (BONUS_LIST[attacker.shipId]) {
var bonus = isNaN(BONUS_LIST[attacker.shipId]) ? BONUS_LIST[attacker.shipId] : BONUS_LIST[BONUS_LIST[attacker.shipId]]
return items.filter(function (item) {
return bonus[item.slotitemId]
}).filter(function (item) {
return isNaN(bonus[item.slotitemId]) ? bonus[item.slotitemId].date.before(date) : true
}).map(function (item) {
return isNaN(bonus[item.slotitemId]) ? bonus[item.slotitemId].param : bonus[item.slotitemId]
}).reduce(function (p, param) {
return p + param
}, 0)
}
else {
var ctype = Ship.get(attacker.shipId).json.getJsonNumber("api_ctype").intValue()
if (BONUS_LIST.ctype[ctype]) {
var bonus = isNaN(BONUS_LIST.ctype[ctype]) ? BONUS_LIST.ctype[ctype] : BONUS_LIST.ctype[BONUS_LIST.ctype[ctype]]
return items.filter(function (item) {
return bonus[item.slotitemId]
}).filter(function (item) {
return isNaN(bonus[item.slotitemId]) ? bonus[item.slotitemId].date.before(date) : true
}).map(function (item) {
return isNaN(bonus[item.slotitemId]) ? bonus[item.slotitemId].param : bonus[item.slotitemId]
}).reduce(function (p, param) {
return p + param
}, 0)
}
}
return 0
}(this.date, this.attacker, this.items)
var taisenShip = this.attacker.taisen - this.attacker.slotParam.taisen - equipmentBonus
var taisenItem = this.items.map(function (item) {
switch (item.type2) {
case 7: // 艦上爆撃機
case 8: // 艦上攻撃機
case 11: // 水上爆撃機
case 14: // ソナー
case 15: // 爆雷
case 25: // オートジャイロ
case 26: // 対潜哨戒機
case 40: // 大型ソナー
return item.param.taisen
default:
return 0
}
}).reduce(function (prev, current) {
return prev + current
}, 0)
return Math.sqrt(taisenShip) * 2 + taisenItem * 1.5 + this.getImprovementBonus() + this.getShipTypeConstant()
}
/**
* 対潜改修火力を返します
* @return {Number} 対潜改修火力
*/
AntiSubmarinePower.prototype.getImprovementBonus = function () {
return this.items.map(function (item) {
switch (item.type2) {
case 14: // ソナー
case 15: // 爆雷
return Math.sqrt(item.level)
case 25: // 回転翼機
return 0.3 * item.level
default:
return 0
}
}).reduce(function (prev, current) {
return prev + current
}, 0)
}
/**
* 対潜艦種別定数を返します
* @return {8|13} 対潜艦種別定数
*/
AntiSubmarinePower.prototype.getShipTypeConstant = function () {
if (isSubMarine(this.defender)) {
if (!this.attack.kind.isNight()) {
if (getAttackTypeAtDay(this.attack, this.attacker, this.defender) === 1) {
return 8
} else {
return 13
}
} else {
if (getAttackTypeAtNight(this.attack, this.attacker, this.defender) === 1) {
return 8
} else {
return 13
}
}
} else {
return 0
}
}
/**
* 対潜シナジー倍率を取得します
* @return {Number} 対潜シナジー倍率
*/
AntiSubmarinePower.prototype.getSynergyBonus = function () {
// 旧型シナジー
var synergy1 = (this.items.some(function (item) { return item.type3 === 18 })
&& this.items.some(function (item) { return item.type3 === 17 })) ? 1.15 : 1
// 新型シナジー
var synergy2 = 1
if (this.items.some(function (item) { return item.slotitemId === 44 || item.slotitemId === 45 })
&& this.items.some(function (item) { return item.slotitemId === 226 || item.slotitemId === 227 })) {
if (this.items.some(function (item) { return item.type2 === 14 })) {
// 小型ソナー/爆雷投射機/爆雷シナジー
synergy2 = 1.25
} else {
// 爆雷投射機/爆雷シナジー
synergy2 = 1.1
}
}
return synergy1 * synergy2
}
/**
* 対潜火力(キャップ前)を返します
* @return {Number} 対潜火力(キャップ前)
*/
AntiSubmarinePower.prototype.getBeforeCapPower = function () {
return this.getBasePower() * getFormationMatchBonus(this.formation) * this.getFormationBonus() * this.getConditionBonus() * this.getSynergyBonus()
}
/**
* 対潜火力(キャップ後)を返します
* @return {[Number,Number]} 対潜火力(キャップ後)
*/
AntiSubmarinePower.prototype.getAfterCapPower = function () {
var v = Math.floor(getAfterCapValue(this.getBeforeCapPower(), this.CAP_VALUE)) * getCriticalBonus(this.attack)
var s = this.shouldUseSkilled ? getSkilledBonus(this.date, this.attack, this.attacker, this.defender, this.attackerHp) : [1.0, 1.0]
return [Math.floor(v * s[0]), Math.floor(v * s[1])]
}
/**
* 対潜陣形補正を返します
* @return {Number} 倍率
*/
AntiSubmarinePower.prototype.getFormationBonus = function () {
var CHANGE_ECHELON_BONUS_DATE = getJstDate(2019, 2, 27, 12, 0, 0)
switch (Number(this.formation[this.attack.friendAttack ? 0 : 1])) {
case FORMATION.LINE_AHEAD: return 0.6
case FORMATION.DOUBLE_LINE: return 0.8
case FORMATION.DIAMOND: return 1.2
case FORMATION.ECHELON: return CHANGE_ECHELON_BONUS_DATE.before(this.date) ? 1.1 : 1.0
case FORMATION.LINE_ABREAST: return 1.3
case FORMATION.VANGUARD: return this.attack.attacker < Math.floor(this.attackNum / 2) ? 1.0 : 0.6
case FORMATION.CRUISING_FORMATION_1: return 1.3
case FORMATION.CRUISING_FORMATION_2: return 1.1
case FORMATION.CRUISING_FORMATION_3: return 1.0
case FORMATION.CRUISING_FORMATION_4: return 0.7
default: return 1.0
}
}
/**
* 損傷補正を返します
* @return {Number} 倍率
*/
AntiSubmarinePower.prototype.getConditionBonus = function () {
if (this.attackerHp.isBadlyDamage()) {
return 0.4
} else if (this.attackerHp.isHalfDamage()) {
return 0.7
} else {
return 1.0
}
}
//#endregion
//#region 昼砲撃関連
/**
* 昼砲撃関連処理
* @param {java.util.Date} date 戦闘日時
* @param {logbook.dto.BattlePhaseKind} kind 戦闘の種類
* @param {0|1|2|3} friendCombinedKind 自軍側連合種別(0=なし,1=機動,2=水上,3=輸送)
* @param {Boolean} isEnemyCombined 敵軍は連合艦隊か
* @param {Number} attackNum 攻撃側艦数(警戒陣用)
* @param {[number,number,number]} formation 昼戦[自軍陣形,敵軍陣形,交戦形態]
* @param {AttackDto} attack 攻撃データ
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} attacker 攻撃艦
* @param {logbook.dto.ShipDto|logbook.dto.EnemyShipDto} defender 防御艦
* @param {ShipHpDto} attackerHp 攻撃艦Hp
* @param {Boolean} shouldUseSkilled 熟練度を使用すべきか
* @param {FleetDto} origins 攻撃側艦隊
*/
var DayBattlePower = function (date, kind, friendCombinedKind, isEnemyCombined, attackNum, formation, attack, attacker, defender, attackerHp, shouldUseSkilled, origins) {
this.date = date
this.kind = kind
this.friendCombinedKind = friendCombinedKind
this.isEnemyCombined = isEnemyCombined
this.attackNum = attackNum
this.formation = formation
this.attack = attack
this.attacker = attacker
this.defender = defender
this.attackerHp = attackerHp
this.items = getItems(attacker)
this.shouldUseSkilled = shouldUseSkilled
this.origins = origins
this.CAP_VALUE = getJstDate(2017, 3, 17, 12, 0, 0).before(this.date) ? 180 : 150
}
/**
* 昼砲撃火力(基本攻撃力)を返します
* @return {Number} 昼砲撃火力(基本攻撃力)
*/
DayBattlePower.prototype.getBasePower = function () {
// 空撃または陸上型かつ艦上爆撃機,艦上攻撃機,陸上攻撃機,噴式戦闘爆撃機,噴式攻撃機所持時?
if (getAttackTypeAtDay(this.attack, this.attacker, this.defender) === 1 || isGround(this.attacker) && this.items.some(function (item) { return item.type2 === 7 || item.type2 === 8 || item.type2 === 47 || item.type2 === 57 || item.type2 === 58 })) {
// 空撃
var rai = this.attacker.slotParam.raig
var baku = this.attacker.slotParam.baku
if (isGround(this.defender)) {
rai = 0
if (getJstDate(2019, 3, 27, 12, 0, 0).before(this.date)) {
baku = this.items.filter(function (item) {
// Ju87C改
// 試製南山
// F4U-1D
// FM-2
// Ju87C改二(KMX搭載機)
// Ju87C改二(KMX搭載機/熟練)
// 彗星一二型(六三四空/三号爆弾搭載機)
return [64, 148, 233, 277, 305, 306, 319].indexOf(item.slotitemId) >= 0
}).reduce(function(p, v) {
return p + v.param.baku
}, 0)
}
}
return Math.floor((this.attacker.karyoku + rai + Math.floor(baku * 1.3) + this.getImprovementBonus() + this.getCombinedPowerBonus()) * 1.5) + 55
} else {
// 砲撃
return this.attacker.karyoku + this.getImprovementBonus() + this.getCombinedPowerBonus() + 5
}
}
/**
* 昼砲撃改修火力を返します
* @return {Number} 昼砲撃改修火力
*/
DayBattlePower.prototype.getImprovementBonus = function () {
var CHANGE_SUB_GUN_BONUS_DATE = getJstDate(2017, 3, 17, 12, 0, 0)
var RECHANGE_SUB_GUN_BONUS_DATE = getJstDate(2017, 5, 2, 12, 0, 0)
return this.items.map(function (item) {
var _getimprovementBonus = function () {
switch (item.type2) {
case 1: return 1 // 小口径主砲
case 2: return 1 // 中口径主砲
case 3: return 1.5 // 大口径主砲
case 38: return 1.5 // 大口径主砲(II)
case 4: return 1 // 副砲
case 19: return 1 // 対艦強化弾
case 36: return 1 // 高射装置
case 29: return 1 // 探照灯
case 42: return 1 // 大型探照灯
case 21: return 1 // 機銃
case 15: // 爆雷(投射機)
return item.slotitemId === 44 || item.slotitemId === 45 ? 0.75 : 0
case 14: return 0.75 // ソナー
case 40: return 0.75 // 大型ソナー
case 24: return 1 // 上陸用舟艇
case 46: return 1 // 特二式内火艇
case 18: return 1 // 三式弾
default: return 0
}
}
// 副砲
if (item.type2 === 4) {
// 2017/3/17~2017/5/2
if (CHANGE_SUB_GUN_BONUS_DATE.before(this.date) && RECHANGE_SUB_GUN_BONUS_DATE.after(this.date)) {
switch (item.type3) {
case 4: return 0.3 * item.level // (黄色)副砲
case 16: return 0.2 * item.level // (緑)高角副砲
}
} else {
switch (item.slotitemId) {
case 10: // 12.7cm連装高角砲
case 66: // 8cm高角砲
case 220: // 8cm高角砲改+増設機銃
case 275: // 10cm連装高角砲改+増設機銃
return 0.2 * item.level
case 12: // 15.5cm三連装副砲
case 234: // 15.5cm三連装副砲改
case 247: // 15.2cm三連装砲
return 0.3 * item.level
}
}
}
return _getimprovementBonus() * Math.sqrt(item.level)
}, this).reduce(function (prev, current) {
return prev + current
}, 0)
}
/**
* 昼砲撃火力(キャップ前)を返します
* @return {Number} 昼砲撃火力(キャップ前)
*/
DayBattlePower.prototype.getBeforeCapPower = function () {
var landBonus = getLandBonus(this.attacker, this.defender)
return ((this.getBasePower() + landBonus.b12) * landBonus.multi + getWg42Bonus(this.attacker, this.defender) + landBonus.add) * getFormationMatchBonus(this.formation) * this.getFormationBonus() * this.getConditionBonus() + getOriginalGunPowerBonus(this.attacker)
}
/**
* 昼砲撃火力(キャップ後)を返します
* @return {[Number,Number]} 昼砲撃火力(キャップ後)
*/
DayBattlePower.prototype.getAfterCapPower = function () {
// サイレント修正(Twitterで確認した限りでは17/9/9が最古=>17夏イベ?)以降、集積地棲姫特効のキャップ位置が変化(a5→a6)
// 17夏以降に登場したPT小鬼群の特効位置もa6に変化?(乗算と加算組み合わせているっぽいので詳細不明)
// A = [[キャップ後攻撃力] * 乗算特効補正 + 加算特効補正] * 弾着観測射撃 * 戦爆連合カットイン攻撃
var value = Math.floor(Math.floor(getAfterCapValue(this.getBeforeCapPower(), this.CAP_VALUE)) * getMultiplySlayerBonus(this.attacker, this.defender) + getAddSlayerBonus(this.attacker, this.defender)) * this.getSpottingBonus() * this.getUnifiedBombingBonus()
// 徹甲弾補正判定
if (this.isAPshellBonusTarget()) {
// A = [A * 徹甲弾補正]
value = Math.floor(value * this.getAPshellBonus())
}
// クリティカル判定
if (isCritical(this.attack)) {
// A = [A * クリティカル補正 * 熟練度補正]
value *= getCriticalBonus(this.attack)
var skilled = this.shouldUseSkilled ? getSkilledBonus(this.date, this.attack, this.attacker, this.defender, this.attackerHp) : [1.0, 1.0]
return [Math.floor(value * skilled[0]), Math.floor(value * skilled[1])]
}
return [value, value]
}
/**
* 昼砲撃陣形補正を返します
* @return {Number} 倍率
*/
DayBattlePower.prototype.getFormationBonus = function () {
var CHANGE_ECHELON_BONUS_DATE = getJstDate(2019, 2, 27, 12, 0, 0)
switch (Number(this.formation[this.attack.friendAttack ? 0 : 1])) {
case FORMATION.LINE_AHEAD: return 1.0
case FORMATION.DOUBLE_LINE: return 0.8
case FORMATION.DIAMOND: return 0.7
case FORMATION.ECHELON: return CHANGE_ECHELON_BONUS_DATE.before(this.date) ? 0.75 : 0.6
case FORMATION.LINE_ABREAST: return 0.6
case FORMATION.VANGUARD: return this.attack.attacker < Math.floor(this.attackNum / 2) ? 0.5 : 1.0
case FORMATION.CRUISING_FORMATION_1: return 0.8
case FORMATION.CRUISING_FORMATION_2: return 1.0
case FORMATION.CRUISING_FORMATION_3: return 0.7
case FORMATION.CRUISING_FORMATION_4: return 1.1
default: return 1.0
}
}
/**
* 損傷補正を返します
* @return {Number} 倍率
*/
DayBattlePower.prototype.getConditionBonus = function () {
if (this.attackerHp.isBadlyDamage()) {
return 0.4
} else if (this.attackerHp.isHalfDamage()) {
return 0.7
} else {
return 1.0
}
}
/**
* 徹甲弾補正を返す
* @return {Number} 倍率
*/
DayBattlePower.prototype.getAPshellBonus = function () {
if (this.isAPshellBonusTarget()) {
var mainGun = this.items.some(function (item) { return item.type1 === 1 })
var subGun = this.items.some(function (item) { return item.type1 === 2 })
var apShell = this.items.some(function (item) { return item.type1 === 25 })
var radar = this.items.some(function (item) { return item.type1 === 8 })
if (mainGun && apShell) {
if (subGun) return 1.15
if (radar) return 1.1
return 1.08
}
}
return 1.0
}
/**
* 徹甲弾補正対象か
* @return {Boolean} 対象か
*/
DayBattlePower.prototype.isAPshellBonusTarget = function () {
switch (this.defender.stype) {
case 5: // 重巡洋艦
case 6: // 航空巡洋艦
case 8: // 巡洋戦艦
case 9: // 戦艦
case 10: // 航空戦艦
case 11: // 正規空母
case 12: // 超弩級戦艦
case 18: // 装甲空母
return true
default:
return false
}
}
/**
* 弾着補正を返す
* @return {Number} 倍率
*/
DayBattlePower.prototype.getSpottingBonus = function () {
var ADD_ITEM_BONUS_DATE = getJstDate(2018, 12, 7, 12, 0, 0)
var UPDATE_SPECIAL_ATTACK_BONUS_DATE = getJstDate(2019, 2, 27, 12, 0, 0)
switch (Number(this.attack.attackType)) {
case 0: return 1.0 // 通常攻撃
case 1: return 1.0 // レーザー攻撃
case 2: return 1.2 // 連撃
case 3: return 1.1 // 主砲+副砲
case 4: return 1.2 // 主砲+電探
case 5: return 1.3 // 主砲+徹甲弾
case 6: return 1.5 // 主砲+主砲
//case 7: return 1.0 // 戦爆連合CI
case 100: return Number(this.formation[2]) === 4 ? 2.5 : 2.0 // Nelson Touch(≠弾着攻撃)
case 101: // 一斉射かッ…胸が熱いな!
var secondShipId = this.origins[this.attack.mainAttack ? "main" : "escort"][1].shipId
var base = this.attack.attackNum < 3 ? 1.4 : 1.2
var secondShipBonus = function(date, secondShipId, attackNum){
if (attackNum < 3) {
switch (secondShipId) {
case 573: return 1.2 // 陸奥改二
case 276: return 1.15 // 陸奥改
case 576: return UPDATE_SPECIAL_ATTACK_BONUS_DATE.before(date) ? 1.1 : 1.0 // Nelson改
}
} else {
switch (secondShipId) {
case 573: return 1.4 // 陸奥改二
case 276: return 1.35 // 陸奥改
case 576: return UPDATE_SPECIAL_ATTACK_BONUS_DATE.before(date) ? 1.25 : 1.0 // Nelson改
}
}
return 1.0
}(this.date, secondShipId, this.attack.attackNum)
var itemBonus = function(date, items) {
if (ADD_ITEM_BONUS_DATE.after(date)) return 1
var surfaceRadarBonus = items.some(function(item) {
return item.type3 === 11 && item.param.saku >= 5
}) ? 1.15 : 1
var apShellBonus = items.some(function(item) {
return item.type3 === 13
}) ? 1.35 : 1
return surfaceRadarBonus * apShellBonus
}(this.date, !this.attack.lastAttack ? this.items : getItems(this.origins[this.attack.mainAttack ? "main" : "escort"][1]))
return base * secondShipBonus * itemBonus
case 102: // 長門、いい? いくわよ! 主砲一斉射ッ!
var secondShipId = this.origins[this.attack.mainAttack ? "main" : "escort"][1].shipId
var base = this.attack.attackNum < 3 ? 1.4 : 1.2
var secondShipBonus = function(secondShipId, attackNum){
if (attackNum < 3) {
switch (secondShipId) {
case 541: return 1.2 // 長門改二
}
} else {
switch (secondShipId) {
case 541: return 1.4 // 長門改二
}
}
return 1.0
}(secondShipId, this.attack.attackNum)
var itemBonus = function(items) {
var surfaceRadarBonus = items.some(function(item) {
return item.type3 === 11 && item.param.saku >= 5
}) ? 1.15 : 1
var apShellBonus = items.some(function(item) {
return item.type3 === 13
}) ? 1.35 : 1
return surfaceRadarBonus * apShellBonus
}(!this.attack.lastAttack ? this.items : getItems(this.origins[this.attack.mainAttack ? "main" : "escort"][1]))
return base * secondShipBonus * itemBonus
case 103: // Colorado 特殊攻撃
var secondShipId = this.origins[this.attack.mainAttack ? "main" : "escort"][1].shipId
var thirdShipId = this.origins[this.attack.mainAttack ? "main" : "escort"][2].shipId
var base = this.attack.attackNum === 1 ? 1.3 : 1.15
var companionShipBonus = function (secondShipId, thirdShipId, attackNum) {
var isBig7 = function(shipId){
switch (shipId) {
case 80: // 長門
case 275: // 長門改
case 541: // 長門改二
case 81: // 陸奥
case 276: // 陸奥改
case 573: // 陸奥改二
case 571: // Nelson
case 576: // Nelson改
return true
}
return false
}
switch (attackNum) {
case 2:
return isBig7(secondShipId) ? 1.1 : 1
case 3:
return isBig7(thirdShipId) ? 1.15 * (isBig7(secondShipId) ? 1.1 : 1) : 1
}
return 1
}(secondShipId, thirdShipId)
var itemBonus = function(items) {
var surfaceRadarBonus = items.some(function(item) {
return item.type3 === 11 && item.param.saku >= 5
}) ? 1.15 : 1
var apShellBonus = items.some(function(item) {
return item.type3 === 13
}) ? 1.35 : 1
return surfaceRadarBonus * apShellBonus
}(!this.attack.lastAttack ? this.items : getItems(this.origins[this.attack.mainAttack ? "main" : "escort"][1]))
return base * companionShipBonus * itemBonus
case 200: return 1.35 // 瑞雲立体攻撃
case 201: return 1.3 // 海空立体攻撃
default: return 1.0 // それ以外
}
}
/**
* 戦爆連合CI補正を返す
* @return {Number} 倍率
*/
DayBattlePower.prototype.getUnifiedBombingBonus = function () {
if (Number(this.attack.attackType) === 7) {
var type2list = Java.from(this.attack.showItem).map(function (id) { return Item.get(Number(id)).type2 })
var fighter = type2list.filter(function (type2) { return type2 === 6 }).length
var bomber = type2list.filter(function (type2) { return type2 === 7 }).length
var attacker = type2list.filter(function (type2) { return type2 === 8 }).length
if (fighter === 1 && bomber === 1 && attacker === 1) {
return 1.25
} else if (bomber === 2 && attacker === 1) {
return 1.2
} else if (bomber === 1 && attacker === 1) {
return 1.15
}
}
return 1
}
/**
* 連合艦隊補正を返す
* @return {Number} 連合艦隊補正
*/
DayBattlePower.prototype.getCombinedPowerBonus = function () {
if (this.attack.friendAttack) {
if (this.isEnemyCombined) {
switch (this.friendCombinedKind) {
case COMBINED_FLEET.NONE: // 味方:通常艦隊 -> 敵:空母機動部隊(第一艦隊/第二艦隊)
return 5
case COMBINED_FLEET.CARRIER_TASK_FORCE: // 味方:空母機動部隊(第一艦隊/第二艦隊) -> 敵:空母機動部隊(第一艦隊/第二艦隊)
return this.attack.mainAttack ? 2 : -5
case COMBINED_FLEET.SURFACE_TASK_FORCE: // 味方:水上打撃部隊(第一艦隊/第二艦隊) -> 敵:空母機動部隊(第一艦隊/第二艦隊)
return this.attack.mainAttack ? 2 : -5
case COMBINED_FLEET.TRANSPORT_ESCORT: // 味方:輸送護衛部隊(第一艦隊/第二艦隊) -> 敵:空母機動部隊(第一艦隊/第二艦隊)
return this.attack.mainAttack ? -5 : -5
}
} else {
switch (this.friendCombinedKind) {
case COMBINED_FLEET.NONE: // 味方:通常艦隊 -> 敵:通常艦隊
return 0
case COMBINED_FLEET.CARRIER_TASK_FORCE: // 味方:空母機動部隊(第一艦隊/第二艦隊) -> 敵:通常艦隊
return this.attack.mainAttack ? 2 : 10
case COMBINED_FLEET.SURFACE_TASK_FORCE: // 味方:水上打撃部隊(第一艦隊/第二艦隊) -> 敵:通常艦隊
return this.attack.mainAttack ? 10 : -5
case COMBINED_FLEET.TRANSPORT_ESCORT: // 味方:輸送護衛部隊(第一艦隊/第二艦隊) -> 敵:通常艦隊
return this.attack.mainAttack ? -5 : 10
}
}
} else {
if (this.isEnemyCombined) {
return this.attack.mainAttack ? 10 : -5 // 敵:空母機動部隊(第一艦隊/第二艦隊) -> 味方:Any
} else {
switch (this.friendCombinedKind) {
case COMBINED_FLEET.NONE: // 敵:通常艦隊 -> 味方:通常艦隊
return 0
case COMBINED_FLEET.CARRIER_TASK_FORCE: // 敵:通常艦隊 -> 味方:空母機動部隊(第一艦隊/第二艦隊)
return this.attack.mainDefense ? 10 : 5
case COMBINED_FLEET.SURFACE_TASK_FORCE: // 敵:通常艦隊 -> 味方:水上打撃部隊(第一艦隊/第二艦隊)
return this.attack.mainDefense ? 5 : -5
case COMBINED_FLEET.TRANSPORT_ESCORT: // 敵:通常艦隊 -> 味方:輸送護衛部隊(第一艦隊/第二艦隊)
return this.attack.mainDefense ? 10 : 5
}
}
}
return 0
}
//#endregion
//#region 雷撃関連