QS Dungeon Sim
by path411
HTML
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<div class="fluid-container">
<div class="row">
<div class="col">
<input id="dungeonlvl" placeholder="Dungeon Level" />
</div>
</div>
<div class="row">
<div class="col">
<h2>
Fighters (Enter cost in thousands):
</h2>
</div>
</div>
<div class="row">
<div class="col-12">
Crusader: <br/>
Health: <input id="cHealth" value="2250" /><br/>
Defense: <input id="cDefense" value="1000" /><br/>
Damage: <input id="cDamage" value="10" /><br/>
Crit Damage: <input id="cCritDamage" value="10" /><br/>
Hit: <input id="cHit" value="10" /><br/>
Dodge: <input id="cDodge" value="1500" /><br/>
</div>
<div class="col-12 mt-4">
Warrior: <br/>
Health: <input id="wHealth" value="10"/><br/>
Defense: <input id="wDefense" value="10"/><br/>
Damage: <input id="wDamage" value="2000"/><br/>
Crit Damage: <input id="wCritDamage" value="200"/><br/>
Hit: <input id="wHit" value="1000"/><br/>
Dodge: <input id="wDodge" value="10"/><br/>
</div>
<div class="col-12 mt-4">
Wizard: <br/>
Health: <input id="zHealth" value="10"/><br/>
Defense: <input id="zDefense" value="10"/><br/>
Damage: <input id="zDamage" value="10"/><br/>
Crit Damage: <input id="zCritDamage" value="10"/><br/>
Hit: <input id="zHit" value="10"/><br/>
Dodge: <input id="zDodge" value="10"/><br/>
...
CSS
html, body {
font-size: 14px;
}
TypeScript
const iterations = 10000;
const statScaling = {
Health: 100,
Defense: 10,
Damage: 25,
CritDamage: 0.25,
Hit: 50,
Dodge: 50
};
function Main() {
BindEvents();
}
function BindEvents() {
$('#startSim').on('click', function() {
var sim = new Sim();
sim.Start();
});
}
$(function() {
Main();
});
class Sim {
private Crusader:Fighter;
private Warrior:Fighter;
private Wizard:Fighter;
private Fighters:Fighter[] = [];
private Monsters:Monster[] = [];
private DungeonLevel:number;
public Wins:number = 0;
public Losses:number = 0;
public SimCount: number = 0;
constructor() {
this.Crusader = new Fighter("c");
this.Warrior = new Fighter("w");
this.Wizard = new Fighter("z");
this.Fighters.push(this.Crusader);
this.Fighters.push(this.Warrior);
this.Fighters.push(this.Wizard);
}
public LoadData(): void {
this.Fighters.forEach(function(f:Fighter) {
["Health", "Defense", "Damage", "CritDamage", "Hit", "Dodge"].forEach(function(stat:string) {
let v = parseInt($('#'+f.Type+stat).val());
let c = (v/10) - 10;
f[stat] += (c * statScaling[stat]);
f[stat] = Math.round(f[stat] * 1.75);
});
f.MHealth = f.Health;
});
this.DungeonLevel = parseInt($('#dungeonlevel'), 10);
if(this.DungeonLevel < 51) {
let mcount = 1;
}
else if(this.DugeonLevel < 126) {
let mcount = 2;
}
else if(this.DungeonLevel < 201) {
let mcount = 3;
}
else if(this.DungeonLevel < 276) {
let mcount = 4;
}
else if(this.DungeonLevel < 351) {
let mcount = 5;
}
else {
let mcount = 6;
}
for(let i=0; i<mcount; i++) {
let m = new Monster(this.DungeonLevel - (i*25));
...