Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/KC3Kai/kancolle-replay in…
Browse files Browse the repository at this point in the history
…to gh-pages
  • Loading branch information
fourinone41 committed Jan 19, 2024
2 parents 9f0c670 + 9238bca commit 2ec152d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 19 deletions.
18 changes: 5 additions & 13 deletions js/kcsim.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,22 +352,14 @@ function getRepairCost(ship) {
}

function getRepairTime(ship) {
if (ship.HP >= ship.maxHP) return 0;
var mod, base;
if (ship.LVL <= 12) base = 10*ship.LVL;
else if (ship.LVL < 100) {
base = 120;
var extra = 0, count = 0, bm = 2;
for (var i=13; i<=ship.LVL; i++) {
base += 5;
if (count++ >= bm) { bm += 2; count = 0; base += 10; }
}
} else if (ship.LVL <= 128) base = 650 + 5*(ship.LVL-100);
else if (ship.LVL < 150) base = 800 + 5*(ship.LVL-128);
else base = 915;
if (ship.LVL <= 11) base = 10*ship.LVL;
else base = 5*ship.LVL + 10*Math.floor(Math.sqrt(ship.LVL-11)) + 50;
switch (SHIPDATA[ship.mid].type) {
case 'BB': case 'BBV': case 'CV': case 'AR': mod = 2; break;
case 'BB': case 'BBV': case 'CV': case 'CVB': case 'AR': mod = 2; break;
case 'CA': case 'CAV': case 'FBB': case 'CVL': case 'AS': mod = 1.5; break;
case 'SS': mod = .5; break;
case 'SS': case 'DE': mod = .5; break;
default: mod = 1; break;
}
return (ship.maxHP - ship.HP)*base*mod+30;
Expand Down
1 change: 1 addition & 0 deletions js/simulator-ui/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ window.CONVERT = {
continueOnTaiha: !dataUI.settings.retreatOnTaiha,
bucketHPPercent: dataUI.settings.bucketPercent,
bucketTime: dataUI.settings.bucketTime,
bucketTimeIgnore: (dataUI.settings.bucketTimeIgnore||0)*60*60,
carryOverHP: dataUI.settings.carryOverHP,
carryOverMorale: dataUI.settings.carryOverMorale,
mechanics: null,
Expand Down
7 changes: 7 additions & 0 deletions js/simulator-ui/fleet-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,13 @@ var UI_FLEETEDITOR = Vue.createApp({
getAmmoMax: function(ship) {
return SHIPDATA[ship.mstId].ammo || 100;
},
getRepairStr: function(ship) {
let timeNow = window.getRepairTime({ mid: ship.mstId, LVL: ship.level, maxHP: ship.hp, HP: ship.hpInit });
let timeMax = window.getRepairTime({ mid: ship.mstId, LVL: ship.level, maxHP: ship.hp, HP: 1 });
let hNow = Math.floor(timeNow/3600), mNow = Math.floor((timeNow-hNow*3600)/60), sNow = Math.floor(timeNow-hNow*3600-mNow*60);
let hMax = Math.floor(timeMax/3600), mMax = Math.floor((timeMax-hMax*3600)/60), sMax = Math.floor(timeMax-hMax*3600-mMax*60);
return 'Repair: ' + hNow + 'h ' + mNow + 'm ' + sNow + 's (max ' + hMax + 'h ' + mMax + 'm ' + sMax + 's)';
},

doOpen: function(fleet) {
this.active = true;
Expand Down
7 changes: 4 additions & 3 deletions js/simulator-ui/sim-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,13 @@ var SIM = {
this._results.totalTransport += tp;
}
},
_updateResultsTotal: function() {
_updateResultsTotal: function(dataInput) {
this._results.totalnum++;
for (let fleet of FLEETS1) {
if (!fleet) continue;
for (let ship of fleet.ships) {
let useBucket = ship.HP/ship.maxHP <= window.BUCKETPERCENT || window.getRepairTime(ship) > window.BUCKETTIME;
let repairTime = window.getRepairTime(ship);
let useBucket = (ship.HP/ship.maxHP <= window.BUCKETPERCENT || repairTime > window.BUCKETTIME) && repairTime >= (dataInput.bucketTimeIgnore || 0);
if (!window.CARRYOVERHP || useBucket) {
let cost = window.getRepairCost(ship);
this._results.totalFuelR += cost[0];
Expand Down Expand Up @@ -747,7 +748,7 @@ var SIM = {
}

if (!dataReplay) {
this._updateResultsTotal();
this._updateResultsTotal(dataInput);

if (window.CARRYOVERHP || window.CARRYOVERMORALE) {
for (let fleet of FLEETS1) {
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 @@ -94,6 +94,7 @@ var UI_MAIN = Vue.createApp({
arcticCamoEva: SIMCONSTS.arcticCamoEva,
bucketPercent: BUCKETPERCENT*100,
bucketTime: BUCKETTIME/3600,
bucketTimeIgnore: 0,
carryOverHP: CARRYOVERHP,
carryOverMorale: CARRYOVERMORALE,
enableSkipTorpBonus: SIMCONSTS.enableSkipTorpBonus,
Expand Down
1 change: 1 addition & 0 deletions simulator-import-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
continueOnTaiha: &lt;bool&gt; (default 0),
bucketHPPercent: &lt;int&gt; if HP percent &lt;= bucketHPPercent, report as bucket used (default 0),
bucketTime: &lt;int&gt; if repair time in seconds &gt; bucketTime, report as bucket used (default "infinity"),
bucketTimeIgnore: &lt;int&gt; if repair time in seconds &lt; bucketTimeIgnore, ignore bucketHPPercent and bucketTime and do not report as bucket used (default 0),
didSpecial: &lt;bool&gt; if fleet has already performed special attack, disables special attack for simulator (default 0),
settingsFCF: optional {
los: &lt;float&gt; required ELoS after FCF use (optional),
Expand Down
7 changes: 4 additions & 3 deletions simulator.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ <h2>Settings</h2>
<label><input type="checkbox" v-model="settings.airRaidCostW6" /> Use default World 6 costs for Air Raid (4% <img src="assets/stats/fuel.png" /> 8% <img src="assets/stats/ammo.png" />)</label>
</div>
<div>
<div><img src="assets/stats/bucket.png" />: Count use if HP &leq; <input type="number" min="0" max="100" v-model="settings.bucketPercent":class="getClassSetting('bucketPercent')" />% OR repair time &gt; <input type="number" min="0" max="100" v-model="settings.bucketTime" :class="getClassSetting('bucketTime')"/> hours</div>
<div><label><input type="checkbox" v-model="settings.carryOverHP" />Carry over ship HP between sims unless <img src="assets/stats/bucket.png" /> conditions</label></div>
<div><img src="assets/stats/bucket.png" />: Count use if HP &leq; <input type="number" min="0" max="100" v-model="settings.bucketPercent" :class="getClassSetting('bucketPercent')"/>% OR repair time &gt; <input type="number" min="0" max="100" v-model="settings.bucketTime" :class="getClassSetting('bucketTime')"/> hours</div>
<div style="margin-left:26px">Do not count if repair time &lt; <input type="number" min="0" max="100" v-model="settings.bucketTimeIgnore" :class="getClassSetting('bucketTimeIgnore')"/> hours (regardless of above)</div>
<div><label><input type="checkbox" v-model="settings.carryOverHP" />Carry over ship HP between sims unless <img src="assets/stats/bucket.png" /> conditions (not including "Do not count if repair time &lt;")</label></div>
<div><label><input type="checkbox" v-model="settings.carryOverMorale" />Carry over ship morale between sims</label></div>
</div>
<div id="divSettingsAdvanced">
Expand Down Expand Up @@ -706,7 +707,7 @@ <h3>Statistics</h3>
</div>
</div>

<div class="statWide"><img src="assets/stats/hp.png" title="HP Init"/> Init: <input type="number" v-model.number="ship.hpInit" min="1" :max="ship.hp" :class="getClassHP(ship)" @change="onchangeStat($event,ship,'hpInit')"/></div>
<div class="statWide"><img src="assets/stats/hp.png" title="HP Init"/> Init: <input type="number" :title="getRepairStr(ship)" v-model.number="ship.hpInit" min="1" :max="ship.hp" :class="getClassHP(ship)" @change="onchangeStat($event,ship,'hpInit')"/></div>
<div class="statWide">Morale: <input type="number" v-model.number="ship.morale" min="0" max="100" :class="getClassMorale(ship)" @change="onchangeStat($event,ship,'morale')"/></div>
<div class="statHalf" :title="getFuel(ship)+'/'+getFuelMax(ship)"><img src="assets/stats/fuel.png" title="Fuel Percent"/><input type="number" v-model.number="ship.fuelInit" min="0" max="100" @change="onchangeStat($event,ship,'fuelInit')"/></div>
<div class="statHalf" :title="getAmmo(ship)+'/'+getAmmoMax(ship)"><img src="assets/stats/ammo.png" title="Ammo Percent"/><input type="number" v-model.number="ship.ammoInit" min="0" max="100" @change="onchangeStat($event,ship,'ammoInit')"/></div>
Expand Down

0 comments on commit 2ec152d

Please sign in to comment.