Skip to content

Commit

Permalink
Better support for doubles and tag battles
Browse files Browse the repository at this point in the history
  • Loading branch information
anastarawneh committed Sep 8, 2024
1 parent 478def3 commit e6bbdea
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ table.field {



.trainer-poke-list, .trainer-poke-list-opposing {
.trainer-poke-list, .trainer-poke-list-opposing, .tag-poke-list-opposing {
display: flex;
flex-wrap: wrap;
}
Expand Down Expand Up @@ -677,7 +677,7 @@ table.field {
background: linear-gradient(to right, #daff08 50%, #dd0b0b 0%);
}

.box-poke, .trainer-poke-list-opposing {
.box-poke, .trainer-poke-list-opposing, .tag-poke-list-opposing {
min-height: 30px;
}

Expand Down
4 changes: 4 additions & 0 deletions src/hacks.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,10 @@ <h5>Advanced</h5>
<fieldset class="poke-info">
<legend align="center">Enemy Party</legend>
<div class="trainer-poke-list-opposing"></div>
<div class="tag-container hide">
<hr />
<div class="tag-poke-list-opposing"></div>
</div>
<div class="game-specific gm1">
<hr>
<button type="button" id="previous-trainer">Previous Trainer</button>
Expand Down
4 changes: 4 additions & 0 deletions src/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -1850,6 +1850,10 @@ <h5>Advanced</h5>
<fieldset class="poke-info">
<legend align="center">Enemy Party</legend>
<div class="trainer-poke-list-opposing"></div>
<div class="tag-container hide">
<hr />
<div class="tag-poke-list-opposing"></div>
</div>
<div class="game-specific gm9">
<hr>
<button type="button" id="previous-trainer">Previous Trainer</button>
Expand Down
51 changes: 51 additions & 0 deletions src/js/data/flags/hacks/ek.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,57 @@ var CUSTOMHACKFLAGS_EK = {
"Champion Steven"
]
},
"battleType": {
"doubles": [
"Twins Gina & Mia",
"Twins Amy & Liv",
"Sr. & Jr. Anna & Meg",
"Bug Maniac Angelo",
"Interviewers Gabby & Ty #1",
"Twins Tori & Tia",
"Sr. & Jr. Tyra & Ivy",
"Leader Norman",
"Interviewers Gabby & Ty #2",
"Interviewers Gabby & Ty #3",
"Leader Winona",
"Sr. & Jr. Kate & Joy",
"Young Couple Dez & Luke",
"Sis & Bro Lila & Roy",
"Sr. & Jr. Kim & Iris",
"Teaders Tate&Liza",
"Aqua Leader Archie",
"Sis & Bro Reli & Ian",
"Leader #2 Juan",
"Old Couple Miu & Yuki"
],
"tag": [
["Picnicker Bianca", "Kindler Hayden"],
["Camper Tyron", "Aroma Lady Celina"],
["Picknicker Irene", "Camper Travis"],
["Black Belt Daisuke", "Cooltrainer Brooke"],
["Team Magma Grunt #1 @ Jagged Pass", "Team Magma Grunt #2 @ Jagged Pass"],
["Battle Girl Melene", "Psychic Alix"],
["Bird Keeper Josue", "Ruin Maniac Andres"],
["Bird Keeper Phil", "Parasol Lady Missy"],
["Team Aqua Grunt #1 @ Route 124", "Team Aqua Grunt #2 @ Route 124"],
["Psychic Preston", "Psychic Maura"],
["Psychic Samantha", "Cooltrainer Virgil"],
["Gentleman Nate", "Expert Nicholas"],
["Psychic Blake", "Cooltrainer Hannah"],
["Hex Maniac Sylvia", "Expert Macey"],
["Expert Clifford", "Hex Maniac Kathleen"],
["Team Magma Grunt #1 @ Mossdeep Space Center", "Team Magma Grunt #2 @ Mossdeep Space Center"],
["Magma Leader Maxie #3", "Magma Admin Tabitha #2"],
["Psychic Cameron", "Aroma Lady Violet"],
["Ninja Boy Jonas", "Collector Ed"],
["Hex Maniac Kindra", "Guitarist Fernando"],
["Bird Keeper Alberto", "Psychic Jacki"],
["Parasol Lady Kayley", "Bug Maniac Davis"],
["Cooltrainer Wendy", "Cooltrainer Braxton"],
["Cooltrainer Jazmyn", "Expert Frederick"],
["Expert Mitchell", "Expert Felix"]
]
},
"weather": {
"any": [
// Route 119
Expand Down
11 changes: 10 additions & 1 deletion src/js/game_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,15 @@ function predictMidTurnSwitchEmerald(p1, p2) {
$(".trainer-poke.right-side").removeClass("switch-risk-mon");
if (slower) {
var partySpecies = partyOrder[window.CURRENT_TRAINER];
var container = ".trainer-poke-list-opposing";
if (flags) {
for (var i in flags["battleType"]["tag"]) {
if (flags["battleType"]["tag"][i].includes(window.CURRENT_TRAINER)) {
container = flags["battleType"]["tag"][i].indexOf(window.CURRENT_TRAINER) ? ".tag-poke-list-opposing" : ".trainer-poke-list-opposing";
break;
}
}
}
for (var i in p1.moves) {
var move = p1.moves[i];
if (move.category == "Status") continue;
Expand All @@ -763,7 +772,7 @@ function predictMidTurnSwitchEmerald(p1, p2) {
var typeEffectiveness = typeEffectiveness2 !== undefined ? typeEffectiveness1 * typeEffectiveness2 : typeEffectiveness1;
if (typeEffectiveness > 1) {
$(resultLocations[0][i]["move"]).addClass("switch-risk");
$(".trainer-poke.right-side").each(function(index, e) {
$(`${container} .trainer-poke.right-side`).each(function(index, e) {
if (index == j) $(this).addClass("switch-risk-mon");
});
}
Expand Down
38 changes: 37 additions & 1 deletion src/js/shared_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,10 @@ $(".set-selector").change(function () {
var oldTrainer = window.CURRENT_TRAINER;
var nextPokemon = getTrainerPokemon(fullSetName);
var trainerHTML = "";
var tagHTML = "";
var switchHTML = "";
for (var i in nextPokemon) {
if (nextPokemon[i][0].includes($('input.opposing').val())){
if (nextPokemon[i][0].includes($('input.opposing').val())) {
continue;
}
var pokemonName = nextPokemon[i].split(" (")[0];
Expand Down Expand Up @@ -632,10 +633,45 @@ $(".set-selector").change(function () {
$("#mindBadge").prop("checked", true);
}
}

var battleType = "singles-format";
$(".tag-container").hide();
if (flags["battleType"]["doubles"].includes(window.CURRENT_TRAINER)) {
battleType = "doubles-format";
} else for (var i in flags["battleType"]["tag"]) {
if (flags["battleType"]["tag"][i].includes(window.CURRENT_TRAINER)) {
battleType = "doubles-format";
$(".tag-container").show();
var tag = flags["battleType"]["tag"][i];
trainerHTML = "";
var nextTrainerPokemon = getTrainerPokemon(` (${tag[0]})`);
for (var i in nextTrainerPokemon) {
if (nextTrainerPokemon[i][0].includes($('input.opposing').val())) {
continue;
}
var pokemonName = nextTrainerPokemon[i].split(" (")[0];
var pokemonHTML = `<img class="trainer-poke right-side" src="https://raw.githubusercontent.com/May8th1995/sprites/master/${pokemonName}.png" data-id="${nextTrainerPokemon[i]}" title="${nextTrainerPokemon[i]}">`;
trainerHTML += pokemonHTML;
}
var nextTagPokemon = getTrainerPokemon(` (${tag[1]})`);
for (var i in nextTagPokemon) {
if (nextTagPokemon[i][0].includes($('input.opposing').val())) {
continue;
}
var pokemonName = nextTagPokemon[i].split(" (")[0];
var pokemonHTML = `<img class="trainer-poke right-side" src="https://raw.githubusercontent.com/May8th1995/sprites/master/${pokemonName}.png" data-id="${nextTagPokemon[i]}" title="${nextTagPokemon[i]}">`;
tagHTML += pokemonHTML;
}
getTrainerPokemon(fullSetName);
break;
}
}
$(`#${battleType}`).prop("checked", true).change();
}
}

$('.trainer-poke-list-opposing').html(trainerHTML);
$('.tag-poke-list-opposing').html(tagHTML);
if (oldTrainer !== window.CURRENT_TRAINER) $('.trainer-poke-switch-list').html(switchHTML);

var pokemonName = fullSetName.substring(0, fullSetName.indexOf(" ("));
Expand Down

0 comments on commit e6bbdea

Please sign in to comment.