Inflation RPG - Battle Calculator
HTML
<script src="http://yourjavascript.com/6556181611/bosses.js"></script>
<!-- <div id="debug"></div> -->
<section>
<h1>
Inflation RPG - Battle Calculator
<span class="rightAligned">
<input type="button" id="btnSave" value="Save"
title="Save the current data in the browser's local storage" />
<input type="button" id="btnLoad" value="Load"
title="Load data from the browser's local storage" />
</span>
</h1>
</section>
<section>
<div>
Boss: <select id="cboBosses"></select><label><input type="checkbox" id="chkHardMode" />Hard Mode</label>
<img id="selectedBoss" style="position: floating" align="right" />
</div>
<!--<br />
<div>
<table id="itemsTable">
<tr><th>Image</th><th>ID</th><th>Name</th><th>Chance</th><th>Hard mode?</th></tr>
</table>
</div>-->
<br />
<div>Character: <span id="charDescription"></span>
<table id="charTable"></table>
</div>
<br />
<table>
<tr>
<td>Weapon:</td>
<td><select id="cboWeapons"></select><img id="selectedWeapon" align="top" /></td>
</tr>
<tr>
<td>Armor:</td>
<td><select id="cboArmors"></select><img id="selectedArmor" align="top"/></td>
</tr>
<tr>
<td>Lifesteal:</td>
<td>
<select id="cboLifesteal">
<option>None</option>
<option>Small Recovery Necklace (2%)</option>
<option>Recovery Necklace (4%)</option>
</select>
</td>
</tr>
<tr>
<td>Player Level:</td>
<td><input type="text" id="txtPlayerLevel" value="16" style="width:20px" /></td>
</tr>
<tr>
<td>Character Level:</td>
<td><input type="text" id="txtCharLevel" value="6" style="width:20px" /></td>
</tr>
<tr>
<td>Stat Points per Level:</td>
<td><input type="text" id="txtStatPointsPerLevel" value="5" style="width:20px" /></td>
</tr>
<!-- <tr>
...
CSS
body {
margin: 1em;
font-size: 85%;
font-family: arial, helvetica, sans-serif;
}
.charCell {
cursor: pointer;
}
.slider {
width: 50;
height: 20;
}
input[type="text"] {
width: 10px;
text-align: right;
}
input[type="checkbox"] {
vertical-align: middle;
position: relative;
bottom: 1px;
}
.bad {
color: red;
}
.good {
color: green;
}
.unselectedCell {
border: 1px solid transparent;
}
.selectedCell {
border: 1px solid red;
}
p {
font-size: 1em;
margin: 0 0 .8em 0;
}
#chkMoveMenu {
width: 13px;
height: 13px;
padding: 0;
margin: 0;
vertical-align: bottom;
position: relative;
top: -1px;
*overflow: hidden;
}
.rightAligned {
position: absolute;
right: 55px;
}
.rightAligned2 {
position: absolute;
right: 30px;
}
.setName {
font-style: italic;
}
html>body {
font-size: 12px;
}
h1 {
font-weight: bold;
font-size: big;
}
th {
text-align: left;
padding: 1px 5px 0 0;
border-bottom: 1px solid gray;
padding: 3px;
}
td {
}
section {
font-size: 1em;
border: 3px solid white;
margin: 10px 0 0 0;
padding: 5px;
vertical-align: middle;
box-shadow: 0px 0px 20px 3px #d3d3d3;
border-radius: 4px;
background-color: #ffffff;
}
.best {
background-color: lightcyan;
font-weight: bold;
}
JavaScript
var selectedCharCell = null;
var accessorySets = [
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
]
var curSet = 0;
function $(str) { return document.getElementById(str) }
function runOpti()
{
clearLog();
print("Running opti")
var hardMode = $("chkHardMode").checked;
var bonuses = runSim();
var data = getPageData();
var weapon = weapons[data.weapon];
var armor = armors[data.armor];
var boss = bosses[data.bossIndex];
var eatk = hardMode ? boss.HardAttack : boss.Attack;
var bossHP = hardMode ? boss.HardHP : boss.HP;
print("Calc opti def")
var optiDef = eatk * (data.lifestealIndex == 2 ? 2.1 : data.lifestealIndex == 1 ? 3 : 5);
$("optimalDef").innerHTML = optiDef;
print("Calc dmg")
var averagedmgtaken = (eatk * 0.412) - (optiDef * 0.05);
var lifesteal = data.lifestealIndex == 1 ? .0148 : data.lifestealIndex == 2 ? .039 : 0;
var optimaldmg = averagedmgtaken / lifesteal;
var baseDmgTaken = (eatk*33/80)-(optiDef*3/56);
var maxDmgTaken = ((baseDmgTaken*1.1)+(eatk/40)+2);
print("Calc stats in def")
var statsInDef = Math.max(0,(optiDef-((data.accessDef+armor.BonusAmt)*(1+bonuses.Def)))/((3*bonuses.Def)+3));
var bestLS = null;
var prevTotalLevel = 999999999999;
for (var ls = 100; ls >= 0; ls--)
{
print("Calc LS " + ls)
var lsData = getLifeStealData(ls, baseDmgTaken, lifesteal, bossHP, data, statsInDef, maxDmgTaken, bonuses, weapon);
if (bestLS == null || lsData.totalLevel < bestLS.totalLevel)
bestLS = lsData;
if (lsData.totalLevel > prevTotalLevel)
break;
prevTotalLevel = lsData.totalLevel;
}
$("optimalAtk").innerHTML = Math.round(bestLS.requiredAtk);
$("optimalHP").innerHTML = Math.round(bestLS.requiredHP);
$("results").innerHTML = "Optimal Level: " + Math.round(bestLS.totalLevel);
fillinMissingData(bonuses);
}
function getLifeStealData(lsPct, baseDmgTaken, lsAmt, bossHP, data, statsInDef, maxDmgTaken, bonuses,...