Skip to content

Commit

Permalink
Implement default level selection
Browse files Browse the repository at this point in the history
  • Loading branch information
DimK19 committed Aug 8, 2023
1 parent df0da6c commit 1a4c699
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,13 @@
<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" class="gen-specific g4 g5 g6 g7 g8 g9" 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" type="radio" name="defaultLevel" value="50" id="default-level-50" />
<label class="btn btn-wide btn-right" for="default-level-50">Level 50</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 @@ -100,8 +100,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 @@ -582,7 +591,7 @@ $(".set-selector").change(function () {
}
} else {
pokeObj.find(".teraType").val(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 @@ -1401,6 +1410,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 1a4c699

Please sign in to comment.