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

Implement default level selection #573

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 () {
thejetou marked this conversation as resolved.
Show resolved Hide resolved
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