Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added field button to account for Tailwind #126

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!doctype HTML>
<html lang="us">
<link rel="icon" type="image/png" href="image_res/favicon.ico">
<link rel="icon" type="image/png" href="image_res/favicon.ico" />
<link rel="stylesheet" href="styles/variables.css">
<link rel="stylesheet" href="styles/aStyle.css">

<link rel="image_src" href="https://damagecalc.trainertower.com/image_res/logo.png" />
<html xmlns="http://www.w3.org/1999/xhtml"
Expand Down Expand Up @@ -75,6 +77,11 @@
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></div> -->
<div class="moveTest">
<div class="moveType">
<img src="./styles/type-icons/Normal.png" alt="Normal">
</div>
<p>Tackle</p></div>
<div class="move-result-group" title="Select a move to show detailed results.">
<div class="move-result-subgroup">
<div class="result-move-header"><span id="resultHeaderL">Pokemon 1's Moves (select one to show detailed results)</span></div>
Expand Down Expand Up @@ -320,6 +327,14 @@ <h4 class="panel-title">Field
<input class="btn-input calc-trigger" type="checkbox" id="helpingHandR" /><label class="btn btn-xxwide" for="helpingHandR">Helping Hand</label>
</div>
</div>
<div class="btn-group gen-specific g4 g5 g6 g7 g8">
<div class="left" title="Has this Pokemon's speed been boosted by Tailwind?">
<input class="btn-input calc-trigger" type="checkbox" id="tailwindL" /><label class="btn btn-xxwide" for="tailwindL">Tailwind</label>
</div>
<div class="right" title="Has this Pokemon's speed been boosted by Tailwind?">
<input class="btn-input calc-trigger" type="checkbox" id="tailwindR" /><label class="btn btn-xxwide" for="tailwindR">Tailwind</label>
</div>
</div>
<div class="btn-group gen-specific g7 g8">
<div class="left" title="Has this Pokemon's power been boosted by an ally's Battery?">
<input class="btn-input calc-trigger" type="checkbox" id="batteryL" /><label class="btn btn-xxwide" for="batteryL">Battery</label>
Expand All @@ -336,14 +351,6 @@ <h4 class="panel-title">Field
<input class="btn-input calc-trigger" type="checkbox" id="friendGuardR" /><label class="btn btn-xxwide" for="friendGuardR">Friend Guard</label>
</div>
</div>
<div class="btn-group gen-specific g8">
<div class="left" title="Is this Pokemon boosted by an ally's Power Spot?">
<input class="btn-input calc-trigger" type="checkbox" id="powerSpotL" /><label class="btn btn-xxwide" for="powerSpotL">Power Spot</label>
</div>
<div class="right" title="Is this Pokemon boosted by an ally's Power Spot?">
<input class="btn-input calc-trigger" type="checkbox" id="powerSpotR" /><label class="btn btn-xxwide" for="powerSpotR">Power Spot</label>
</div>
</div>

<div class="btn-group gen-specific g7 g8">
<div class="left" title="Has this Pokemon used Geomancy?">
Expand Down Expand Up @@ -519,5 +526,6 @@ <h4 class="panel-title">Field
<script type="text/javascript" src="script_res/damage_gsc.js"></script>
<script type="text/javascript" src="script_res/damage_rby.js"></script>
<script type="text/javascript" src="script_res/ko_chance.js"></script>
<script type="text/javascript" src="script_res/statuscalc.js"></script>

</html>
8 changes: 6 additions & 2 deletions script_res/ap_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ function Field() {
var isFriendGuard = [$("#friendGuardL").prop("checked"), $("#friendGuardR").prop("checked")];
var isBattery = [$("#batteryR").prop("checked"), $("#batteryL").prop("checked")];
var isPowerSpot = [$("#powerSpotR").prop("checked"), $("#powerSpotL").prop("checked")]; // affects attacks against opposite side
var isTailwind = [$("#tailwindR").prop("checked"), $("#tailwindL").prop("checked")];

this.getWeather = function() {
return weather;
Expand All @@ -724,11 +725,11 @@ function Field() {
weather = "";
};
this.getSide = function(i) {
return new Side(format, terrain, weather, isGravity, isSR[i], spikes[i], isReflect[i], isLightScreen[i], isForesight[i], isHelpingHand[i], isFriendGuard[i], isBattery[i], isProtect[i], isPowerSpot[i]);
return new Side(format, terrain, weather, isGravity, isSR[i], spikes[i], isReflect[i], isLightScreen[i], isForesight[i], isHelpingHand[i], isFriendGuard[i], isBattery[i], isProtect[i], isPowerSpot[i], isTailwind[i]);
};
}

function Side(format, terrain, weather, isGravity, isSR, spikes, isReflect, isLightScreen, isForesight, isHelpingHand, isFriendGuard, isBattery, isProtect, isPowerSpot) {
function Side(format, terrain, weather, isGravity, isSR, spikes, isReflect, isLightScreen, isForesight, isHelpingHand, isFriendGuard, isBattery, isProtect, isPowerSpot, isTailwind) {
this.format = format;
this.terrain = terrain;
this.weather = weather;
Expand All @@ -743,6 +744,7 @@ function Side(format, terrain, weather, isGravity, isSR, spikes, isReflect, isLi
this.isBattery = isBattery;
this.isProtect = isProtect;
this.isPowerSpot = isPowerSpot;
this.isTailwind = isTailwind;
}

var gen, pokedex, setdex, typeChart, moves, abilities, items, STATS, calculateAllMoves, calcHP, calcStat;
Expand Down Expand Up @@ -885,6 +887,8 @@ function clearField() {
$("#helpingHandR").prop("checked", false);
$("#friendGuardL").prop("checked", false);
$("#friendGuardR").prop("checked", false);
$("#tailwindR").prop("checked", false);
$("#tailwindL").prop("checked", false);
}

function getSetOptions() {
Expand Down
14 changes: 9 additions & 5 deletions script_res/damage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ function CALCULATE_ALL_MOVES_SM(p1, p2, field) {
checkEvo(p1, p2);
checkSeeds(p1, field);
checkSeeds(p2, field);
var side1 = field.getSide(1);
var side2 = field.getSide(0);
p1.stats[DF] = getModifiedStat(p1.rawStats[DF], p1.boosts[DF]);
p1.stats[SD] = getModifiedStat(p1.rawStats[SD], p1.boosts[SD]);
p1.stats[SP] = getFinalSpeedSM(p1, field.getWeather(), field.getTerrain());
p1.stats[SP] = getFinalSpeedSM(p1, field.getWeather(), field.getTerrain(), side1.isTailwind);
p2.stats[DF] = getModifiedStat(p2.rawStats[DF], p2.boosts[DF]);
p2.stats[SD] = getModifiedStat(p2.rawStats[SD], p2.boosts[SD]);
p2.stats[SP] = getFinalSpeedSM(p2, field.getWeather(), field.getTerrain());
p2.stats[SP] = getFinalSpeedSM(p2, field.getWeather(), field.getTerrain(), side2.isTailwind);
checkIntimidate(p1, p2);
checkIntimidate(p2, p1);
checkDownload(p1, p2);
Expand All @@ -24,8 +26,6 @@ function CALCULATE_ALL_MOVES_SM(p1, p2, field) {
p1.stats[SA] = getModifiedStat(p1.rawStats[SA], p1.boosts[SA]);
p2.stats[AT] = getModifiedStat(p2.rawStats[AT], p2.boosts[AT]);
p2.stats[SA] = getModifiedStat(p2.rawStats[SA], p2.boosts[SA]);
var side1 = field.getSide(1);
var side2 = field.getSide(0);
checkInfiltrator(p1, side1);
checkInfiltrator(p2, side2);
var results = [[],[]];
Expand Down Expand Up @@ -877,7 +877,7 @@ function getModifiedStat(stat, mod) {
: stat;
}

function getFinalSpeedSM(pokemon, weather, terrain) {
function getFinalSpeedSM(pokemon, weather, terrain, tailwind) {
var speed = getModifiedStat(pokemon.rawStats[SP], pokemon.boosts[SP]);
var otherSpeedMods = 1;
if (pokemon.item === "Choice Scarf") {
Expand All @@ -903,9 +903,13 @@ function getFinalSpeedSM(pokemon, weather, terrain) {
otherSpeedMods *= 2;
}
speed = pokeRound(speed * otherSpeedMods);
console.log({tailwind, speed});
if (pokemon.status === "Paralyzed" && pokemon.ability !== "Quick Feet") {
speed = Math.floor(speed / 2);
}
if (tailwind) {
speed *= 2;
}
if (speed > 10000) {speed = 10000;}
return speed;
}
Expand Down