Skip to content

Commit

Permalink
sortie sim: sub fleet attack rate option, ctrl+c alts for Statistics …
Browse files Browse the repository at this point in the history
…imgs (#73)

sim: update sub fleet attack mechanics (#74)
  • Loading branch information
fourinone41 committed Mar 12, 2024
1 parent c70d626 commit f8b910e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 59 deletions.
30 changes: 19 additions & 11 deletions js/kcsim.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ var SIMCONSTS = {
kongouSpecialRate: null,
yamatoSpecial3Rate: 80,
yamatoSpecial2Rate: 80,
subFleetAttackRate: 80,
nightZuiunCIRate: 60,
arcticCamoAr: 0,
arcticCamoEva: 0,
Expand Down Expand Up @@ -858,7 +859,7 @@ function NBattack(ship,target,NBonly,NBequips,APIyasen,attackSpecial) {
APIyasen.api_df_list.push([target.apiID]);
}
APIyasen.api_damage.push([realdmg+DIDPROTECT*.1]);
APIyasen.api_sp_list.push(ship.fleet.useAtoll && ship.numAtollAttacks ? 1000 : cutin || 0);
APIyasen.api_sp_list.push(!attackSpecial && ship.fleet.useAtoll && ship.numAtollAttacks ? 1000 : cutin || 0);
APIyasen.api_cl_list.push([((res>1)?2:1)]);
APIyasen.api_n_mother_list.push(+ship.canNBAirAttack());
}
Expand Down Expand Up @@ -1144,20 +1145,26 @@ function canSpecialAttackUnique(ship,isNB) {
if (!MECHANICS.specialAttacks) return false;
if (ship.side == 1) return false;
if (MECHANICS.subFleetAttack && ship.type == 'AS' && ship.fleet.id == 0) {
if (!isNB && ship.fleet.didSpecial == 1) return false;
if (ship.fleet.ships[0] != ship) return false;
if (ship.LVL < 30) return false;
if (ship.fleet.formation.id != 4 && ship.fleet.formation.id != 5) return false;
if (ship.HP/ship.maxHP <= .25) return false;
let rate = .6;
let types = { 300: { s1: 1, s2: 2 }, 301: { s1: 2, s2: 3 }, 302: { s1: 1, s2: 3 } };
for (let id in types) {
let ship1 = ship.fleet.ships[types[id].s1], ship2 = ship.fleet.ships[types[id].s2];
if (!ship1 || !ship1.isSub || ship1.HP/ship1.maxHP <= .5) continue;
if (!ship2 || !ship2.isSub || ship2.HP/ship2.maxHP <= .5) continue;
if (Math.random() < rate) {
ship.attackSpecial = +id;
return true;
}
if (ship.fleet.ships.length < 3) return false;
let ship1 = ship.fleet.ships[1], ship2 = ship.fleet.ships[2], ship3 = ship.fleet.ships[3];
if (!ship1.isSub || ship1.retreated || !ship2.isSub || ship2.retreated) return false;

let type = 0;
if (ship3 && ship3.isSub && !ship3.retreated && ship1.HP/ship1.maxHP > .5 && ship3.HP/ship3.maxHP > .5) type = 302;
else if (ship3 && ship3.isSub && !ship3.retreated && ship2.HP/ship2.maxHP > .5 && ship3.HP/ship3.maxHP > .5) type = 301;
else if (ship1.HP/ship1.maxHP > .5 && ship2.HP/ship2.maxHP > .5) type = 300;
if (!type) return false;

let rate = SIMCONSTS.subFleetAttackRate/100;
if (Math.random() < rate) {
ship.attackSpecial = type;
ship.fleet.didSpecial = 1;
return true;
}
return false;
}
Expand Down Expand Up @@ -1201,6 +1208,7 @@ function canSpecialAttackUnique(ship,isNB) {
if (ship.HP/ship.maxHP <= .5) return false;
if (ship.fleet.ships[2].CVshelltype || ship.fleet.ships[4].CVshelltype) return false;
if (ship.fleet.ships[2].isSub || ship.fleet.ships[4].isSub) return false;
if (ship.fleet.ships[2].retreated || ship.fleet.ships[4].retreated) return false;
let rate = SIMCONSTS.nelsonTouchRate;
if (Math.random() < rate/100) {
ship.fleet.didSpecial = 1;
Expand Down
1 change: 1 addition & 0 deletions js/simulator-ui/ui-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ var UI_MAIN = Vue.createApp({
kongouSpecialRate: SIMCONSTS.kongouSpecialRate,
yamatoSpecial3Rate: SIMCONSTS.yamatoSpecial3Rate,
yamatoSpecial2Rate: SIMCONSTS.yamatoSpecial2Rate,
subFleetAttackRate: SIMCONSTS.subFleetAttackRate,
nightZuiunCIRate: SIMCONSTS.nightZuiunCIRate,
arcticCamoAr: SIMCONSTS.arcticCamoAr,
arcticCamoEva: SIMCONSTS.arcticCamoEva,
Expand Down
97 changes: 49 additions & 48 deletions simulator.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ <h2>Settings</h2>
<tr><td>Kongou Special:</td><td><input type="number" min="0" max="100" v-model="settings.kongouSpecialRate" :class="getClassSetting('kongouSpecialRate')"/>%</td></tr>
<tr><td>Yamato Special (3-ship):</td><td><input type="number" min="0" max="100" v-model="settings.yamatoSpecial3Rate" :class="getClassSetting('yamatoSpecial3Rate')"/>%</td></tr>
<tr><td>Yamato Special (2-ship):</td><td><input type="number" min="0" max="100" v-model="settings.yamatoSpecial2Rate" :class="getClassSetting('yamatoSpecial2Rate')"/>%</td></tr>
<tr><td>Submarine Special Attack:</td><td><input type="number" min="0" max="100" v-model="settings.subFleetAttackRate" :class="getClassSetting('subFleetAttackRate')"/>%</td></tr>
</table>
</div>
<div v-show="settings.showAdvanced">
Expand Down Expand Up @@ -303,19 +304,19 @@ <h3>Statistics</h3>
<div>
<div>Final Rank Rate:</div>
<table>
<tr><th><img src="assets/stats/S.png"/></th><td><span class="resultBold">{{results.rankS}}</span></td></tr>
<tr><th><img src="assets/stats/A.png"/></th><td>{{results.rankA}}</td></tr>
<tr><th><img src="assets/stats/B.png"/></th><td>{{results.rankB}}</td></tr>
<tr><th><img src="assets/stats/C.png"/></th><td>{{results.rankC}}</td></tr>
<tr><th><img src="assets/stats/D.png"/></th><td>{{results.rankD}}</td></tr>
<tr><th><img src="assets/stats/E.png"/></th><td>{{results.rankE}}</td></tr>
<tr><th><img src="assets/stats/retreat.png"/></th><td>{{results.retreat}}</td></tr>
<tr><th><img src="assets/stats/S.png" alt="S"/></th><td><span class="resultBold">{{results.rankS}}</span></td></tr>
<tr><th><img src="assets/stats/A.png" alt="A"/></th><td>{{results.rankA}}</td></tr>
<tr><th><img src="assets/stats/B.png" alt="B"/></th><td>{{results.rankB}}</td></tr>
<tr><th><img src="assets/stats/C.png" alt="C"/></th><td>{{results.rankC}}</td></tr>
<tr><th><img src="assets/stats/D.png" alt="D"/></th><td>{{results.rankD}}</td></tr>
<tr><th><img src="assets/stats/E.png" alt="E"/></th><td>{{results.rankE}}</td></tr>
<tr><th><img src="assets/stats/retreat.png" alt="Retreat"/></th><td>{{results.retreat}}</td></tr>
</table>
</div>
<div>
<div>Enemy Flagship Sunk Rate:</div>
<table>
<tr><th><img src="assets/stats/flagsunk.png"/></th><td><span class="resultBold">{{results.flagSunk}}</span></td></tr>
<tr><th><img src="assets/stats/flagsunk.png" alt="Flagship Sunk"/></th><td><span class="resultBold">{{results.flagSunk}}</span></td></tr>
</table>
<div>Avg <span class="resultBold">-{{results.flagSunkHP}}</span> HP per run</div>
<div>Avg <span class="resultBold">-{{results.flagSunkHPBoss}}</span> HP per boss</div>
Expand All @@ -324,31 +325,31 @@ <h3>Statistics</h3>
<div v-show="results.numNodes>1">
<div>Rank Per Battle:</div>
<table class="multi">
<tr><th></th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr><th><img src="assets/stats/S.png"/></th><td v-for="stat in results.rankSNode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/A.png"/></th><td v-for="stat in results.rankANode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/B.png"/></th><td v-for="stat in results.rankBNode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/C.png"/></th><td v-for="stat in results.rankCNode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/D.png"/></th><td v-for="stat in results.rankDNode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/E.png"/></th><td v-for="stat in results.rankENode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/flagsunk.png"/></th><td v-for="stat in results.flagSunkNode">{{stat}}</td></tr>
<tr><th>&nbsp;</th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr><th><img src="assets/stats/S.png" alt="S"/></th><td v-for="stat in results.rankSNode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/A.png" alt="A"/></th><td v-for="stat in results.rankANode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/B.png" alt="B"/></th><td v-for="stat in results.rankBNode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/C.png" alt="C"/></th><td v-for="stat in results.rankCNode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/D.png" alt="D"/></th><td v-for="stat in results.rankDNode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/E.png" alt="E"/></th><td v-for="stat in results.rankENode">{{stat}}</td></tr>
<tr><th><img src="assets/stats/flagsunk.png" alt="Flagship Sunk"/></th><td v-for="stat in results.flagSunkNode">{{stat}}</td></tr>
</table>
</div>
</div>
<div class="resultCol">
<div>
<div><img src="assets/stats/MVP.png"/> Rate Per Battle:</div>
<div><img src="assets/stats/MVP.png" alt="MVP"/> Rate Per Battle:</div>
<table class="multi">
<tr v-show="results.numNodes>1"><th></th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr v-for="n in 7" v-show="results.hasSF||n<7"><th><img :src="'assets/stats/F' + n + '.png'"/></th><td v-for="stat in results['mvp'+n]">{{stat}}</td></tr>
<tr v-show="results.numNodes>1"><th>&nbsp;</th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr v-for="n in 7" v-show="results.hasSF||n<7"><th><img :src="'assets/stats/F' + n + '.png'" :alt="'Ship ' + n"/></th><td v-for="stat in results['mvp'+n]">{{stat}}</td></tr>
<tr class="tableSpace" v-show="results.hasCF"></tr>
<tr v-for="n in 6" v-show="results.hasCF"><th><img :src="'assets/stats/F' + n + '.png'"/></th><td v-for="stat in results['mvpE'+n]">{{stat}}</td></tr>
<tr v-for="n in 6" v-show="results.hasCF"><th><img :src="'assets/stats/F' + n + '.png'" :alt="'Ship ' + n"/></th><td v-for="stat in results['mvpE'+n]">{{stat}}</td></tr>
</table>
</div>
<div>
<div>Air State Rate Per Battle:</div>
<table class="multi">
<tr v-show="results.numNodes>1"><th></th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr v-show="results.numNodes>1"><th>&nbsp;</th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr><th><span class="air good">AS+</span></th><td v-for="stat in results.airASP">{{stat}}</td></tr>
<tr><th><span class="air good">AS</span></th><td v-for="stat in results.airAS">{{stat}}</td></tr>
<tr><th><span class="air">AP</span></th><td v-for="stat in results.airAP">{{stat}}</td></tr>
Expand All @@ -359,20 +360,20 @@ <h3>Statistics</h3>
</div>
<div class="resultCol">
<div>
<div><img src="assets/stats/taiha.png"/> Rate Per Battle:</div>
<div><img src="assets/stats/taiha.png" alt="Heavy Damage"/> Rate Per Battle:</div>
<table class="multi">
<tr v-show="results.numNodes>1"><th></th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr v-show="results.numNodes>1"><th>&nbsp;</th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr><th>Any</th><td v-for="stat in results.taiha"><span class="resultBold">{{stat}}</span></td></tr>
<tr class="tableSpace"></tr>
<tr v-for="n in 7" v-show="results.hasSF||n<7"><th><img :src="'assets/stats/F' + n + '.png'"/></th><td v-for="stat in results['taiha'+n]">{{stat}}</td></tr>
<tr v-for="n in 7" v-show="results.hasSF||n<7"><th><img :src="'assets/stats/F' + n + '.png'" :alt="'Ship ' + n"/></th><td v-for="stat in results['taiha'+n]">{{stat}}</td></tr>
<tr class="tableSpace" v-show="results.hasCF"></tr>
<tr v-for="n in 6" v-show="results.hasCF"><th><img :src="'assets/stats/F' + n + '.png'"/></th><td v-for="stat in results['taihaE'+n]">{{stat}}</td></tr>
<tr v-for="n in 6" v-show="results.hasCF"><th><img :src="'assets/stats/F' + n + '.png'" :alt="'Ship ' + n"/></th><td v-for="stat in results['taihaE'+n]">{{stat}}</td></tr>
</table>
</div>
<div>
<div>No <img src="assets/stats/chuuha.png"/> After Battle:</div>
<div>No <img src="assets/stats/chuuha.png" alt="Moderate Damage"/> After Battle:</div>
<table class="multi">
<tr v-show="results.numNodes>1"><th></th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr v-show="results.numNodes>1"><th>&nbsp;</th><th v-for="n in results.numNodes">{{n}}</th></tr>
<tr><th>All</th><td v-for="stat in results.noChuuha">{{stat}}</td></tr>
</table>
</div>
Expand All @@ -381,40 +382,40 @@ <h3>Statistics</h3>
<div>
<div>Avg Resupply:</div>
<table>
<tr><th><img src="assets/stats/fuel.png"/></th><td>{{results.fuelSupply}}</td></tr>
<tr><th><img src="assets/stats/ammo.png"/></th><td>{{results.ammoSupply}}</td></tr>
<tr><th><img src="assets/stats/baux.png"/></th><td>{{results.bauxSupply}}</td></tr>
<tr><th><img src="assets/stats/fuel.png" alt="Fuel"/></th><td>{{results.fuelSupply}}</td></tr>
<tr><th><img src="assets/stats/ammo.png" alt="Ammo"/></th><td>{{results.ammoSupply}}</td></tr>
<tr><th><img src="assets/stats/baux.png" alt="Bauxite"/></th><td>{{results.bauxSupply}}</td></tr>
</table>
</div>
<div>
<div>Avg Repair:</div>
<table>
<tr><th><img src="assets/stats/fuel.png"/></th><td>{{results.fuelRepair}}</td></tr>
<tr><th><img src="assets/stats/steel.png"/></th><td>{{results.steelRepair}}</td></tr>
<tr><th><img src="assets/stats/bucket.png"/></th><td>{{results.bucket}}</td></tr>
<tr><th><img src="assets/items/14.png"/></th><td>{{results.damecon}}</td></tr>
<tr><th><img src="assets/stats/fuel.png" alt="Fuel"/></th><td>{{results.fuelRepair}}</td></tr>
<tr><th><img src="assets/stats/steel.png" alt="Steel"/></th><td>{{results.steelRepair}}</td></tr>
<tr><th><img src="assets/stats/bucket.png" alt="Bucket"/></th><td>{{results.bucket}}</td></tr>
<tr><th><img src="assets/items/14.png" alt="Repair Team"/></th><td>{{results.damecon}}</td></tr>
</table>
</div>
<div>
<div>Avg Resource Per <img src="assets/stats/S.png"/>:</div>
<div>Avg Resource Per <img src="assets/stats/S.png" alt="S"/>:</div>
<table>
<tr><th><img src="assets/stats/fuel.png"/></th><td><span class="resultBold">{{results.fuelS}}</span></td></tr>
<tr><th><img src="assets/stats/ammo.png"/></th><td><span class="resultBold">{{results.ammoS}}</span></td></tr>
<tr><th><img src="assets/stats/steel.png"/></th><td><span class="resultBold">{{results.steelS}}</span></td></tr>
<tr><th><img src="assets/stats/baux.png"/></th><td><span class="resultBold">{{results.bauxS}}</span></td></tr>
<tr><th><img src="assets/stats/bucket.png"/></th><td><span class="resultBold">{{results.bucketS}}</span></td></tr>
<tr><th><img src="assets/items/14.png"/></th><td><span class="resultBold">{{results.dameconS}}</span></td></tr>
<tr><th><img src="assets/stats/fuel.png" alt="Fuel"/></th><td><span class="resultBold">{{results.fuelS}}</span></td></tr>
<tr><th><img src="assets/stats/ammo.png" alt="Ammo"/></th><td><span class="resultBold">{{results.ammoS}}</span></td></tr>
<tr><th><img src="assets/stats/steel.png" alt="Steel"/></th><td><span class="resultBold">{{results.steelS}}</span></td></tr>
<tr><th><img src="assets/stats/baux.png" alt="Bauxite"/></th><td><span class="resultBold">{{results.bauxS}}</span></td></tr>
<tr><th><img src="assets/stats/bucket.png" alt="Bucket"/></th><td><span class="resultBold">{{results.bucketS}}</span></td></tr>
<tr><th><img src="assets/items/14.png" alt="Repair Team"/></th><td><span class="resultBold">{{results.dameconS}}</span></td></tr>
</table>
</div>
<div>
<div>Avg Resource Per <img src="assets/stats/flagsunk.png"/>:</div>
<div>Avg Resource Per <img src="assets/stats/flagsunk.png" alt="Flagship Sunk"/>:</div>
<table>
<tr><th><img src="assets/stats/fuel.png"/></th><td><span class="resultBold">{{results.fuelSunk}}</span></td></tr>
<tr><th><img src="assets/stats/ammo.png"/></th><td><span class="resultBold">{{results.ammoSunk}}</span></td></tr>
<tr><th><img src="assets/stats/steel.png"/></th><td><span class="resultBold">{{results.steelSunk}}</span></td></tr>
<tr><th><img src="assets/stats/baux.png"/></th><td><span class="resultBold">{{results.bauxSunk}}</span></td></tr>
<tr><th><img src="assets/stats/bucket.png"/></th><td><span class="resultBold">{{results.bucketSunk}}</span></td></tr>
<tr><th><img src="assets/items/14.png"/></th><td><span class="resultBold">{{results.dameconSunk}}</span></td></tr>
<tr><th><img src="assets/stats/fuel.png" alt="Fuel"/></th><td><span class="resultBold">{{results.fuelSunk}}</span></td></tr>
<tr><th><img src="assets/stats/ammo.png" alt="Ammo"/></th><td><span class="resultBold">{{results.ammoSunk}}</span></td></tr>
<tr><th><img src="assets/stats/steel.png" alt="Steel"/></th><td><span class="resultBold">{{results.steelSunk}}</span></td></tr>
<tr><th><img src="assets/stats/baux.png" alt="Bauxite"/></th><td><span class="resultBold">{{results.bauxSunk}}</span></td></tr>
<tr><th><img src="assets/stats/bucket.png" alt="Bucket"/></th><td><span class="resultBold">{{results.bucketSunk}}</span></td></tr>
<tr><th><img src="assets/items/14.png" alt="Repair Team"/></th><td><span class="resultBold">{{results.dameconSunk}}</span></td></tr>
</table>
</div>
<div>
Expand Down

0 comments on commit f8b910e

Please sign in to comment.