mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 15:32:18 +02:00
Split modifier-type.ts into multiple files
This commit is contained in:
parent
f9e6785c35
commit
a402137754
@ -53,18 +53,14 @@ import { GameData } from "#app/system/game-data";
|
||||
import { addTextObject, getTextColor, TextStyle } from "#app/ui/text";
|
||||
import { allMoves } from "./data/data-lists";
|
||||
import { MusicPreference } from "#app/system/settings/settings";
|
||||
import { getModifierType, modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
||||
import {
|
||||
getDefaultModifierTypeForTier,
|
||||
getEnemyModifierTypesForWave,
|
||||
getLuckString,
|
||||
getLuckTextTint,
|
||||
getModifierPoolForType,
|
||||
getModifierType,
|
||||
getPartyLuckValue,
|
||||
ModifierPoolType,
|
||||
modifierTypes,
|
||||
PokemonHeldItemModifierType,
|
||||
} from "#app/modifier/modifier-type";
|
||||
} from "#app/modifier/modifier-pool";
|
||||
import { getLuckString, getLuckTextTint, getPartyLuckValue } from "#app/modifier/modifier-utils";
|
||||
import AbilityBar from "#app/ui/ability-bar";
|
||||
import {
|
||||
applyAbAttrs,
|
||||
|
@ -13,7 +13,8 @@ import { TrainerPartyCompoundTemplate } from "#app/data/trainers/TrainerPartyTem
|
||||
import { TrainerPartyTemplate } from "#app/data/trainers/TrainerPartyTemplate";
|
||||
import { ModifierTier } from "#app/modifier/modifier-tier";
|
||||
import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
||||
import { ModifierPoolType, modifierTypes } from "#app/modifier/modifier-type";
|
||||
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||
import { ModifierPoolType } from "#app/modifier/modifier-pool";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { PartyMemberStrength } from "#enums/party-member-strength";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
@ -49,6 +50,7 @@ import { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
||||
import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
|
||||
import { EncounterAnim } from "#enums/encounter-anims";
|
||||
import { Challenges } from "#enums/challenges";
|
||||
import { withTierFromPool } from "#app/modifier/modifier-pool";
|
||||
|
||||
/** the i18n namespace for the encounter */
|
||||
const namespace = "mysteryEncounters/clowningAround";
|
||||
@ -318,7 +320,7 @@ export const ClowningAroundEncounter: MysteryEncounter = MysteryEncounterBuilder
|
||||
let numRogue = 0;
|
||||
|
||||
for (const m of items.filter(m => m.isTransferable && !(m instanceof BerryModifier))) {
|
||||
const type = m.type.withTierFromPool(ModifierPoolType.PLAYER, party);
|
||||
const type = withTierFromPool(m.type, ModifierPoolType.PLAYER, party);
|
||||
const tier = type.tier ?? ModifierTier.ULTRA;
|
||||
if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) {
|
||||
numRogue += m.stackCount;
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
getPlayerModifierTypeOptions,
|
||||
ModifierPoolType,
|
||||
regenerateModifierPoolThresholds,
|
||||
} from "#app/modifier/modifier-type";
|
||||
} from "#app/modifier/modifier-pool";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter";
|
||||
@ -54,6 +54,7 @@ import type { PokeballType } from "#enums/pokeball";
|
||||
import { doShinySparkleAnim } from "#app/field/anims";
|
||||
import { TrainerType } from "#enums/trainer-type";
|
||||
import { timedEventManager } from "#app/global-event-manager";
|
||||
import { withTierFromPool } from "#app/modifier/modifier-pool";
|
||||
|
||||
/** the i18n namespace for the encounter */
|
||||
const namespace = "mysteryEncounters/globalTradeSystem";
|
||||
@ -437,7 +438,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter = MysteryEncounterBuil
|
||||
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||
|
||||
// Check tier of the traded item, the received item will be one tier up
|
||||
const type = modifier.type.withTierFromPool(ModifierPoolType.PLAYER, party);
|
||||
const type = withTierFromPool(modifier.type, ModifierPoolType.PLAYER, party);
|
||||
let tier = type.tier ?? ModifierTier.GREAT;
|
||||
// Eggs and White Herb are not in the pool
|
||||
if (type.id === "WHITE_HERB") {
|
||||
|
@ -23,7 +23,8 @@ import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode
|
||||
import { Biome } from "#enums/biome";
|
||||
import { getBiomeKey } from "#app/field/arena";
|
||||
import { PokemonType } from "#enums/pokemon-type";
|
||||
import { getPartyLuckValue, modifierTypes } from "#app/modifier/modifier-type";
|
||||
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||
import { getPartyLuckValue } from "#app/modifier/modifier-utils";
|
||||
import { TrainerSlot } from "#enums/trainer-slot";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
|
@ -11,15 +11,19 @@ import { showEncounterText } from "#app/data/mystery-encounters/utils/encounter-
|
||||
import type { AiType, PlayerPokemon } from "#app/field/pokemon";
|
||||
import type Pokemon from "#app/field/pokemon";
|
||||
import { EnemyPokemon, FieldPosition, PokemonMove } from "#app/field/pokemon";
|
||||
import type { CustomModifierSettings, ModifierType } from "#app/modifier/modifier-type";
|
||||
import {
|
||||
getPartyLuckValue,
|
||||
ModifierPoolType,
|
||||
type ModifierType,
|
||||
ModifierTypeGenerator,
|
||||
ModifierTypeOption,
|
||||
modifierTypes,
|
||||
regenerateModifierPoolThresholds,
|
||||
} from "#app/modifier/modifier-type";
|
||||
import {
|
||||
type CustomModifierSettings,
|
||||
ModifierPoolType,
|
||||
regenerateModifierPoolThresholds,
|
||||
withTierFromPool,
|
||||
} from "#app/modifier/modifier-pool";
|
||||
import { getPartyLuckValue } from "#app/modifier/modifier-utils";
|
||||
import {
|
||||
MysteryEncounterBattlePhase,
|
||||
MysteryEncounterBattleStartCleanupPhase,
|
||||
@ -513,9 +517,11 @@ export function generateModifierType(modifier: () => ModifierType, pregenArgs?:
|
||||
let result: ModifierType = modifierTypes[modifierId]();
|
||||
|
||||
// Populates item id and tier (order matters)
|
||||
result = result
|
||||
.withIdFromFunc(modifierTypes[modifierId])
|
||||
.withTierFromPool(ModifierPoolType.PLAYER, globalScene.getPlayerParty());
|
||||
result = withTierFromPool(
|
||||
result.withIdFromFunc(modifierTypes[modifierId]),
|
||||
ModifierPoolType.PLAYER,
|
||||
globalScene.getPlayerParty(),
|
||||
);
|
||||
|
||||
return result instanceof ModifierTypeGenerator
|
||||
? result.generateType(globalScene.getPlayerParty(), pregenArgs)
|
||||
|
1418
src/modifier/modifier-pool.ts
Normal file
1418
src/modifier/modifier-pool.ts
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
67
src/modifier/modifier-utils.ts
Normal file
67
src/modifier/modifier-utils.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball";
|
||||
import type Pokemon from "#app/field/pokemon";
|
||||
import { timedEventManager } from "#app/global-event-manager";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { getModifierTierTextTint } from "#app/ui/text";
|
||||
import { NumberHolder, randSeedInt } from "#app/utils/common";
|
||||
import type { PokeballType } from "#enums/pokeball";
|
||||
import { ModifierTier } from "./modifier-tier";
|
||||
|
||||
/**
|
||||
* Used to check if the player has max of a given ball type in Classic
|
||||
* @param ballType The {@linkcode PokeballType} being checked
|
||||
* @returns boolean: true if the player has the maximum of a given ball type
|
||||
*/
|
||||
export function hasMaximumBalls(ballType: PokeballType): boolean {
|
||||
return globalScene.gameMode.isClassic && globalScene.pokeballCounts[ballType] >= MAX_PER_TYPE_POKEBALLS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the team's luck value.
|
||||
* @param party The player's party.
|
||||
* @returns A number between 0 and 14 based on the party's total luck value, or a random number between 0 and 14 if the player is in Daily Run mode.
|
||||
*/
|
||||
export function getPartyLuckValue(party: Pokemon[]): number {
|
||||
if (globalScene.gameMode.isDaily) {
|
||||
const DailyLuck = new NumberHolder(0);
|
||||
globalScene.executeWithSeedOffset(
|
||||
() => {
|
||||
DailyLuck.value = randSeedInt(15); // Random number between 0 and 14
|
||||
},
|
||||
0,
|
||||
globalScene.seed,
|
||||
);
|
||||
return DailyLuck.value;
|
||||
}
|
||||
const eventSpecies = timedEventManager.getEventLuckBoostedSpecies();
|
||||
const luck = Phaser.Math.Clamp(
|
||||
party
|
||||
.map(p => (p.isAllowedInBattle() ? p.getLuck() + (eventSpecies.includes(p.species.speciesId) ? 1 : 0) : 0))
|
||||
.reduce((total: number, value: number) => (total += value), 0),
|
||||
0,
|
||||
14,
|
||||
);
|
||||
return Math.min(timedEventManager.getEventLuckBoost() + (luck ?? 0), 14);
|
||||
}
|
||||
|
||||
export function getLuckString(luckValue: number): string {
|
||||
return ["D", "C", "C+", "B-", "B", "B+", "A-", "A", "A+", "A++", "S", "S+", "SS", "SS+", "SSS"][luckValue];
|
||||
}
|
||||
|
||||
export function getLuckTextTint(luckValue: number): number {
|
||||
let modifierTier: ModifierTier;
|
||||
if (luckValue > 11) {
|
||||
modifierTier = ModifierTier.LUXURY;
|
||||
} else if (luckValue > 9) {
|
||||
modifierTier = ModifierTier.MASTER;
|
||||
} else if (luckValue > 5) {
|
||||
modifierTier = ModifierTier.ROGUE;
|
||||
} else if (luckValue > 2) {
|
||||
modifierTier = ModifierTier.ULTRA;
|
||||
} else if (luckValue) {
|
||||
modifierTier = ModifierTier.GREAT;
|
||||
} else {
|
||||
modifierTier = ModifierTier.COMMON;
|
||||
}
|
||||
return getModifierTierTextTint(modifierTier);
|
||||
}
|
@ -2,8 +2,6 @@ import { globalScene } from "#app/global-scene";
|
||||
import type { ModifierTier } from "#app/modifier/modifier-tier";
|
||||
import type { ModifierTypeOption, ModifierType } from "#app/modifier/modifier-type";
|
||||
import {
|
||||
regenerateModifierPoolThresholds,
|
||||
getPlayerShopModifierTypeOptionsForWave,
|
||||
PokemonModifierType,
|
||||
FusePokemonModifierType,
|
||||
PokemonMoveModifierType,
|
||||
@ -11,9 +9,14 @@ import {
|
||||
RememberMoveModifierType,
|
||||
PokemonPpRestoreModifierType,
|
||||
PokemonPpUpModifierType,
|
||||
} from "#app/modifier/modifier-type";
|
||||
import {
|
||||
regenerateModifierPoolThresholds,
|
||||
getPlayerShopModifierTypeOptionsForWave,
|
||||
ModifierPoolType,
|
||||
getPlayerModifierTypeOptions,
|
||||
} from "#app/modifier/modifier-type";
|
||||
type CustomModifierSettings,
|
||||
} from "#app/modifier/modifier-pool";
|
||||
import type { Modifier } from "#app/modifier/modifier";
|
||||
import {
|
||||
ExtraModifierModifier,
|
||||
@ -28,7 +31,6 @@ import { UiMode } from "#enums/ui-mode";
|
||||
import i18next from "i18next";
|
||||
import { BattlePhase } from "./battle-phase";
|
||||
import Overrides from "#app/overrides";
|
||||
import type { CustomModifierSettings } from "#app/modifier/modifier-type";
|
||||
import { isNullOrUndefined, NumberHolder } from "#app/utils/common";
|
||||
|
||||
export class SelectModifierPhase extends BattlePhase {
|
||||
|
Loading…
Reference in New Issue
Block a user