mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-18 15:00:55 +00:00
[Bug] Fixed bug where container for unfiltered Pokémon does not try to setVisible (#3509)
This commit is contained in:
parent
a35aff7b25
commit
5020d742f7
@ -1328,44 +1328,48 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
let starterContainer;
|
||||||
|
const starterData = this.scene.gameData.starterData[this.lastSpecies.speciesId];
|
||||||
|
// prepare persistent starter data to store changes
|
||||||
|
let starterAttributes = this.starterPreferences[this.lastSpecies.speciesId];
|
||||||
|
|
||||||
|
// this gets the correct pokemon cursor depending on whether you're in the starter screen or the party icons
|
||||||
|
if (!this.starterIconsCursorObj.visible) {
|
||||||
|
starterContainer = this.filteredStarterContainers[this.cursor];
|
||||||
|
} else {
|
||||||
|
// if species is in filtered starters, get the starter container from the filtered starters, it can be undefined if the species is not in the filtered starters
|
||||||
|
starterContainer = this.filteredStarterContainers[this.filteredStarterContainers.findIndex(container => container.species === this.lastSpecies)];
|
||||||
|
}
|
||||||
|
|
||||||
if (button === Button.ACTION) {
|
if (button === Button.ACTION) {
|
||||||
if (!this.speciesStarterDexEntry?.caughtAttr) {
|
if (!this.speciesStarterDexEntry?.caughtAttr) {
|
||||||
error = true;
|
error = true;
|
||||||
} else if (this.starterSpecies.length <= 6) { // checks to see if the party has 6 or fewer pokemon
|
} else if (this.starterSpecies.length <= 6) { // checks to see if the party has 6 or fewer pokemon
|
||||||
|
|
||||||
let species;
|
|
||||||
|
|
||||||
// this gets the correct generation and pokemon cursor depending on whether you're in the starter screen or the party icons
|
|
||||||
if (!this.starterIconsCursorObj.visible) {
|
|
||||||
species = this.filteredStarterContainers[this.cursor].species;
|
|
||||||
} else {
|
|
||||||
species = this.starterSpecies[this.starterIconsCursorIndex];
|
|
||||||
}
|
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
let options: any[] = []; // TODO: add proper type
|
let options: any[] = []; // TODO: add proper type
|
||||||
|
|
||||||
const [isDupe, removeIndex]: [boolean, number] = this.isInParty(species); // checks to see if the pokemon is a duplicate; if it is, returns the index that will be removed
|
const [isDupe, removeIndex]: [boolean, number] = this.isInParty(this.lastSpecies); // checks to see if the pokemon is a duplicate; if it is, returns the index that will be removed
|
||||||
|
|
||||||
|
|
||||||
const isPartyValid = this.isPartyValid();
|
const isPartyValid = this.isPartyValid();
|
||||||
const isValidForChallenge = new Utils.BooleanHolder(true);
|
const isValidForChallenge = new Utils.BooleanHolder(true);
|
||||||
|
|
||||||
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, species, isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(species, this.getCurrentDexProps(species.speciesId)), isPartyValid);
|
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, this.lastSpecies, isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId)), isPartyValid);
|
||||||
|
|
||||||
const currentPartyValue = this.starterSpecies.map(s => s.generation).reduce((total: number, gen: number, i: number) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0);
|
const currentPartyValue = this.starterSpecies.map(s => s.generation).reduce((total: number, gen: number, i: number) => total += this.scene.gameData.getSpeciesStarterValue(this.starterSpecies[i].speciesId), 0);
|
||||||
const newCost = this.scene.gameData.getSpeciesStarterValue(species.speciesId);
|
const newCost = this.scene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId);
|
||||||
if (!isDupe && isValidForChallenge.value && currentPartyValue + newCost <= this.getValueLimit() && this.starterSpecies.length < 6) { // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party
|
if (!isDupe && isValidForChallenge.value && currentPartyValue + newCost <= this.getValueLimit() && this.starterSpecies.length < 6) { // this checks to make sure the pokemon doesn't exist in your party, it's valid for the challenge and that it won't go over the cost limit; if it meets all these criteria it will add it to your party
|
||||||
options = [
|
options = [
|
||||||
{
|
{
|
||||||
label: i18next.t("starterSelectUiHandler:addToParty"),
|
label: i18next.t("starterSelectUiHandler:addToParty"),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
ui.setMode(Mode.STARTER_SELECT);
|
ui.setMode(Mode.STARTER_SELECT);
|
||||||
const isOverValueLimit = this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(species.speciesId), true);
|
const isOverValueLimit = this.tryUpdateValue(this.scene.gameData.getSpeciesStarterValue(this.lastSpecies.speciesId), true);
|
||||||
if (!isDupe && isValidForChallenge.value && isOverValueLimit) {
|
if (!isDupe && isValidForChallenge.value && isOverValueLimit) {
|
||||||
const cursorObj = this.starterCursorObjs[this.starterSpecies.length];
|
const cursorObj = this.starterCursorObjs[this.starterSpecies.length];
|
||||||
cursorObj.setVisible(true);
|
cursorObj.setVisible(true);
|
||||||
cursorObj.setPosition(this.cursorObj.x, this.cursorObj.y);
|
cursorObj.setPosition(this.cursorObj.x, this.cursorObj.y);
|
||||||
this.addToParty(species, this.dexAttrCursor, this.abilityCursor, this.natureCursor as unknown as Nature, this.starterMoveset?.slice(0) as StarterMoveset);
|
this.addToParty(this.lastSpecies, this.dexAttrCursor, this.abilityCursor, this.natureCursor as unknown as Nature, this.starterMoveset?.slice(0) as StarterMoveset);
|
||||||
ui.playSelect();
|
ui.playSelect();
|
||||||
} else {
|
} else {
|
||||||
ui.playError(); // this should be redundant as there is now a trigger for when a pokemon can't be added to party
|
ui.playError(); // this should be redundant as there is now a trigger for when a pokemon can't be added to party
|
||||||
@ -1481,9 +1485,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const starterContainer = this.filteredStarterContainers[this.cursor];
|
|
||||||
const starterData = this.scene.gameData.starterData[this.lastSpecies.speciesId];
|
|
||||||
let starterAttributes = this.starterPreferences[this.lastSpecies.speciesId];
|
|
||||||
if (this.canCycleNature) {
|
if (this.canCycleNature) {
|
||||||
// if we could cycle natures, enable the improved nature menu
|
// if we could cycle natures, enable the improved nature menu
|
||||||
const showNatureOptions = () => {
|
const showNatureOptions = () => {
|
||||||
@ -1567,7 +1568,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
label: i18next.t("starterSelectUiHandler:addToFavorites"),
|
label: i18next.t("starterSelectUiHandler:addToFavorites"),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
starterAttributes.favorite = true;
|
starterAttributes.favorite = true;
|
||||||
starterContainer.favoriteIcon.setVisible(starterAttributes.favorite);
|
// if the starter container not exists, it means the species is not in the filtered starters
|
||||||
|
if (starterContainer) {
|
||||||
|
starterContainer.favoriteIcon.setVisible(starterAttributes.favorite);
|
||||||
|
}
|
||||||
ui.setMode(Mode.STARTER_SELECT);
|
ui.setMode(Mode.STARTER_SELECT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1577,7 +1581,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
label: i18next.t("starterSelectUiHandler:removeFromFavorites"),
|
label: i18next.t("starterSelectUiHandler:removeFromFavorites"),
|
||||||
handler: () => {
|
handler: () => {
|
||||||
starterAttributes.favorite = false;
|
starterAttributes.favorite = false;
|
||||||
starterContainer.favoriteIcon.setVisible(starterAttributes.favorite);
|
// if the starter container not exists, it means the species is not in the filtered starters
|
||||||
|
if (starterContainer) {
|
||||||
|
starterContainer.favoriteIcon.setVisible(starterAttributes.favorite);
|
||||||
|
}
|
||||||
ui.setMode(Mode.STARTER_SELECT);
|
ui.setMode(Mode.STARTER_SELECT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1598,7 +1605,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
if (name.length > 0) {
|
if (name.length > 0) {
|
||||||
this.pokemonNameText.setText(name);
|
this.pokemonNameText.setText(name);
|
||||||
} else {
|
} else {
|
||||||
this.pokemonNameText.setText(species.name);
|
this.pokemonNameText.setText(this.lastSpecies.name);
|
||||||
}
|
}
|
||||||
ui.setMode(Mode.STARTER_SELECT);
|
ui.setMode(Mode.STARTER_SELECT);
|
||||||
},
|
},
|
||||||
@ -1631,16 +1638,18 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
ui.setMode(Mode.STARTER_SELECT);
|
ui.setMode(Mode.STARTER_SELECT);
|
||||||
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, undefined);
|
this.setSpeciesDetails(this.lastSpecies, undefined, undefined, undefined, undefined, undefined, undefined);
|
||||||
|
|
||||||
// Update the candy upgrade display
|
// if starterContainer exists, update the passive background
|
||||||
if (this.isUpgradeIconEnabled() ) {
|
if (starterContainer) {
|
||||||
this.setUpgradeIcon(starterContainer);
|
// Update the candy upgrade display
|
||||||
}
|
if (this.isUpgradeIconEnabled() ) {
|
||||||
if (this.isUpgradeAnimationEnabled()) {
|
this.setUpgradeIcon(starterContainer);
|
||||||
this.setUpgradeAnimation(starterContainer.icon, this.lastSpecies, true);
|
}
|
||||||
}
|
if (this.isUpgradeAnimationEnabled()) {
|
||||||
|
this.setUpgradeAnimation(starterContainer.icon, this.lastSpecies, true);
|
||||||
starterContainer.starterPassiveBgs.setVisible(!!this.scene.gameData.starterData[this.lastSpecies.speciesId].passiveAttr);
|
}
|
||||||
|
|
||||||
|
starterContainer.starterPassiveBgs.setVisible(!!this.scene.gameData.starterData[this.lastSpecies.speciesId].passiveAttr);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1666,21 +1675,24 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
return this.scene.reset(true);
|
return this.scene.reset(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.updateStarterValueLabel(starterContainer);
|
|
||||||
this.tryUpdateValue(0);
|
this.tryUpdateValue(0);
|
||||||
ui.setMode(Mode.STARTER_SELECT);
|
ui.setMode(Mode.STARTER_SELECT);
|
||||||
this.scene.playSound("buy");
|
this.scene.playSound("buy");
|
||||||
|
|
||||||
// If the notification setting is set to 'On', update the candy upgrade display
|
// if starterContainer exists, update the value reduction background
|
||||||
if (this.scene.candyUpgradeNotification === 2) {
|
if (starterContainer) {
|
||||||
if (this.isUpgradeIconEnabled() ) {
|
this.updateStarterValueLabel(starterContainer);
|
||||||
this.setUpgradeIcon(starterContainer);
|
|
||||||
}
|
// If the notification setting is set to 'On', update the candy upgrade display
|
||||||
if (this.isUpgradeAnimationEnabled()) {
|
if (this.scene.candyUpgradeNotification === 2) {
|
||||||
this.setUpgradeAnimation(starterContainer.icon, this.lastSpecies, true);
|
if (this.isUpgradeIconEnabled() ) {
|
||||||
|
this.setUpgradeIcon(starterContainer);
|
||||||
|
}
|
||||||
|
if (this.isUpgradeAnimationEnabled()) {
|
||||||
|
this.setUpgradeAnimation(starterContainer.icon, this.lastSpecies, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1755,11 +1767,6 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId));
|
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId));
|
||||||
// prepare persistent starter data to store changes
|
|
||||||
let starterAttributes = this.starterPreferences[this.lastSpecies.speciesId];
|
|
||||||
if (!starterAttributes) {
|
|
||||||
starterAttributes = this.starterPreferences[this.lastSpecies.speciesId] = {};
|
|
||||||
}
|
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case Button.CYCLE_SHINY:
|
case Button.CYCLE_SHINY:
|
||||||
if (this.canCycleShiny) {
|
if (this.canCycleShiny) {
|
||||||
@ -2962,10 +2969,12 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
const isValidForChallenge = new Utils.BooleanHolder(true);
|
const isValidForChallenge = new Utils.BooleanHolder(true);
|
||||||
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, species, isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor), !!this.starterSpecies.length);
|
Challenge.applyChallenges(this.scene.gameMode, Challenge.ChallengeType.STARTER_CHOICE, species, isValidForChallenge, this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor), !!this.starterSpecies.length);
|
||||||
const currentFilteredContainer = this.filteredStarterContainers.find(p => p.species.speciesId === species.speciesId)!;
|
const currentFilteredContainer = this.filteredStarterContainers.find(p => p.species.speciesId === species.speciesId);
|
||||||
const starterSprite = currentFilteredContainer.icon as Phaser.GameObjects.Sprite;
|
if (currentFilteredContainer) {
|
||||||
starterSprite.setTexture(species.getIconAtlasKey(formIndex, shiny, variant), species.getIconId(female!, formIndex, shiny, variant));
|
const starterSprite = currentFilteredContainer.icon as Phaser.GameObjects.Sprite;
|
||||||
currentFilteredContainer.checkIconId(female, formIndex, shiny, variant);
|
starterSprite.setTexture(species.getIconAtlasKey(formIndex, shiny, variant), species.getIconId(female!, formIndex, shiny, variant));
|
||||||
|
currentFilteredContainer.checkIconId(female, formIndex, shiny, variant);
|
||||||
|
}
|
||||||
this.canCycleShiny = !!(dexEntry.caughtAttr & DexAttr.NON_SHINY && dexEntry.caughtAttr & DexAttr.SHINY);
|
this.canCycleShiny = !!(dexEntry.caughtAttr & DexAttr.NON_SHINY && dexEntry.caughtAttr & DexAttr.SHINY);
|
||||||
this.canCycleGender = !!(dexEntry.caughtAttr & DexAttr.MALE && dexEntry.caughtAttr & DexAttr.FEMALE);
|
this.canCycleGender = !!(dexEntry.caughtAttr & DexAttr.MALE && dexEntry.caughtAttr & DexAttr.FEMALE);
|
||||||
this.canCycleAbility = [ abilityAttr & AbilityAttr.ABILITY_1, (abilityAttr & AbilityAttr.ABILITY_2) && species.ability2, abilityAttr & AbilityAttr.ABILITY_HIDDEN ].filter(a => a).length > 1;
|
this.canCycleAbility = [ abilityAttr & AbilityAttr.ABILITY_1, (abilityAttr & AbilityAttr.ABILITY_2) && species.ability2, abilityAttr & AbilityAttr.ABILITY_HIDDEN ].filter(a => a).length > 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user