Skip to content

Commit

Permalink
UI: Auto change Terapagos forms (smogon#613)
Browse files Browse the repository at this point in the history
When you have a Terapagos or Terapagos-Terastal and check the Tera checkbox, Terapagos's forme will automatically be changed to Terapagos-Stellar, and its stats will get updated automatically. When you have a Terapagos-Stellar and you uncheck the Tera checkbox, Terapagos's forme will be changed to Terapagos-Terastal and its stats will get updated automatically. It will function similar to how Ogerpon's forme interacts with Terastallization.

https://www.smogon.com/forums/posts/10060270
  • Loading branch information
shrianshChari authored Apr 8, 2024
1 parent 00dabe7 commit d1457fe
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions src/js/shared_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -815,22 +815,48 @@ $(".teraToggle").change(function () {
var curForme = forme.val();
if (forme.is(":hidden")) return;
var container = $(this).closest(".info-group").siblings();
// Ogerpon mechs
if (!startsWith(curForme, "Ogerpon")) return;
if (
curForme !== "Ogerpon" && !endsWith(curForme, "Tera") &&
container.find(".item").val() !== curForme.split("-")[1] + " Mask"
) return;
if (this.checked) {
var newForme = curForme === "Ogerpon" ? "Ogerpon-Teal-Tera" : curForme + "-Tera";
// Ogerpon and Terapagos mechs
if (startsWith(curForme, "Ogerpon")) {
if (
curForme !== "Ogerpon" && !endsWith(curForme, "Tera") &&
container.find(".item").val() !== curForme.split("-")[1] + " Mask"
) return;
if (this.checked) {
var newForme = curForme === "Ogerpon" ? "Ogerpon-Teal-Tera" : curForme + "-Tera";
forme.val(newForme);
container.find(".ability").val("Embody Aspect (" + newForme.split("-")[1] + ")");
return;
}
if (!endsWith(curForme, "Tera")) return;
var newForme = curForme === "Ogerpon-Teal-Tera" ? "Ogerpon" : curForme.slice(0, -5);
forme.val(newForme);
container.find(".ability").val("Embody Aspect (" + newForme.split("-")[1] + ")");
return;
container.find(".ability").val(pokedex[newForme].abilities[0]);
} else if (startsWith(curForme, "Terapagos")) {
if (this.checked) {
var newForme = "Terapagos-Stellar";

forme.val(newForme);
container.find(".ability").val(pokedex[newForme].abilities[0]);

for (var property in pokedex[newForme].bs) {
var baseStat = container.find("." + property).find(".base");
baseStat.val(pokedex[newForme].bs[property]);
baseStat.keyup();
}
return;
}

if (!endsWith(curForme, "Stellar")) return;
var newForme = "Terapagos-Terastal";

forme.val(newForme);
container.find(".ability").val(pokedex[newForme].abilities[0]);
for (var property in pokedex[newForme].bs) {
var baseStat = container.find("." + property).find(".base");
baseStat.val(pokedex[newForme].bs[property]);
baseStat.keyup();
}
}
if (!endsWith(curForme, "Tera")) return;
var newForme = curForme === "Ogerpon-Teal-Tera" ? "Ogerpon" : curForme.slice(0, -5);
forme.val(newForme);
container.find(".ability").val(pokedex[newForme].abilities[0]);
});

$(".forme").change(function () {
Expand Down

0 comments on commit d1457fe

Please sign in to comment.