[QoL] Auto filter for challenge mode in starter select (#3312)
This commit is contained in:
parent
a2a1f3ec24
commit
800abc4767
|
@ -151,8 +151,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
private filterBarContainer: Phaser.GameObjects.Container;
|
private filterBarContainer: Phaser.GameObjects.Container;
|
||||||
private filterBar: FilterBar;
|
private filterBar: FilterBar;
|
||||||
private shinyOverlay: Phaser.GameObjects.Image;
|
private shinyOverlay: Phaser.GameObjects.Image;
|
||||||
private starterContainer: StarterContainer[] = [];
|
private starterContainers: StarterContainer[] = [];
|
||||||
private filteredStarterContainers: StarterContainer[] = [];
|
private filteredStarterContainers: StarterContainer[] = [];
|
||||||
|
private validStarterContainers: StarterContainer[] = [];
|
||||||
private pokemonNumberText: Phaser.GameObjects.Text;
|
private pokemonNumberText: Phaser.GameObjects.Text;
|
||||||
private pokemonSprite: Phaser.GameObjects.Sprite;
|
private pokemonSprite: Phaser.GameObjects.Sprite;
|
||||||
private pokemonNameText: Phaser.GameObjects.Text;
|
private pokemonNameText: Phaser.GameObjects.Text;
|
||||||
|
@ -536,7 +537,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
|
|
||||||
const starterContainer = new StarterContainer(this.scene, species).setVisible(false);
|
const starterContainer = new StarterContainer(this.scene, species).setVisible(false);
|
||||||
this.iconAnimHandler.addOrUpdate(starterContainer.icon, PokemonIconAnimMode.NONE);
|
this.iconAnimHandler.addOrUpdate(starterContainer.icon, PokemonIconAnimMode.NONE);
|
||||||
this.starterContainer.push(starterContainer);
|
this.starterContainers.push(starterContainer);
|
||||||
starterBoxContainer.add(starterContainer);
|
starterBoxContainer.add(starterContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,7 +821,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
this.starterSelectContainer.setVisible(true);
|
this.starterSelectContainer.setVisible(true);
|
||||||
|
|
||||||
this.allSpecies.forEach((species, s) => {
|
this.allSpecies.forEach((species, s) => {
|
||||||
const icon = this.starterContainer[s].icon;
|
const icon = this.starterContainers[s].icon;
|
||||||
const dexEntry = this.scene.gameData.dexData[species.speciesId];
|
const dexEntry = this.scene.gameData.dexData[species.speciesId];
|
||||||
|
|
||||||
if (dexEntry.caughtAttr) {
|
if (dexEntry.caughtAttr) {
|
||||||
|
@ -1956,14 +1957,31 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
updateStarters = () => {
|
updateStarters = () => {
|
||||||
this.scrollCursor = 0;
|
this.scrollCursor = 0;
|
||||||
this.filteredStarterContainers = [];
|
this.filteredStarterContainers = [];
|
||||||
|
this.validStarterContainers = [];
|
||||||
|
|
||||||
this.pokerusCursorObjs.forEach(cursor => cursor.setVisible(false));
|
this.pokerusCursorObjs.forEach(cursor => cursor.setVisible(false));
|
||||||
this.starterCursorObjs.forEach(cursor => cursor.setVisible(false));
|
this.starterCursorObjs.forEach(cursor => cursor.setVisible(false));
|
||||||
|
|
||||||
this.filterBar.updateFilterLabels();
|
this.filterBar.updateFilterLabels();
|
||||||
|
|
||||||
|
// pre filter for challenges
|
||||||
|
if (this.scene.gameMode.modeId === GameModes.CHALLENGE) {
|
||||||
|
console.log("this.scene.gameMode.modeId", this.scene.gameMode.modeId);
|
||||||
|
this.starterContainers.forEach(container => {
|
||||||
|
const isValidForChallenge = new Utils.BooleanHolder(true);
|
||||||
|
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, container.species, isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(container.species, this.scene.gameData.getSpeciesDefaultDexAttr(container.species, false, true)), true);
|
||||||
|
if (isValidForChallenge.value) {
|
||||||
|
this.validStarterContainers.push(container);
|
||||||
|
} else {
|
||||||
|
container.setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.validStarterContainers = this.starterContainers;
|
||||||
|
}
|
||||||
|
|
||||||
// filter
|
// filter
|
||||||
this.starterContainer.forEach(container => {
|
this.validStarterContainers.forEach(container => {
|
||||||
container.setVisible(false);
|
container.setVisible(false);
|
||||||
|
|
||||||
container.cost = this.scene.gameData.getSpeciesStarterValue(container.species.speciesId);
|
container.cost = this.scene.gameData.getSpeciesStarterValue(container.species.speciesId);
|
||||||
|
@ -2275,12 +2293,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
const dexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(this.lastSpecies, false, true);
|
const dexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(this.lastSpecies, false, true);
|
||||||
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr);
|
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr);
|
||||||
const speciesIndex = this.allSpecies.indexOf(this.lastSpecies);
|
const speciesIndex = this.allSpecies.indexOf(this.lastSpecies);
|
||||||
const lastSpeciesIcon = this.starterContainer[speciesIndex].icon;
|
const lastSpeciesIcon = this.starterContainers[speciesIndex].icon;
|
||||||
this.checkIconId(lastSpeciesIcon, this.lastSpecies, props.female, props.formIndex, props.shiny, props.variant);
|
this.checkIconId(lastSpeciesIcon, this.lastSpecies, props.female, props.formIndex, props.shiny, props.variant);
|
||||||
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
|
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
|
||||||
|
|
||||||
// Resume the animation for the previously selected species
|
// Resume the animation for the previously selected species
|
||||||
const icon = this.starterContainer[speciesIndex].icon;
|
const icon = this.starterContainers[speciesIndex].icon;
|
||||||
this.scene.tweens.getTweensOf(icon).forEach(tween => tween.resume());
|
this.scene.tweens.getTweensOf(icon).forEach(tween => tween.resume());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2376,7 +2394,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
|
|
||||||
// Pause the animation when the species is selected
|
// Pause the animation when the species is selected
|
||||||
const speciesIndex = this.allSpecies.indexOf(species);
|
const speciesIndex = this.allSpecies.indexOf(species);
|
||||||
const icon = this.starterContainer[speciesIndex].icon;
|
const icon = this.starterContainers[speciesIndex].icon;
|
||||||
|
|
||||||
if (this.isUpgradeAnimationEnabled()) {
|
if (this.isUpgradeAnimationEnabled()) {
|
||||||
this.scene.tweens.getTweensOf(icon).forEach(tween => tween.pause());
|
this.scene.tweens.getTweensOf(icon).forEach(tween => tween.pause());
|
||||||
|
@ -2813,7 +2831,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||||
/** Used to detect if this pokemon is registered in starter */
|
/** Used to detect if this pokemon is registered in starter */
|
||||||
const speciesStarterDexEntry = this.scene.gameData.dexData[this.allSpecies[s].speciesId];
|
const speciesStarterDexEntry = this.scene.gameData.dexData[this.allSpecies[s].speciesId];
|
||||||
/** {@linkcode Phaser.GameObjects.Sprite} object of Pokémon for setting the alpha value */
|
/** {@linkcode Phaser.GameObjects.Sprite} object of Pokémon for setting the alpha value */
|
||||||
const speciesSprite = this.starterContainer[s].icon;
|
const speciesSprite = this.starterContainers[s].icon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If remainValue greater than or equal pokemon species and the pokemon is legal for this challenge, the user can select.
|
* If remainValue greater than or equal pokemon species and the pokemon is legal for this challenge, the user can select.
|
||||||
|
|
Loading…
Reference in New Issue