From f904f5c18ac39d782a006a43890fb174009f8d8d Mon Sep 17 00:00:00 2001 From: fourinone Date: Thu, 7 Dec 2017 00:07:27 -0500 Subject: [PATCH] make sunk/repair handling slightly less bad --- js/player.js | 220 ++++++++++++++++----------------------------------- 1 file changed, 66 insertions(+), 154 deletions(-) diff --git a/js/player.js b/js/player.js index 6995498a..c0b688d2 100644 --- a/js/player.js +++ b/js/player.js @@ -441,19 +441,21 @@ function processAPI(root) { bossbar.show = true; } else bossbar.show = false; - var HPstate = [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]; - var HPbeginstate = null, battlenumstate = 0; + var battlenumstate = 0; var getState = function(newbattle) { if (newbattle) { - HPbeginstate = HPstate.slice(); battlenumstate++; } var state = { - HP:HPbeginstate, + HP: { + fleet1: [], + fleet1C: [], + }, bg:(bg.parent)? 1 : 2, battle:battlenumstate - }; - HPbeginstate = HPstate.slice(); + }; + for (var i=0; i= 7)? 429 : 402; stage.addChild(fleet1[i].graphic); - HPstate[i] = nowhp; + fleet1[i].hpTrack = nowhp; } for (var b=0; b0)? dam:0,(dam!=kouku.api_stage3.api_fdam[ind]),kouku.api_stage3.api_fcl_flag[ind],kouku.api_stage3.api_frai_flag[ind]]); + if (hit) { + targetdata.push([fleet1[i],(dam>0)? dam:0,(dam!=kouku.api_stage3.api_fdam[ind]),kouku.api_stage3.api_fcl_flag[ind],kouku.api_stage3.api_frai_flag[ind]]); + fleet1[i].hpTrack -= Math.floor(dam); + } } if (kouku.api_stage3.api_edam) { var dam = parseInt(kouku.api_stage3.api_edam[ind]); - if (OLDFORMAT) HPstate[i+6] -= Math.floor(dam); hit = (kouku.api_stage3.api_erai_flag[ind] || kouku.api_stage3.api_ebak_flag[ind]); if (hit) targetdata.push([f2[i],(dam>0)? dam:0,(dam!=kouku.api_stage3.api_edam[ind]),kouku.api_stage3.api_ecl_flag[ind],kouku.api_stage3.api_erai_flag[ind]]); } @@ -786,13 +806,14 @@ function processAPI(root) { if (kouku.api_stage3_combined) { if (kouku.api_stage3_combined.api_fdam) { var dam = parseInt(kouku.api_stage3_combined.api_fdam[ind]); //remember later, .1 = protect - HPstate[i+12] -= Math.floor(dam); var hit = (kouku.api_stage3_combined.api_frai_flag[ind] || kouku.api_stage3_combined.api_fbak_flag[ind]); - if (hit) targetdata.push([fleet1C[i],(dam>0)? dam:0,(dam!=kouku.api_stage3_combined.api_fdam[ind]),kouku.api_stage3_combined.api_fcl_flag[ind],kouku.api_stage3_combined.api_frai_flag[ind]]); + if (hit) { + targetdata.push([fleet1C[i],(dam>0)? dam:0,(dam!=kouku.api_stage3_combined.api_fdam[ind]),kouku.api_stage3_combined.api_fcl_flag[ind],kouku.api_stage3_combined.api_frai_flag[ind]]); + fleet1C[i].hpTrack -= Math.floor(dam); + } } if (kouku.api_stage3_combined.api_edam) { var dam = parseInt(kouku.api_stage3_combined.api_edam[ind]); //remember later, .1 = protect - HPstate[i+18] -= Math.floor(dam); var hit = (kouku.api_stage3_combined.api_erai_flag[ind] || kouku.api_stage3_combined.api_ebak_flag[ind]); if (hit) targetdata.push([f2c[i],(dam>0)? dam:0,(dam!=kouku.api_stage3_combined.api_edam[ind]),kouku.api_stage3_combined.api_ecl_flag[ind],kouku.api_stage3_combined.api_erai_flag[ind]]); } @@ -814,22 +835,8 @@ function processAPI(root) { eventqueue.push([GAirPhase,[attackdata,targetdata,defenders,AACI1,undefined,contact1,contact2,AS1,AS2,false,isbombing,isjet],getState()]); //remember AACI } - for (var i=0; i=6)? f1[i-6] : f1[i]; var crit = (rai.api_fcl[i+1] == 2); shots.push([attacker,target,rai.api_fydam[i+1],crit]); + target.hpTrack -= Math.floor(rai.api_edam[i+1]); } if (rai.api_erai[i+1] > 0) { var target; @@ -854,9 +862,8 @@ function processAPI(root) { var attacker = (ecombined)? f2c[i-6] : f2[i]; var crit = (rai.api_ecl[i+1] == 2); shots.push([attacker,target,rai.api_eydam[i+1],crit]); + target.hpTrack -= Math.floor(rai.api_fdam[i+1]); } - HPstate[i+((i>=6)?12:6)] -= Math.floor(rai.api_edam[i+1]); - HPstate[i+((COMBINED)?12:0)] -= Math.floor(rai.api_fdam[i+1]); } else { if (rai.api_frai[i] > -1) { var ind = rai.api_frai[i]; @@ -864,6 +871,7 @@ function processAPI(root) { var attacker = (i >= 6 && fleet1.length < 7)? fleet1C[i-6] : fleet1[i]; var crit = (rai.api_fcl[i] == 2); shots.push([attacker,target,rai.api_fydam[i],crit]); + target.hpTrack -= Math.floor(rai.api_edam[i]); } if (rai.api_erai[i] > -1) { var ind = rai.api_erai[i]; @@ -871,6 +879,7 @@ function processAPI(root) { var attacker = (i >= 6 && f2.length < 7)? f2c[i-6] : f2[i]; var crit = (rai.api_ecl[i] == 2); shots.push([attacker,target,rai.api_eydam[i],crit]); + target.hpTrack -= Math.floor(rai.api_fdam[i]); } } } @@ -879,23 +888,8 @@ function processAPI(root) { eventqueue.push([GTorpedoPhase,[shots],getState()]); } - for (var i=0; i= 6) ind += 6; - //if (!hou.api_at_eflag) ind += 6; - HPstate[ind] -= Math.floor(hou.api_damage[j][k]); - } - } else { - HPstate[hou.api_df_list[j][0]-1+((f1[0].escort && hou.api_df_list[j][0] < 7)?12:0)] -= Math.floor(hou.api_damage[j][k]); - } - } else { - if (OLDFORMAT || hou.api_at_eflag[j]) { - var ind = hou.api_df_list[j][0]; - if (OLDFORMAT) ind -= 1; - if (hou.api_at_eflag[j] && ind >= 6) ind += 6; //player escort (not used currently) - else if (!hou.api_at_eflag[j] && ind < 6) ind += 6; //enemy main - else if (!hou.api_at_eflag[j] && ind >= 6) ind += 12; //enemy escort - HPstate[ind] -= Math.floor(hou.api_damage[j][k]); - } - } + defender.hpTrack -= Math.max(0,Math.floor(hou.api_damage[j][k])); } for (var k=0; k= 6 && fleet1.length < 7) ind += 6; - HPstate[ind] -= Math.max(0,Math.floor(hou.api_damage[j][k])); - } - } else { - ind = hou.api_df_list[j][0]-1+((COMBINED && hou.api_df_list[j][0] < 7)?12:0); - HPstate[ind] -= Math.max(0,Math.floor(hou.api_damage[j][k])); - } - } else { - var ind; - if (hou.api_at_eflag) { - if (hou.api_at_eflag[j]) { - ind = hou.api_df_list[j][0]; - if (ind >= 6 && fleet1.length < 7) ind += 6; - HPstate[ind] -= Math.max(0,Math.floor(hou.api_damage[j][k])); - } - } else { - ind = hou.api_df_list[j][0]-1; - if (combinedEType == 2 && ind >= 6) ind += 12; - if (COMBINED && ind < 6) ind += 12; - HPstate[ind] -= Math.max(0,Math.floor(hou.api_damage[j][k])); - } - } + d[1].hpTrack -= Math.max(0,Math.floor(hou.api_damage[j][k])); } for (var k=0; k