Pet Stats

Developer
Size
10,939 Kb
Views
36,432

How do I make an pet stats?

What is a pet stats? How do you make a pet stats? This script and codes were developed by Steven on 11 August 2022, Thursday.

Pet Stats Previews

Pet Stats - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Pet Stats</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h2 align="center" style="margin-top: 10px;">King Midas Pet Battle Simulator</h2>
<div style="width: 80%; position: absolute; left: 10%; top: 15px;">Short Numbers <input type="checkbox" style="vertical-align: middle;" id="shortNum"></div>
<div class="inputs"> <div class="panel panel1"> <div class="stat"><label for="champion">Champion</label><select id="champion"></select></div> <div class="stat"><label for="petName">Pet Name</label><select id="petName"></select></div> <div class="stat"><label for="petLevel">Pet Level</label><select id="petLevel"></select></div> </div> <div class="panel panel2"> <label for="league">League</label> <select id="league"> <option value="1">Bronze</option> <option value="2">Silver</option> <option value="3" selected>Gold</option> <option value="4">Diamond</option> </select> <label for="division">Division</label> <select id="division"> <option value="1">I</option> <option value="2">II</option> <option value="3">III</option> <option value="4">IV</option> <option value="5">V</option> </select> <label for="battle">Battle</label><select id="battle"></select> </div> <div class="panel panel3"> <p style="margin-top: -10px;">Pet Upgrade Levels</p> <div class="stat"><label for="bpHP">Health</label><input type="number" min=0 id="bpHP" value=0 placeholder="LVL"></div> <div class="stat"><label for="bpATK">Attack</label><input type="number" min=0 id="bpATK" value=0 placeholder="LVL"></div> <div class="stat"><label for="bpDEF">Defence</label><input type="number" min=0 id="bpDEF" value=0 placeholder="LVL"></div> <br> <div class="stat"><label for="bpLifeSteal">LifeSteal</label><input type="number" min=0 id="bpLifeSteal" value=0 placeholder="LVL"></div> <div class="stat"><label for="bpBlock">Block</label><input type="number" min=0 id="bpBlock" value=0 placeholder="LVL"></div> <div class="stat"><label for="bpReflect">Reflect</label><input type="number" min=0 id="bpReflect" value=0 placeholder="LVL"></div> <p style="margin-top: 5px;">Total BP = <span id="totalBP"></span>. Spent BP = <span id="spentBP"></span>. Remaining BP = <span id="remainingBP"></span></p> </div> <div class="panel panel4"> <label for="useATK">Use Attack Potion</label><input type="checkbox" id="useATK"> <label for="useDEF">Use Defense Potion</label><input type="checkbox" id="useDEF"> <label for="useHP">Health Potions To Use</label><input type="number" id="useHP" min=0 max=32 value=0 title="Uses all up front. Increase slowly to best see results"> </div>
</div>
<div class="bottomContainer clearfix"> <div id="petStats" class="petPanel" style="margin-top: 10px;"> <table class="statTable"> <tr> <th style="text-align: left; padding-left: 5px;">Pet</th> <th>Base Stats</th> <th>Upgraded Stats</th> </tr> <tr> <td>Health</td> <td></td> <td></td> </tr> <tr> <td>Attack</td> <td></td> <td></td> </tr> <tr> <td>Defence</td> <td></td> <td></td> </tr> <tr> <td>LifeSteal</td> <td></td> <td></td> </tr> <tr> <td>Block</td> <td></td> <td></td> </tr> <tr> <td>Reflect</td> <td></td> <td></td> </tr> </table> </div> <div class="fightPanel"> <h3 style="margin-bottom: 6px;">Fight</h3> <div><p><span id="enemyName">Cave Bug</span></p><input disabled=true type="text" min=0 id="enemyHP"></div> <button class="fight" id="fight1">Simulate 1 Fight</button> <button class="fight" id="fight100">Simulate 100 Fights</button> <button class="fight" id="fight1000">Simulate 1000 Fights</button> </div>
</div>
<div id="battleLog"></div>
<div style="width: 80%; margin: auto; text-align: center">
<textarea id="massBattleLog"></textarea>
</div> <script src='js/rwyvlq.js'></script> <script src="js/index.js"></script>
</body>
</html>

Pet Stats - Script Codes CSS Codes

* { margin: 0; padding: 0; box-sizing: border-box;
}
body { min-width: 750px;
}
.inputs { border: solid blue 0.5px; background: lightblue; width: 80%; margin: 5px auto; padding: 5px; text-align: center;
}
label { display: inline-block; font-weight: bold; width: 80px;
}
.panel { margin: 5px;
}
.stat { width: 100px; display: inline-block;
}
.stat input { display: block; width: 100px;
}
.panel4 label { width: auto; margin-right: 5px; margin-left: 15px;
}
.panel4 input[type=checkbox] { vertical-align: middle;
}
input[type=number] { text-align: center;
}
.panel1 .stat, .panel1 .stat select { width: 200px;
}
.panel1 .stat:nth-child(1), .panel1 .stat:nth-child(1) select { width: 100px;
}
.panel1 .stat:nth-child(3), .panel1 .stat:nth-child(3) select { width: 100px;
}
.panel3 { padding: 10px; border: dashed black 0.5px;
}
#statContainer { border: solid 5px black;
}
.petPanel { float: left; width: 49%;
}
.fightPanel { float: right; width: 49%; text-align: center;
}
.fightPanel input { margin-top: 5px;
}
.bottomContainer { width: 80%; margin: auto;
}
.clearfix:after { content: ""; display: table; clear: both;
}
.statTable { width: 100%;
}
.statTable td { padding-left: 5px;
}
td:nth-child(2), td:nth-child(3) { text-align: center;
}
.fight { display: block; width: 50%; height: 20px; margin: 7px auto;
}
#battleLog { column-count: 2; background: rgba(170, 137, 82, 1); border: solid 1px black; width: 60%; margin: 10px auto; padding: 5px; padding-left: 50px; display: none;
}
#battleLog .header { font-weight: bold;
}
#battleLog table { width: 80%;
}
.battleOutput td { padding-right: 5px;
}
#massBattleLog { background: rgba(170, 137, 82, 1); border: solid 1px black; width: 60%; margin: 10px auto; padding: 5px; height: 500px; display: none; font-size: large;
}
#enemyHP { text-align: center;
}

Pet Stats - Script Codes JS Codes

let pet = (() => { let inputList = ["champion", "petName", "petLevel", "league", "division", "battle", "bpHP", "bpATK", "bpDEF", "bpLifeSteal", "bpBlock", "bpReflect", "useATK", "useDEF", "useHP", "enemyHP", "shortNum"]; let input = {}; for (let each of inputList) { input[each] = document.getElementById(each); } // Edit the things that make sense under here. Leave any that start with get alone. Case sensitive :) // Same inputs as in spreadsheet let petObject = { petName: "Bloodthirsty Tiger", petLevel: 4, champion: "Lin", useATK: true, useDEF: true, useHP: 0, bpHP: 26, // LVL of your Health upgrades bpATK: 26, bpDEF: 4, bpLifeSteal: 9, bpBlock: 8, bpReflect: 0, enemyHP: 6e12, get championMult() { return championList[this.champion] }, get petMult() { return Math.pow(6, petList.indexOf(this.petName)) }, get levelMult() { return 0.2*(this.petLevel-1)+1 }, get HP() { return 720*this.championMult*this.petMult*this.levelMult }, get ATK() { return 62*this.championMult*this.petMult*this.levelMult }, get DEF() { return 24*this.championMult*this.petMult*this.levelMult }, get lifeSteal() { return 51*this.championMult*this.petMult*this.levelMult }, get block() { return 42*this.championMult*this.petMult*this.levelMult }, get reflect() { return 54*this.championMult*this.petMult*this.levelMult }, get upgradedHP() { return this.HP * (1+this.bpHP*0.1) }, get upgradedATK() { return this.ATK * (1+this.bpATK*0.1) }, get upgradedDEF() { return this.DEF * (1+this.bpDEF*0.1) }, get upgradedLifeSteal() { return this.lifeSteal * (1+this.bpLifeSteal*0.1) }, get upgradedBlock() { return this.block * (1+this.bpBlock*0.1) }, get upgradedReflect() { return this.reflect * (1+this.bpReflect*0.1) }, }
let enemyStats = { 1: { 1: [6.400e+02, 9.880e+02, 1.270e+03, 1.600e+03, 4.500e+03], 2: [6.000e+03, 8.500e+03, 1.050e+04, 1.300e+04, 1.500e+04, 3.000e+04], 3: [6.000e+04, 8.000e+04, 1.100e+05, 1.300e+05, 1.500e+05, 1.650e+05, 3.000e+05], 4: [6.000e+05, 1.000e+06, 1.200e+06, 1.300e+06, 1.400e+06, 1.600e+06, 1.900e+06, 4.200e+06], 5: [7.200e+06, 9.200e+06, 1.300e+07, 1.400e+07, 1.500e+07, 1.600e+07, 1.700e+07, 1.900e+07, 4.300e+07], }, 2: { 1: [1.200e+08, 1.300e+08, 1.500e+08, 1.600e+08, 1.800e+08, 2.100e+08, 2.300e+08, 2.500e+08, 3.000e+08, 6.300e+08], 2: [1.000e+09, 1.100e+09, 1.200e+09, 1.500e+09, 1.700e+09, 1.800e+09, 2.000e+09, 2.300e+09, 2.800e+09, 3.000e+09, 6.200e+09], 3: [1.000e+10, 1.100e+10, 1.200e+10, 1.500e+10, 1.700e+10, 1.800e+10, 2.000e+10, 2.300e+10, 2.500e+10, 2.700e+10, 2.800e+10, 6.800e+10], 4: [1.000e+11, 1.100e+11, 1.200e+11, 1.300e+11, 1.500e+11, 1.700e+11, 1.800e+11, 2.000e+11, 2.200e+11, 2.300e+11, 2.700e+11, 3.000e+11, 5.00e+11], 5: [6.000e+11, 6.500e+11, 7.000e+11, 8.300e+11, 9.000e+11, 1.000e+12, 1.100e+12, 1.200e+12, 1.400e+12, 1.500e+12, 1.600e+12, 1.700e+12, 1.900e+12, 4.000e+12], }, 3: { 1: [5.000e+12, 5.500e+12, 6.000e+12, 6.500e+12, 7.000e+12, 7.500e+12, 8.500e+12, 9.000e+12, 1.000e+13, 1.100e+13, 1.300e+13, 1.400e+13, 1.500e+13, 1.700e+13, 3.700e+13], 2: [4.000e+13, 4.500e+13, 5.000e+13, 5.500e+13, 7.000e+13, 7.500e+13, 8.000e+13, 8.500e+13, 9.000e+13, 9.500e+14, 1.000e+14, 1.050e+14, 1.100e+14, 1.120e+14, 1.150e+14, 2.000e+14], 3: [2.100e+14, 2.200e+14, 2.300e+14, 2.400e+14, 2.600e+14, 2.800e+14, 3.000e+14, 3.500e+14, 3.800e+14, 4.400e+14, 4.600e+14, 4.800e+14, 5.200e+14, 5.400e+14, 6.050e+14, 6.900e+14, 1.300e+15], 4: [1.700e+15, 2.200e+15, 2.300e+15, 2.700e+15, 3.600e+15, 4.000e+15, 4.500e+15, 4.800e+15, 4.900e+15, 5.000e+15, 5.100e+15, 5.200e+15, 5.300e+15, 5.400e+15, 5.500e+15, 5.600e+15, 6.100e+15, 1.300e+16], 5: [2.000e+16, 2.200e+16, 2.300e+16, 2.400e+16, 2.500e+16, 2.700e+16, 2.800e+16, 2.900e+16, 3.100e+16, 3.400e+16, 3.600e+16, 4.000e+16, 4.300e+16, 4.600e+16, 4.800e+16, 5.000e+16, 5.500e+16, 5.700e+16, 1.400e+17], }, 4: { 1: [2.000e+17, 2.200e+17, 2.300e+17, 2.400e+17, 2.500e+17, 2.600e+17, 2.700e+17, 2.800e+17, 2.900e+17, 3.000e+17, 3.400e+17, 3.600e+17, 3.900e+17, 4.500e+17, 4.700e+17, 5.400e+17, 5.800e+17, 6.400e+17, 6.700e+17, 1.200e+18], 2: [1.800e+18, 1.900e+18, 2.000e+18, 2.200e+18, 2.300e+18, 2.400e+18, 2.500e+18, 2.600e+18, 2.700e+18, 2.800e+18, 2.900e+18, 3.000e+18, 3.300e+18, 3.400e+18, 3.900e+18, 4.000e+18, 4.400e+18, 4.800e+18, 5.500e+18, 6.600e+18, 1.700e+19], 3: [2.000e+19, 2.200e+19, 2.400e+19, 2.600e+19, 2.800e+19, 3.000e+19, 3.300e+19, 3.500e+19, 3.900e+19, 4.400e+19, 4.600e+19, 4.700e+19, 5.000e+19, 5.500e+19, 6.000e+19, 6.500e+19, 7.500e+19, 8.000e+19, 8.500e+19, 9.000e+19, 9.500e+19, 2.000e+20], 4: [2.100e+20, 2.200e+20, 2.300e+20, 2.400e+20, 2.500e+20, 2.600e+20, 2.700e+20, 2.800e+20, 2.900e+20, 3.000e+20, 3.100e+20, 3.200e+20, 3.300e+20, 3.400e+20, 3.500e+20, 3.600e+20, 3.700e+20, 3.800e+20, 3.900e+20, 4.000e+20, 4.100e+20, 4.200e+20, 6.100e+20], 5: [6.500e+20, 6.800e+20, 7.200e+20, 7.400e+20, 7.600e+20, 7.800e+20, 8.000e+20, 8.200e+20, 8.400e+20, 8.600e+20, 8.800e+20, 9.000e+20, 9.200e+20, 9.400e+20, 9.800e+20, 1.000e+21, 1.050e+21, 1.100e+21, 1.200e+21, 1.300e+21, 1.350e+21, 1.400e+21, 1.500e+21, 2.400e+21], }
};
let enemyNames = ["Cave Bug", "Sharpbeak", "Great Tarantula", "Tunnel Minion", "Goblin Gladiator", "Desert Scorpion", "Eyeball Terror", "Seashore Goblin", "Robotic Gatekeeper", "Swarm Beast", "Ancient Cyclops", "Valhalla Devourer", "Druid Hermit", "Alien Insect", "Fearless Zombie", "Mountain Troll King", "Undead Warrior", "Orc Overlord", "Lava Annihilator", "The Unbreakable", "Evil Shaman", "Soul Drainer", "Underworld Soulkeeper", "Shadow King"]; let petList = ["Midaeum Gardens Parrot", "Wild Mountain Boar", "Bonebreaker Python", "Lake Lizard", "Royal Eagle", "Gastonia Defender", "Elephant Fighter", "Fullmoon Werewolf", "Bloodthirsty Tiger", "Rhino of the Valley", "Flameguard Goblin", "Poisonous Hydra", "Snowmountain Yeti", "Astral Pegasus", "Swarm Soldier", "Lava Hound", "Forest Keeper", "Armored Nightmare", "Crystal Golem", "Dragon of the Void"]; let championList = { "Gilligan": 1, "Audrey": 1, "Scarlet": 1.50, "Irwin": 3.10, "Kenny": 4.60, "Adeline": 6.30, "Valeria": 8.70, "Aurelius": 12.20, "Felix": 18.00, "Felice": 27.00, "Tempestus": 40.80, "Sylvar": 59.20, "Benedict": 90.40, "Lin": 541.00, "Volv": 3201.00, } let upgradeCosts = { 0: 0, 1: 1, 2: 3, 3: 6, 4: 10, 5: 15, 6: 21, 7: 28, 8: 36, 9: 45, 10: 55, 11: 67, 12: 81, 13: 97, 14: 115, 15: 135, 16: 157, 17: 181, 18: 207, 19: 235, 20: 265, 21: 298, 22: 334, 23: 373, 24: 415, 25: 460, 26: 508, 27: 559, 28: 613, 29: 670, 30: 730, 31: 794, 32: 862, 33: 934, 34: 1010, 35: 1090, 36: 1174, 37: 1262, 38: 1354, 39: 1450, 40: 1550, 41: 1655, 42: 1765, 43: 1880, 44: 2000, 45: 2125, 46: 2255, 47: 2390, 48: 2530, 49: 2675, 50: 2825, 51: 2981, 52: 3143, 53: 3311, 54: 3485, 55: 3665, 56: 3851, 57: 4043, 58: 4241, 59: 4445, 60: 4655, 61: 4872, 62: 5096, 63: 5327, 64: 5565, 65: 5810, 66: 6062, 67: 6321, 68: 6587, 69: 6860, }; function populateDropdowns() { for(let keys in championList) { let el = document.createElement("option"); el.textContent = keys; el.value = championList[keys]; input.champion.appendChild(el); } for(let i=0; i <petList.length; i++) { let el = document.createElement("option"); el.textContent = `[${i+1< 10 ? "0" : ""}${i+1}] ${petList[i]}`; el.value = petList[i]; input.petName.appendChild(el); } for(let i=1; i <= 10; i++) { let el = document.createElement("option"); el.textContent = `${i}`; el.value = i; input.petLevel.appendChild(el); } } function updateBattleList() { let leagueNo = Number(input.league.options[input.league.selectedIndex].value); let divisionNo = Number(input.division.options[input.division.selectedIndex].value); input.battle.innerHTML = ""; let lvl = ((leagueNo-1)*5)+divisionNo; let battleTotal = 4+lvl; for(let i=1; i <= battleTotal; i++) { let el = document.createElement("option"); el.textContent = `${i}`; el.value = i; input.battle.appendChild(el); } input.battle.selectedIndex = localStorage.getItem("battle") || 0 } function updateTotalBP() { let leagueNo = Number(input.league.options[input.league.selectedIndex].value); let divisionNo = Number(input.division.options[input.division.selectedIndex].value); let battleNo = localStorage.getItem("battle") || 0; let lvl = ((leagueNo-1)*5)+divisionNo; let bpTotal = 0; let bossBP = 4; for (let i = 0; i < lvl-1; i++) { bpTotal = bpTotal + ((4+i) * (i+1)); bpTotal += bossBP; bossBP += 6+(2*(i)) } bpTotal += lvl * (battleNo); let HPCost = upgradeCosts[Number(input.bpHP.value)]; let ATKCost = upgradeCosts[Number(input.bpATK.value)]; let DEFCost = upgradeCosts[Number(input.bpDEF.value)]; let LifeStealCost = upgradeCosts[Number(input.bpLifeSteal.value)]; let BlockCost = upgradeCosts[Number(input.bpBlock.value)]; let ReflectCost = upgradeCosts[Number(input.bpReflect.value)]; let totalCost = HPCost+ATKCost+DEFCost+LifeStealCost+BlockCost+ReflectCost; let remaining = bpTotal - totalCost; document.getElementById("totalBP").innerHTML = bpTotal; document.getElementById("spentBP").innerHTML = totalCost; document.getElementById("remainingBP").innerHTML = remaining; petObject.bpTotal = bpTotal; petObject.bpRemaining = remaining; document.getElementById("enemyName").innerHTML = enemyNames[battleNo]; input.enemyHP.value = outputNum(enemyStats[leagueNo][divisionNo][battleNo]); buildSuggestedStatString(); } // Returns exponent part of number. Eg 24e47 - returns 47. 10 returns 1. function getExp(num) { return Math.floor(Math.log(num)/Math.log(10)); } function midasNum(num) { if (num === undefined) return 0; if (Number(num) < 1000) return num.toFixed(1); // Plain numbers if super low let expCount = getExp(num+1); // num + 1 Solves rounding issue at dead on 1000. 10000. etc let str = num.toPrecision(5).split(""); let firstDigit = str.shift(); // First number let rest = ""; // Next two numbers. str.shift(); // Throw away the dot if (expCount % 3 === 0) { // Position dot where required. rest = `.${str.shift()}${str.shift()}`; } if (expCount % 3 === 1) { rest = `${str.shift()}.${str.shift()}`; } if (expCount % 3 === 2) { rest = `${str.shift()}${str.shift()}`; } return `${firstDigit+rest} ${getNumberNotation(expCount, 3)}`; } function simulateBattle(petObject, fights) { const doLifeSteal = petList.indexOf(petObject.petName) > 0; const lifeStealChance = 0.25; const lifeSteal = petObject.upgradedLifeSteal; const doBlock = petList.indexOf(petObject.petName) > 2; const blockChance = 0.3; const block = petObject.upgradedBlock; const doReflect = petList.indexOf(petObject.petName) > 5; const reflectChance = 0.3; const reflect = petObject.upgradedReflect; let petHP = petObject.upgradedHP; petHP = petHP * (1 + (petObject.useHP * 0.25)); let petDMG = (petObject.useATK) ? petObject.upgradedATK * 1.5 : petObject.upgradedATK; let useDEF = petObject.useDEF; let DEF = petObject.upgradedDEF; //petObject.e let leagueNo = Number(input.league.options[input.league.selectedIndex].value); let divisionNo = Number(input.division.options[input.division.selectedIndex].value); let battleNo = localStorage.getItem("battle") || 0; let enemyHP = enemyStats[leagueNo][divisionNo][battleNo]; let enemyMinDMG = enemyHP / 8; let enemyMaxDMG = enemyMinDMG * 1.11; // Using 11% improves accuracy? let enemyDMG = 0; let round = 1; let results = { Won: 0, Lost: 0, lowEnemyHP: 1e100, WHP: 0}; // WHP: 0 let outputString = ``; if (fights === 1) { document.getElementById("massBattleLog").style.display = "none"; } else { document.getElementById("battleLog").style.display = "none"; } for (let i = 0; i< fights; i++) { petHP = petObject.upgradedHP; petHP = petHP * (1 + (petObject.useHP * 0.25)); petDMG = (petObject.useATK) ? petObject.upgradedATK * 1.5 : petObject.upgradedATK; enemyHP = petObject.enemyHP; round = 1; while (petHP > 0 && enemyHP > 0) { doRound(); } } if (fights === 1) { document.getElementById("battleLog").style.display = "block"; outputString += `</table>`; if (results.Won > 0) { outputString += `<p style="font-weight: bold; text-align: center">WON</p>`; } else { outputString += `<p style="font-weight: bold; text-align: center">LOST</p>`; } document.getElementById("battleLog").innerHTML = outputString; } function doRound() { let roundWon = false; if (fights === 1) { outputString += `<table class="battleOutput"><tr><th colspan=2>` outputString += `Round ${round}</th></tr>`; outputString += `<tr><td>Pet HP</td><td> ${outputNum(petHP)}</td>`; outputString += `<tr><td>Enemy HP</td><td>${outputNum(enemyHP)}</td></tr>`; } //console.log("\Before Round " + round) //console.log("PET HP", outputNum(petHP, false), outputNum(petHP)); //console.log("ENEMY HP", outputNum(enemyHP, false), outputNum(enemyHP)); enemyDMG = rangeMap(Math.random(), 0, 1, enemyMinDMG, enemyMaxDMG); enemyDMG = enemyDMG - DEF; enemyDMG = (useDEF) ? enemyDMG * 0.5 : enemyDMG; enemyHP -= petDMG; // Pet hits outputString += `<tr><td>Pet Attacks</td><td> ${outputNum(petDMG)}</td></tr>`; if (doLifeSteal && Math.random() < lifeStealChance) { // Steal life outputString += `<tr><td>LifeSteal</td><td> ${outputNum(lifeSteal)}</td></tr>`; petHP += lifeSteal; } if (enemyHP <= 0 && !roundWon) { // Enemy dead? we win since we go first results.Won = results.Won + 1 || 1; roundWon = true; } outputString += `<tr><td>Enemy Attacks</td><td> ${outputNum(enemyDMG)}</td></tr>`; petHP -= enemyDMG; // Enemy Hits if (doReflect && Math.random() < reflectChance && petHP > 0) { // Reflect Hits outputString += `<tr><td>Reflect</td><td> ${outputNum(reflect)}</td></tr>`; enemyHP -= reflect; } if (enemyHP <= 0 && !roundWon) { // Enemy dead? we win since we go first results.Won = results.Won + 1 || 1; roundWon = true; } if (doBlock && Math.random() < blockChance) { // Block (-enemy DMG) outputString += `<tr><td>Block</td><td> ${outputNum(block)}</td></tr>`; petHP += block; } if (enemyHP > 0 && petHP <= 0) { // Enemy Alive & pet dead? we lost. results.Lost = results.Lost + 1 || 1; } if (petHP < 0 || enemyHP < 0) { results.Count = results.Count + 1 || 1; results.lowEnemyHP = (results.lowEnemyHP > enemyHP) ? enemyHP : results.lowEnemyHP; if (enemyHP > 0) { results.WHP = results.WHP + enemyHP; //console.log(results.WHP); } //console.log(results.WHP) if (fights === 1) { outputString += `<table class="battleOutput"><tr><th colspan=2>` outputString += `After Round ${round}</th></tr>`; outputString += `<tr><td>Pet HP</td><td> ${outputNum(petHP)}</td>`; outputString += `<tr><td>Enemy HP</td><td>${outputNum(enemyHP)}</td></tr></table>`; } } else { // Made it through this round } results[`Round ${round < 10 ? "0" : ""}${round}`] = results[`Round ${round < 10 ? "0" : ""}${round}`] + 1 || 1; round += 1; } let battleLogString = ``; battleLogString += `Overall a ${((results.Won/results.Count)*100).toFixed(2)}% chance of winning the battle with the above stats.\n` battleLogString += `\nBelow shows chances of reaching Round x before fight ends.`; battleLogString += `\n`; battleLogString += `\n`; //console.log("Game shows Round XX before fight is over") for (let key in results) { if (key.indexOf("Round") > -1) { let outstring = ``; outstring += `${key} - ${" ".repeat(results.Count.toString().length - results[key].toString().length)}${results[key]} / `; outstring += `${results.Count}\t${((results[key]/results.Count)*100).toFixed(2)}%`; battleLogString += outstring; battleLogString += `\n`; } } battleLogString += `\n`; for (let key in results) { if (key.indexOf("Round") === -1 && key !== "lowEnemyHP" && key !== "WHP") { let outstring = ``; outstring += `${key}\t- ${" ".repeat(results.Count.toString().length - results[key].toString().length)}${results[key]} / `; outstring += `${results.Count}\t${((results[key]/results.Count)*100).toFixed(2)}%`; battleLogString += outstring; battleLogString += `\n`; } } battleLogString += `\n`; battleLogString += `Lowest Enemy HP = ${outputNum(results.lowEnemyHP, false)}`; battleLogString += `\n\n`; if (results.Won < results.Count / 2) { let estimate = (results.WHP/results.Count) / (petDMG + (reflect*0.3)); battleLogString += `You would need to survive roughly ${Math.ceil(estimate)} more rounds to win this battle.`; } if (fights !== 1) { document.getElementById("massBattleLog").style.display = "block"; document.getElementById("massBattleLog").innerHTML = battleLogString; } } function rangeMap (input, in_min, in_max, out_min, out_max) { return (input - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } function outputNum(num, midasShortNo=true) { if (input.shortNum.checked) { return midasNum(num) } return num.toExponential(3); } // Auto select input content Array.from(document.querySelectorAll("input")) .forEach((each) => each.addEventListener("click", () => each.select())); function saveToLocalStorage() { inputList.forEach((each) => { if (input[each].options) { localStorage.setItem(each, input[each].selectedIndex); } else if (input[each].type === "checkbox") { localStorage.setItem(each, input[each].checked); } else { localStorage.setItem(each, input[each].value); } }); } function updatePetObject() { petObject.petName = input.petName.options[input.petName.selectedIndex].value; petObject.petLevel = input.petLevel.options[input.petLevel.selectedIndex].value; petObject.champion = input.champion.options[input.champion.selectedIndex].text; petObject.useATK = input.useATK.checked; petObject.useDEF = input.useDEF.checked; petObject.useHP = Number(input.useHP.value); petObject.bpHP = Number(input.bpHP.value); petObject.bpATK = Number(input.bpATK.value); petObject.bpDEF = Number(input.bpDEF.value); petObject.bpLifeSteal = Number(input.bpLifeSteal.value); petObject.bpBlock = Number(input.bpBlock.value); petObject.bpReflect = Number(input.bpReflect.value); let leagueNo = Number(input.league.options[input.league.selectedIndex].value); let divisionNo = Number(input.division.options[input.division.selectedIndex].value); let battleNo = localStorage.getItem("battle") || 0; petObject.enemyHP = enemyStats[leagueNo][divisionNo][battleNo]; const doLifeSteal = petList.indexOf(petObject.petName) > 0; const doBlock = petList.indexOf(petObject.petName) > 2; const doReflect = petList.indexOf(petObject.petName) > 5; let baseStats = document.querySelectorAll("td:nth-child(2)"); baseStats[0].innerHTML = outputNum(petObject.HP); baseStats[1].innerHTML = outputNum(petObject.ATK); baseStats[2].innerHTML = outputNum(petObject.DEF); baseStats[3].innerHTML = (doLifeSteal) ? outputNum(petObject.lifeSteal) : ""; baseStats[4].innerHTML = (doBlock) ? outputNum(petObject.block) : ""; baseStats[5].innerHTML = (doReflect) ? outputNum(petObject.reflect) : ""; let upgradedStats = document.querySelectorAll("td:nth-child(3)"); upgradedStats[0].innerHTML = outputNum(petObject.upgradedHP); upgradedStats[1].innerHTML = outputNum(petObject.upgradedATK); upgradedStats[2].innerHTML = outputNum(petObject.upgradedDEF); upgradedStats[3].innerHTML = (doLifeSteal) ? outputNum(petObject.upgradedLifeSteal) : ""; upgradedStats[4].innerHTML = (doBlock) ? outputNum(petObject.upgradedBlock) : ""; upgradedStats[5].innerHTML = (doReflect) ? outputNum(petObject.upgradedReflect) : ""; } document.body.addEventListener("click", () => { saveToLocalStorage(); updatePetObject(); updateTotalBP(); }); document.body.addEventListener("input", () => { saveToLocalStorage(); updatePetObject(); updateTotalBP(); }); input.league.addEventListener("change", () => { updateBattleList(); }); input.division.addEventListener("change", () => { updateBattleList(); }); function loadSaved() { inputList.forEach((each) => { if (input[each].options) { input[each].selectedIndex = localStorage.getItem(each) || 0; } else if (input[each].type === "checkbox") { if (localStorage.getItem(each) === "true") { // Stupid strings. input[each].checked = true; } else { input[each].checked = false; } } else { input[each].value = localStorage.getItem(each) || 0; } }); } document.getElementById("fight1").addEventListener("click", () => simulateBattle(petObject, 1)); document.getElementById("fight100").addEventListener("click", () => simulateBattle(petObject, 100)); document.getElementById("fight1000").addEventListener("click", () => simulateBattle(petObject, 1000)); function buildSuggestedStatString() {
// let suggested = {
// HP: 0, ATK: 0, DEF: 0, lifeSteal: 0, block: 0, reflect: 0
// };
// function bpUsed() {
// let total = 0;
// total += upgradeCosts[suggested.HP];
// total += upgradeCosts[suggested.ATK];
// total += upgradeCosts[suggested.DEF];
// total += upgradeCosts[suggested.lifeSteal];
// total += upgradeCosts[suggested.block];
// total += upgradeCosts[suggested.reflect];
// return total;
// }
// let counter = 0;
// let bpTotal = petObject.bpTotal;
// // Assuming ratio 100 100 25 25 25 0. Total 275. Ask Grim :)
// let HPGoal = (Math.floor((1/2.75)*bpTotal < 1)) ? 1 : Math.floor((1/2.75)*bpTotal);
// counter = 0;
// while(upgradeCosts[counter] < HPGoal) {
// counter++
// }
// counter--; // Hacky...
// suggested.HP = counter;
// suggested.ATK = counter;
// let lifeStealGoal = (Math.floor((0.25/2.75)*bpTotal < 1)) ? 1 : Math.floor((0.25/2.75)*bpTotal);
// counter = 0;
// while(upgradeCosts[counter] < lifeStealGoal) {
// counter++
// }
// counter--; // Hacky...
// suggested.lifeSteal = counter;
// suggested.block = counter;
// let defGoal = (petObject.useDEF) ? (Math.floor((0.125/2.75)*bpTotal < 1)) ? 1 : Math.floor((0.125/2.75)*bpTotal)
// : (Math.floor((0.25/2.75)*bpTotal < 1)) ? 1 : Math.floor((0.25/2.75)*bpTotal);
// counter = 0;
// while(upgradeCosts[counter] < defGoal) {
// counter++
// }
// counter--; // Hacky...
// suggested.DEF = counter;
// console.clear();
// console.log(suggested.HP);
// console.log(suggested.ATK);
// console.log(suggested.DEF);
// console.log(suggested.lifeSteal);
// console.log(suggested.block);
// console.log(suggested.reflect);
// console.log(`BP Used = ${bpUsed()}`);
// console.log(`BP Remaining = ${bpTotal - bpUsed()}`); } function init() { populateDropdowns(); updateBattleList(); loadSaved(); updateTotalBP(); updatePetObject(); updateBattleList(); updateTotalBP(); buildSuggestedStatString(); } return { init }
})();
pet.init();
Pet Stats - Script Codes
Pet Stats - Script Codes
Home Page Home
Developer Steven
Username volv
Uploaded August 11, 2022
Rating 3
Size 10,939 Kb
Views 36,432
Do you need developer help for Pet Stats?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Steven (volv) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!