Skip to content

Commit

Permalink
Implement default level selection (smogon#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
DimK19 authored and ForwardFeed committed Oct 28, 2023
1 parent 89d01b9 commit e2aa5ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,15 @@
<input class="visually-hidden calc-trigger" type="radio" name="format" value="Doubles" id="doubles-format" />
<label class="btn btn-right" for="doubles-format">Doubles</label>
</div>
<div aria-labelledby="selectDefaultLevelInstruction" role="radiogroup" style="margin: auto auto 5px;" title="Select the default level.">
<span class="visually-hidden" id="selectDefaultLevelInstruction">Select the default level.</span>
<input class="visually-hidden calc-trigger" type="radio" name="defaultLevel" value="100" id="default-level-100" />
<label class="btn btn-wide btn-left" for="default-level-100">Level 100</label>
<input class="visually-hidden calc-trigger gen-specific g4 g5 g6 g7 g8 g9" type="radio" name="defaultLevel" value="50" id="default-level-50" />
<label class="btn btn-wide btn-mid gen-specific g4 g5 g6 g7 g8 g9" for="default-level-50">Level 50</label>
<input class="visually-hidden calc-trigger" type="radio" name="defaultLevel" value="5" id="default-level-5" />
<label class="btn btn-wide btn-right" for="default-level-5">Level 5</label>
</div>
<div aria-labelledby="selectTerrainInstruction" class="gen-specific g6 g7 g8 g9" role="group" title="Select the current terrain.">
<span class="visually-hidden" id="selectTerrainInstruction">Select the current terrain.</span>
<input class="visually-hidden terrain-trigger calc-trigger" type="checkbox" name="terrain" value="Electric" id="electric" /><label class="btn btn-xxxwide btn-left" for="electric">Electric Terrain</label>
Expand Down
15 changes: 13 additions & 2 deletions src/js/shared_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,17 @@ $("input:radio[name='format']").change(function () {
$(".format-specific").not("." + gameType.toLowerCase()).hide();
});

var defaultLevel = 100;
$("input:radio[name='defaultLevel']").change(function () {
defaultLevel = $("input:radio[name='defaultLevel']:checked").val();
$("#levelL1").val(defaultLevel);
$("#levelR1").val(defaultLevel);
$("#levelL1").trigger("change");
$("#levelR1").trigger("change");
});

// auto-calc stats and current HP on change
$(".level").keyup(function () {
$(".level").bind("keyup change", function () {
var poke = $(this).closest(".poke-info");
calcHP(poke);
calcStats(poke);
Expand Down Expand Up @@ -641,7 +650,7 @@ $(".set-selector").change(function () {
}
} else {
pokeObj.find(".teraType").val(getForcedTeraType(pokemonName) || pokemon.types[0]);
pokeObj.find(".level").val(100);
pokeObj.find(".level").val(defaultLevel);
pokeObj.find(".hp .evs").val(0);
pokeObj.find(".hp .ivs").val(31);
pokeObj.find(".hp .dvs").val(15);
Expand Down Expand Up @@ -1495,6 +1504,8 @@ $(document).ready(function () {
$("#percentage").change();
$("#singles-format").prop("checked", true);
$("#singles-format").change();
$("#default-level-100").prop("checked", true);
$("#default-level-100").change();
loadDefaultLists();
$(".move-selector").select2({
dropdownAutoWidth: true,
Expand Down

0 comments on commit e2aa5ac

Please sign in to comment.