mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-01 14:02:18 +02:00
Refactor evo conditions and descriptions
This commit is contained in:
parent
eef8367caf
commit
8e61d20384
File diff suppressed because it is too large
Load Diff
@ -838,72 +838,6 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement {
|
|
||||||
requiredEvolutionItem: EvolutionItem[];
|
|
||||||
minNumberOfPokemon: number;
|
|
||||||
invertQuery: boolean;
|
|
||||||
|
|
||||||
constructor(evolutionItems: EvolutionItem | EvolutionItem[], minNumberOfPokemon = 1, invertQuery = false) {
|
|
||||||
super();
|
|
||||||
this.minNumberOfPokemon = minNumberOfPokemon;
|
|
||||||
this.invertQuery = invertQuery;
|
|
||||||
this.requiredEvolutionItem = Array.isArray(evolutionItems) ? evolutionItems : [evolutionItems];
|
|
||||||
}
|
|
||||||
|
|
||||||
override meetsRequirement(): boolean {
|
|
||||||
const partyPokemon = globalScene.getPlayerParty();
|
|
||||||
if (isNullOrUndefined(partyPokemon) || this.requiredEvolutionItem?.length < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this.queryParty(partyPokemon).length >= this.minNumberOfPokemon;
|
|
||||||
}
|
|
||||||
|
|
||||||
filterByEvo(pokemon, evolutionItem) {
|
|
||||||
if (
|
|
||||||
pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) &&
|
|
||||||
pokemonEvolutions[pokemon.species.speciesId].filter(
|
|
||||||
e => e.item === evolutionItem && (!e.condition || e.condition.predicate(pokemon)),
|
|
||||||
).length &&
|
|
||||||
pokemon.getFormKey() !== SpeciesFormKey.GIGANTAMAX
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
pokemon.isFusion() &&
|
|
||||||
pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) &&
|
|
||||||
pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter(
|
|
||||||
e => e.item === evolutionItem && (!e.condition || e.condition.predicate(pokemon)),
|
|
||||||
).length &&
|
|
||||||
pokemon.getFusionFormKey() !== SpeciesFormKey.GIGANTAMAX
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
override queryParty(partyPokemon: PlayerPokemon[]): PlayerPokemon[] {
|
|
||||||
if (!this.invertQuery) {
|
|
||||||
return partyPokemon.filter(
|
|
||||||
pokemon =>
|
|
||||||
this.requiredEvolutionItem.filter(evolutionItem => this.filterByEvo(pokemon, evolutionItem)).length > 0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// for an inverted query, we only want to get the pokemon that don't have ANY of the listed evolutionItemss
|
|
||||||
return partyPokemon.filter(
|
|
||||||
pokemon =>
|
|
||||||
this.requiredEvolutionItem.filter(evolutionItems => this.filterByEvo(pokemon, evolutionItems)).length === 0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
override getDialogueToken(pokemon?: PlayerPokemon): [string, string] {
|
|
||||||
const requiredItems = this.requiredEvolutionItem.filter(evoItem => this.filterByEvo(pokemon, evoItem));
|
|
||||||
if (requiredItems.length > 0) {
|
|
||||||
return ["evolutionItem", EvolutionItem[requiredItems[0]]];
|
|
||||||
}
|
|
||||||
return ["evolutionItem", ""];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class HeldItemRequirement extends EncounterPokemonRequirement {
|
export class HeldItemRequirement extends EncounterPokemonRequirement {
|
||||||
requiredHeldItemModifiers: string[];
|
requiredHeldItemModifiers: string[];
|
||||||
minNumberOfPokemon: number;
|
minNumberOfPokemon: number;
|
||||||
|
@ -97,7 +97,6 @@ import { Gender } from "#app/data/gender";
|
|||||||
import { Status, getRandomStatus } from "#app/data/status-effect";
|
import { Status, getRandomStatus } from "#app/data/status-effect";
|
||||||
import type {
|
import type {
|
||||||
SpeciesFormEvolution,
|
SpeciesFormEvolution,
|
||||||
SpeciesEvolutionCondition,
|
|
||||||
} from "#app/data/balance/pokemon-evolutions";
|
} from "#app/data/balance/pokemon-evolutions";
|
||||||
import {
|
import {
|
||||||
pokemonEvolutions,
|
pokemonEvolutions,
|
||||||
@ -2874,18 +2873,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
if (pokemonEvolutions.hasOwnProperty(this.species.speciesId)) {
|
if (pokemonEvolutions.hasOwnProperty(this.species.speciesId)) {
|
||||||
const evolutions = pokemonEvolutions[this.species.speciesId];
|
const evolutions = pokemonEvolutions[this.species.speciesId];
|
||||||
for (const e of evolutions) {
|
for (const e of evolutions) {
|
||||||
if (
|
if (e.validate(this)) {
|
||||||
!e.item &&
|
return e;
|
||||||
this.level >= e.level &&
|
|
||||||
(isNullOrUndefined(e.preFormKey) ||
|
|
||||||
this.getFormKey() === e.preFormKey)
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
e.condition === null ||
|
|
||||||
(e.condition as SpeciesEvolutionCondition).predicate(this)
|
|
||||||
) {
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2899,18 +2888,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
this.fusionSpecies.speciesId
|
this.fusionSpecies.speciesId
|
||||||
].map(e => new FusionSpeciesFormEvolution(this.species.speciesId, e));
|
].map(e => new FusionSpeciesFormEvolution(this.species.speciesId, e));
|
||||||
for (const fe of fusionEvolutions) {
|
for (const fe of fusionEvolutions) {
|
||||||
if (
|
if (fe.validate(this)) {
|
||||||
!fe.item &&
|
return fe;
|
||||||
this.level >= fe.level &&
|
|
||||||
(isNullOrUndefined(fe.preFormKey) ||
|
|
||||||
this.getFusionFormKey() === fe.preFormKey)
|
|
||||||
) {
|
|
||||||
if (
|
|
||||||
fe.condition === null ||
|
|
||||||
(fe.condition as SpeciesEvolutionCondition).predicate(this)
|
|
||||||
) {
|
|
||||||
return fe;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6843,7 +6822,7 @@ export class PlayerPokemon extends Pokemon {
|
|||||||
) {
|
) {
|
||||||
const newEvolution = pokemonEvolutions[evoSpecies.speciesId][1];
|
const newEvolution = pokemonEvolutions[evoSpecies.speciesId][1];
|
||||||
|
|
||||||
if (newEvolution.condition?.predicate(this)) {
|
if (newEvolution.validate(this, evoSpecies.speciesId === this.species.speciesId)) {
|
||||||
const newPokemon = globalScene.addPlayerPokemon(
|
const newPokemon = globalScene.addPlayerPokemon(
|
||||||
this.species,
|
this.species,
|
||||||
this.level,
|
this.level,
|
||||||
@ -7144,9 +7123,6 @@ export class EnemyPokemon extends Pokemon {
|
|||||||
pe.speciesId === speciesId &&
|
pe.speciesId === speciesId &&
|
||||||
(!pe.evoFormKey || pe.evoFormKey === this.getFormKey()),
|
(!pe.evoFormKey || pe.evoFormKey === this.getFormKey()),
|
||||||
);
|
);
|
||||||
if (evolution?.condition?.enforceFunc) {
|
|
||||||
evolution.condition.enforceFunc(this);
|
|
||||||
}
|
|
||||||
speciesId = prevolution;
|
speciesId = prevolution;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1214,9 +1214,7 @@ export class EvolutionItemModifierType extends PokemonModifierType implements Ge
|
|||||||
pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) &&
|
pokemonEvolutions.hasOwnProperty(pokemon.species.speciesId) &&
|
||||||
pokemonEvolutions[pokemon.species.speciesId].filter(
|
pokemonEvolutions[pokemon.species.speciesId].filter(
|
||||||
e =>
|
e =>
|
||||||
e.item === this.evolutionItem &&
|
e.validate(pokemon, false, this.evolutionItem),
|
||||||
(!e.condition || e.condition.predicate(pokemon)) &&
|
|
||||||
(e.preFormKey === null || e.preFormKey === pokemon.getFormKey()),
|
|
||||||
).length &&
|
).length &&
|
||||||
pokemon.getFormKey() !== SpeciesFormKey.GIGANTAMAX
|
pokemon.getFormKey() !== SpeciesFormKey.GIGANTAMAX
|
||||||
) {
|
) {
|
||||||
@ -1228,9 +1226,7 @@ export class EvolutionItemModifierType extends PokemonModifierType implements Ge
|
|||||||
pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) &&
|
pokemonEvolutions.hasOwnProperty(pokemon.fusionSpecies.speciesId) &&
|
||||||
pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter(
|
pokemonEvolutions[pokemon.fusionSpecies.speciesId].filter(
|
||||||
e =>
|
e =>
|
||||||
e.item === this.evolutionItem &&
|
e.validate(pokemon, true, this.evolutionItem),
|
||||||
(!e.condition || e.condition.predicate(pokemon)) &&
|
|
||||||
(e.preFormKey === null || e.preFormKey === pokemon.getFusionFormKey()),
|
|
||||||
).length &&
|
).length &&
|
||||||
pokemon.getFusionFormKey() !== SpeciesFormKey.GIGANTAMAX
|
pokemon.getFusionFormKey() !== SpeciesFormKey.GIGANTAMAX
|
||||||
) {
|
) {
|
||||||
@ -1566,9 +1562,7 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator {
|
|||||||
const evolutions = pokemonEvolutions[p.species.speciesId];
|
const evolutions = pokemonEvolutions[p.species.speciesId];
|
||||||
return evolutions.filter(
|
return evolutions.filter(
|
||||||
e =>
|
e =>
|
||||||
e.item !== EvolutionItem.NONE &&
|
e.isValidItemEvolution(p),
|
||||||
(e.evoFormKey === null || (e.preFormKey || "") === p.getFormKey()) &&
|
|
||||||
(!e.condition || e.condition.predicate(p)),
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
party
|
party
|
||||||
@ -1585,14 +1579,12 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator {
|
|||||||
const evolutions = pokemonEvolutions[p.fusionSpecies!.speciesId];
|
const evolutions = pokemonEvolutions[p.fusionSpecies!.speciesId];
|
||||||
return evolutions.filter(
|
return evolutions.filter(
|
||||||
e =>
|
e =>
|
||||||
e.item !== EvolutionItem.NONE &&
|
e.validate(p, true),
|
||||||
(e.evoFormKey === null || (e.preFormKey || "") === p.getFusionFormKey()) &&
|
|
||||||
(!e.condition || e.condition.predicate(p)),
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
.flat()
|
.flat()
|
||||||
.flatMap(e => e.item)
|
.flatMap(e => e.evoItem)
|
||||||
.filter(i => (!!i && i > 50) === rare);
|
.filter(i => (!!i && i > 50) === rare);
|
||||||
|
|
||||||
if (!evolutionItemPool.length) {
|
if (!evolutionItemPool.length) {
|
||||||
|
@ -2378,18 +2378,14 @@ export class EvolutionItemModifier extends ConsumablePokemonModifier {
|
|||||||
let matchingEvolution = pokemonEvolutions.hasOwnProperty(playerPokemon.species.speciesId)
|
let matchingEvolution = pokemonEvolutions.hasOwnProperty(playerPokemon.species.speciesId)
|
||||||
? pokemonEvolutions[playerPokemon.species.speciesId].find(
|
? pokemonEvolutions[playerPokemon.species.speciesId].find(
|
||||||
e =>
|
e =>
|
||||||
e.item === this.type.evolutionItem &&
|
e.evoItem === this.type.evolutionItem && e.validate(playerPokemon, false, e.item!),
|
||||||
(e.evoFormKey === null || (e.preFormKey || "") === playerPokemon.getFormKey()) &&
|
|
||||||
(!e.condition || e.condition.predicate(playerPokemon)),
|
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!matchingEvolution && playerPokemon.isFusion()) {
|
if (!matchingEvolution && playerPokemon.isFusion()) {
|
||||||
matchingEvolution = pokemonEvolutions[playerPokemon.fusionSpecies!.speciesId].find(
|
matchingEvolution = pokemonEvolutions[playerPokemon.fusionSpecies!.speciesId].find(
|
||||||
e =>
|
e =>
|
||||||
e.item === this.type.evolutionItem && // TODO: is the bang correct?
|
e.evoItem === this.type.evolutionItem && e.validate(playerPokemon, true, e.item!),
|
||||||
(e.evoFormKey === null || (e.preFormKey || "") === playerPokemon.getFusionFormKey()) &&
|
|
||||||
(!e.condition || e.condition.predicate(playerPokemon)),
|
|
||||||
);
|
);
|
||||||
if (matchingEvolution) {
|
if (matchingEvolution) {
|
||||||
matchingEvolution = new FusionSpeciesFormEvolution(playerPokemon.species.speciesId, matchingEvolution);
|
matchingEvolution = new FusionSpeciesFormEvolution(playerPokemon.species.speciesId, matchingEvolution);
|
||||||
|
Loading…
Reference in New Issue
Block a user