Skip to content

Commit

Permalink
Display recoil and drain values
Browse files Browse the repository at this point in the history
  • Loading branch information
anastarawneh committed Oct 30, 2024
1 parent f280bcd commit 9113c72
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hacks.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@
</div>
<div class="small-text"><span id="damageValues">(If you see this message for more than a few seconds, try enabling JavaScript.)</span>
</div>
<div class="small-text"><span id="recoilValues" class="hide"></span>
</div>
<div class="small-text"><span id="drainValues" class="hide"></span>
</div>
</div>

<div aria-label="Pok&eacute;mon 1" class="panel" role="region">
Expand Down
4 changes: 4 additions & 0 deletions src/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@
</div>
<div class="small-text"><span id="damageValues">(If you see this message for more than a few seconds, try enabling JavaScript.)</span>
</div>
<div class="small-text"><span id="recoilValues" class="hide"></span>
</div>
<div class="small-text"><span id="drainValues" class="hide"></span>
</div>
</div>

<div aria-label="Pok&eacute;mon 1" class="panel" role="region">
Expand Down
26 changes: 26 additions & 0 deletions src/js/index_randoms_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ $(".result-move").change(function () {
if (desc.indexOf('--') === -1) desc += ' -- possibly the worst move ever';
$("#mainResult").text(desc);
$("#damageValues").text("Possible damage amounts: (" + displayDamageHits(result.damage) + ")");
if (game == "Emerald Kaizo") {
if (result.move.recoil && !result.attacker.hasAbility("Rock Head") && (result.damage > 0 || result.damage[0] > 0)) {
$("#recoilValues").show().text("Possible recoil amounts: (" + displayRecoilHits(result.damage, result.move.recoil) + ")");
} else {
$("#recoilValues").hide();
}
if (result.move.drain && !result.defender.hasAbility("Liquid Ooze") && (result.damage > 0 || result.damage[0] > 0)) {
$("#drainValues").show().text("Possible drain amounts: (" + displayRecoilHits(result.damage, result.move.drain) + ")");
} else {
$("#drainValues").hide();
}
}
}
}
});
Expand All @@ -228,6 +240,20 @@ function displayDamageHits(damage) {
return '1st Hit: ' + damage[0].join(', ') + '; 2nd Hit: ' + damage[1].join(', ');
}

function displayRecoilHits(damage, recoil) {
// Fixed Damage
if (typeof damage === 'number') return Math.max(Math.floor(damage * recoil[0] / recoil[1]), 1);
// Standard Damage
if (damage.length > 2) return damage.map(x => Math.max(Math.floor(x * recoil[0] / recoil[1]), 1)).join(', ');
}

function displayDrainHits(damage, drain) {
// Fixed Damage
if (typeof damage === 'number') return Math.max(Math.floor(damage * drain[0] / drain[1]), 1);
// Standard Damage
if (damage.length > 2) return damage.map(x => Math.max(Math.floor(x * drain[0] / drain[1]), 1)).join(', ');
}

function findDamageResult(resultMoveObj) {
var selector = "#" + resultMoveObj.attr("id");
for (var i = 0; i < resultLocations.length; i++) {
Expand Down

0 comments on commit 9113c72

Please sign in to comment.