Skip to content

Commit 0fd323f

Browse files
committed
Imported HP IVs shouldn't be overwritten
Fixes #650
1 parent 18ca84e commit 0fd323f

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/js/shared_controls.js

+24-20
Original file line numberDiff line numberDiff line change
@@ -968,29 +968,33 @@ function correctHiddenPower(pokemon) {
968968
for (var i = 0; i < pokemon.moves.length; i++) {
969969
var m = pokemon.moves[i].match(HIDDEN_POWER_REGEX);
970970
if (!m) continue;
971+
// The Hidden Power type matches the IVs provided so we don't need to do anything else
972+
if (expected.type === m[1]) {
973+
continue;
974+
}
971975
// The Pokemon has Hidden Power and is not maxed but the types don't match we don't
972976
// want to attempt to reconcile the user's IVs so instead just correct the HP type
973-
if (!maxed && expected.type !== m[1]) {
977+
if (!maxed) {
974978
pokemon.moves[i] = "Hidden Power " + expected.type;
975-
} else {
976-
// Otherwise, use the default preset hidden power IVs that PS would use
977-
var hpIVs = calc.Stats.getHiddenPowerIVs(GENERATION, m[1]);
978-
if (!hpIVs) continue; // some impossible type was specified, ignore
979-
pokemon.ivs = pokemon.ivs || {hp: 31, at: 31, df: 31, sa: 31, sd: 31, sp: 31};
980-
pokemon.dvs = pokemon.dvs || {hp: 15, at: 15, df: 15, sa: 15, sd: 15, sp: 15};
981-
for (var stat in hpIVs) {
982-
pokemon.ivs[calc.Stats.shortForm(stat)] = hpIVs[stat];
983-
pokemon.dvs[calc.Stats.shortForm(stat)] = calc.Stats.IVToDV(hpIVs[stat]);
984-
}
985-
if (gen < 3) {
986-
pokemon.dvs.hp = calc.Stats.getHPDV({
987-
atk: pokemon.ivs.at || 31,
988-
def: pokemon.ivs.df || 31,
989-
spe: pokemon.ivs.sp || 31,
990-
spc: pokemon.ivs.sa || 31
991-
});
992-
pokemon.ivs.hp = calc.Stats.DVToIV(pokemon.dvs.hp);
993-
}
979+
continue;
980+
}
981+
// Otherwise, use the default preset hidden power IVs that PS would use
982+
var hpIVs = calc.Stats.getHiddenPowerIVs(GENERATION, m[1]);
983+
if (!hpIVs) continue; // some impossible type was specified, ignore
984+
pokemon.ivs = pokemon.ivs || {hp: 31, at: 31, df: 31, sa: 31, sd: 31, sp: 31};
985+
pokemon.dvs = pokemon.dvs || {hp: 15, at: 15, df: 15, sa: 15, sd: 15, sp: 15};
986+
for (var stat in hpIVs) {
987+
pokemon.ivs[calc.Stats.shortForm(stat)] = hpIVs[stat];
988+
pokemon.dvs[calc.Stats.shortForm(stat)] = calc.Stats.IVToDV(hpIVs[stat]);
989+
}
990+
if (gen < 3) {
991+
pokemon.dvs.hp = calc.Stats.getHPDV({
992+
atk: pokemon.ivs.at || 31,
993+
def: pokemon.ivs.df || 31,
994+
spe: pokemon.ivs.sp || 31,
995+
spc: pokemon.ivs.sa || 31
996+
});
997+
pokemon.ivs.hp = calc.Stats.DVToIV(pokemon.dvs.hp);
994998
}
995999
}
9961000
return pokemon;

0 commit comments

Comments
 (0)