mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-21 17:12:44 +02:00
Some changes to modifier files
This commit is contained in:
parent
a15920a605
commit
9611948d80
@ -1,7 +1,10 @@
|
|||||||
export enum ModifierPoolType {
|
export enum ModifierPoolType {
|
||||||
PLAYER,
|
PLAYER,
|
||||||
WILD,
|
|
||||||
TRAINER,
|
|
||||||
ENEMY_BUFF,
|
ENEMY_BUFF,
|
||||||
DAILY_STARTER
|
DAILY_STARTER
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum HeldItemPoolType {
|
||||||
|
WILD,
|
||||||
|
TRAINER,
|
||||||
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { FusionSpeciesFormEvolution, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
|
import { FusionSpeciesFormEvolution, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions";
|
||||||
import { getLevelTotalExp } from "#app/data/exp";
|
import { getLevelTotalExp } from "#app/data/exp";
|
||||||
import { allMoves, modifierTypes } from "#app/data/data-lists";
|
|
||||||
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
|
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
|
||||||
import { getStatusEffectHealText } from "#app/data/status-effect";
|
import { getStatusEffectHealText } from "#app/data/status-effect";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
@ -33,42 +32,26 @@ import {
|
|||||||
type ModifierType,
|
type ModifierType,
|
||||||
type TerastallizeModifierType,
|
type TerastallizeModifierType,
|
||||||
type TmModifierType,
|
type TmModifierType,
|
||||||
getModifierType,
|
|
||||||
ModifierTypeGenerator,
|
|
||||||
modifierTypes,
|
modifierTypes,
|
||||||
} from "./modifier-type";
|
} from "./modifier-type";
|
||||||
import { getModifierType } from "#app/utils/modifier-utils";
|
|
||||||
import { FRIENDSHIP_GAIN_FROM_RARE_CANDY } from "#app/data/balance/starters";
|
import { FRIENDSHIP_GAIN_FROM_RARE_CANDY } from "#app/data/balance/starters";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import type { ModifierInstanceMap, ModifierString } from "#app/@types/modifier-types";
|
import type { ModifierInstanceMap, ModifierString } from "#app/@types/modifier-types";
|
||||||
|
|
||||||
export type ModifierPredicate = (modifier: Modifier) => boolean;
|
export type ModifierPredicate = (modifier: Modifier) => boolean;
|
||||||
|
|
||||||
|
|
||||||
const iconOverflowIndex = 24;
|
const iconOverflowIndex = 24;
|
||||||
|
|
||||||
export const modifierSortFunc = (a: Modifier, b: Modifier): number => {
|
export const modifierSortFunc = (a: Modifier, b: Modifier): number => {
|
||||||
const itemNameMatch = a.type.name.localeCompare(b.type.name);
|
const itemNameMatch = a.type.name.localeCompare(b.type.name);
|
||||||
const typeNameMatch = a.constructor.name.localeCompare(b.constructor.name);
|
const typeNameMatch = a.constructor.name.localeCompare(b.constructor.name);
|
||||||
const aId = a instanceof PokemonHeldItemModifier && a.pokemonId ? a.pokemonId : 4294967295;
|
|
||||||
const bId = b instanceof PokemonHeldItemModifier && b.pokemonId ? b.pokemonId : 4294967295;
|
|
||||||
|
|
||||||
//First sort by pokemonID
|
|
||||||
if (aId < bId) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (aId > bId) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (aId === bId) {
|
|
||||||
//Then sort by item type
|
//Then sort by item type
|
||||||
if (typeNameMatch === 0) {
|
if (typeNameMatch === 0) {
|
||||||
return itemNameMatch;
|
return itemNameMatch;
|
||||||
//Finally sort by item name
|
//Finally sort by item name
|
||||||
}
|
}
|
||||||
return typeNameMatch;
|
return typeNameMatch;
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ModifierBar extends Phaser.GameObjects.Container {
|
export class ModifierBar extends Phaser.GameObjects.Container {
|
||||||
@ -172,23 +155,6 @@ export abstract class Modifier {
|
|||||||
return this instanceof targetModifier;
|
return this instanceof targetModifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return whether this modifier is of the given class
|
|
||||||
*
|
|
||||||
* @remarks
|
|
||||||
* Used to avoid requiring the caller to have imported the specific modifier class, avoiding circular dependencies.
|
|
||||||
*
|
|
||||||
* @param modifier - The modifier to check against
|
|
||||||
* @returns Whether the modiifer is an instance of the given type
|
|
||||||
*/
|
|
||||||
public is<T extends ModifierString>(modifier: T): this is ModifierInstanceMap[T] {
|
|
||||||
const targetModifier = ModifierClassMap[modifier];
|
|
||||||
if (!targetModifier) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return this instanceof targetModifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
match(_modifier: Modifier): boolean {
|
match(_modifier: Modifier): boolean {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1289,41 +1255,6 @@ export class ExpBalanceModifier extends PersistentModifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MoneyRewardModifier extends ConsumableModifier {
|
|
||||||
private moneyMultiplier: number;
|
|
||||||
|
|
||||||
constructor(type: ModifierType, moneyMultiplier: number) {
|
|
||||||
super(type);
|
|
||||||
|
|
||||||
this.moneyMultiplier = moneyMultiplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies {@linkcode MoneyRewardModifier}
|
|
||||||
* @returns always `true`
|
|
||||||
*/
|
|
||||||
override apply(): boolean {
|
|
||||||
const moneyAmount = new NumberHolder(globalScene.getWaveMoneyAmount(this.moneyMultiplier));
|
|
||||||
|
|
||||||
globalScene.applyModifiers(MoneyMultiplierModifier, true, moneyAmount);
|
|
||||||
|
|
||||||
globalScene.addMoney(moneyAmount.value);
|
|
||||||
|
|
||||||
globalScene.getPlayerParty().map(p => {
|
|
||||||
if (p.species?.speciesId === SpeciesId.GIMMIGHOUL || p.fusionSpecies?.speciesId === SpeciesId.GIMMIGHOUL) {
|
|
||||||
const factor = Math.min(Math.floor(this.moneyMultiplier), 3);
|
|
||||||
const modifier = getModifierType(modifierTypes.EVOLUTION_TRACKER_GIMMIGHOUL).newModifier(
|
|
||||||
p,
|
|
||||||
factor,
|
|
||||||
) as EvoTrackerModifier;
|
|
||||||
globalScene.addModifier(modifier);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class MoneyMultiplierModifier extends PersistentModifier {
|
export class MoneyMultiplierModifier extends PersistentModifier {
|
||||||
match(modifier: Modifier): boolean {
|
match(modifier: Modifier): boolean {
|
||||||
return modifier instanceof MoneyMultiplierModifier;
|
return modifier instanceof MoneyMultiplierModifier;
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
import { ModifierPoolType } from "#enums/modifier-pool-type";
|
import { ModifierPoolType } from "#enums/modifier-pool-type";
|
||||||
import {
|
import { dailyStarterModifierPool, enemyBuffModifierPool, modifierPool } from "#app/modifier/modifier-pools";
|
||||||
dailyStarterModifierPool,
|
|
||||||
enemyBuffModifierPool,
|
|
||||||
modifierPool,
|
|
||||||
trainerModifierPool,
|
|
||||||
wildModifierPool,
|
|
||||||
} from "#app/modifier/modifier-pools";
|
|
||||||
import type { ModifierPool, ModifierTypeFunc } from "#app/@types/modifier-types";
|
import type { ModifierPool, ModifierTypeFunc } from "#app/@types/modifier-types";
|
||||||
import { modifierTypes } from "#app/data/data-lists";
|
import { modifierTypes } from "#app/data/data-lists";
|
||||||
import type { ModifierType } from "#app/modifier/modifier-type";
|
import type { ModifierType } from "#app/modifier/modifier-type";
|
||||||
@ -14,10 +8,6 @@ export function getModifierPoolForType(poolType: ModifierPoolType): ModifierPool
|
|||||||
switch (poolType) {
|
switch (poolType) {
|
||||||
case ModifierPoolType.PLAYER:
|
case ModifierPoolType.PLAYER:
|
||||||
return modifierPool;
|
return modifierPool;
|
||||||
case ModifierPoolType.WILD:
|
|
||||||
return wildModifierPool;
|
|
||||||
case ModifierPoolType.TRAINER:
|
|
||||||
return trainerModifierPool;
|
|
||||||
case ModifierPoolType.ENEMY_BUFF:
|
case ModifierPoolType.ENEMY_BUFF:
|
||||||
return enemyBuffModifierPool;
|
return enemyBuffModifierPool;
|
||||||
case ModifierPoolType.DAILY_STARTER:
|
case ModifierPoolType.DAILY_STARTER:
|
||||||
|
Loading…
Reference in New Issue
Block a user