mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +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 { addTextObject, getTextColor, TextStyle } from "#app/ui/text";
|
||||||
import { allMoves } from "./data/data-lists";
|
import { allMoves } from "./data/data-lists";
|
||||||
import { MusicPreference } from "#app/system/settings/settings";
|
import { MusicPreference } from "#app/system/settings/settings";
|
||||||
|
import { getModifierType, modifierTypes, PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
||||||
import {
|
import {
|
||||||
getDefaultModifierTypeForTier,
|
getDefaultModifierTypeForTier,
|
||||||
getEnemyModifierTypesForWave,
|
getEnemyModifierTypesForWave,
|
||||||
getLuckString,
|
|
||||||
getLuckTextTint,
|
|
||||||
getModifierPoolForType,
|
getModifierPoolForType,
|
||||||
getModifierType,
|
|
||||||
getPartyLuckValue,
|
|
||||||
ModifierPoolType,
|
ModifierPoolType,
|
||||||
modifierTypes,
|
} from "#app/modifier/modifier-pool";
|
||||||
PokemonHeldItemModifierType,
|
import { getLuckString, getLuckTextTint, getPartyLuckValue } from "#app/modifier/modifier-utils";
|
||||||
} from "#app/modifier/modifier-type";
|
|
||||||
import AbilityBar from "#app/ui/ability-bar";
|
import AbilityBar from "#app/ui/ability-bar";
|
||||||
import {
|
import {
|
||||||
applyAbAttrs,
|
applyAbAttrs,
|
||||||
|
@ -13,7 +13,8 @@ import { TrainerPartyCompoundTemplate } from "#app/data/trainers/TrainerPartyTem
|
|||||||
import { TrainerPartyTemplate } from "#app/data/trainers/TrainerPartyTemplate";
|
import { TrainerPartyTemplate } from "#app/data/trainers/TrainerPartyTemplate";
|
||||||
import { ModifierTier } from "#app/modifier/modifier-tier";
|
import { ModifierTier } from "#app/modifier/modifier-tier";
|
||||||
import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type";
|
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 { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||||
import { PartyMemberStrength } from "#enums/party-member-strength";
|
import { PartyMemberStrength } from "#enums/party-member-strength";
|
||||||
import { globalScene } from "#app/global-scene";
|
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 { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants";
|
||||||
import { EncounterAnim } from "#enums/encounter-anims";
|
import { EncounterAnim } from "#enums/encounter-anims";
|
||||||
import { Challenges } from "#enums/challenges";
|
import { Challenges } from "#enums/challenges";
|
||||||
|
import { withTierFromPool } from "#app/modifier/modifier-pool";
|
||||||
|
|
||||||
/** the i18n namespace for the encounter */
|
/** the i18n namespace for the encounter */
|
||||||
const namespace = "mysteryEncounters/clowningAround";
|
const namespace = "mysteryEncounters/clowningAround";
|
||||||
@ -318,7 +320,7 @@ export const ClowningAroundEncounter: MysteryEncounter = MysteryEncounterBuilder
|
|||||||
let numRogue = 0;
|
let numRogue = 0;
|
||||||
|
|
||||||
for (const m of items.filter(m => m.isTransferable && !(m instanceof BerryModifier))) {
|
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;
|
const tier = type.tier ?? ModifierTier.ULTRA;
|
||||||
if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) {
|
if (type.id === "GOLDEN_EGG" || tier === ModifierTier.ROGUE) {
|
||||||
numRogue += m.stackCount;
|
numRogue += m.stackCount;
|
||||||
|
@ -11,7 +11,7 @@ import {
|
|||||||
getPlayerModifierTypeOptions,
|
getPlayerModifierTypeOptions,
|
||||||
ModifierPoolType,
|
ModifierPoolType,
|
||||||
regenerateModifierPoolThresholds,
|
regenerateModifierPoolThresholds,
|
||||||
} from "#app/modifier/modifier-type";
|
} from "#app/modifier/modifier-pool";
|
||||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter";
|
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 { doShinySparkleAnim } from "#app/field/anims";
|
||||||
import { TrainerType } from "#enums/trainer-type";
|
import { TrainerType } from "#enums/trainer-type";
|
||||||
import { timedEventManager } from "#app/global-event-manager";
|
import { timedEventManager } from "#app/global-event-manager";
|
||||||
|
import { withTierFromPool } from "#app/modifier/modifier-pool";
|
||||||
|
|
||||||
/** the i18n namespace for the encounter */
|
/** the i18n namespace for the encounter */
|
||||||
const namespace = "mysteryEncounters/globalTradeSystem";
|
const namespace = "mysteryEncounters/globalTradeSystem";
|
||||||
@ -437,7 +438,7 @@ export const GlobalTradeSystemEncounter: MysteryEncounter = MysteryEncounterBuil
|
|||||||
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
const chosenPokemon: PlayerPokemon = encounter.misc.chosenPokemon;
|
||||||
|
|
||||||
// Check tier of the traded item, the received item will be one tier up
|
// 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;
|
let tier = type.tier ?? ModifierTier.GREAT;
|
||||||
// Eggs and White Herb are not in the pool
|
// Eggs and White Herb are not in the pool
|
||||||
if (type.id === "WHITE_HERB") {
|
if (type.id === "WHITE_HERB") {
|
||||||
|
@ -23,7 +23,8 @@ import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode
|
|||||||
import { Biome } from "#enums/biome";
|
import { Biome } from "#enums/biome";
|
||||||
import { getBiomeKey } from "#app/field/arena";
|
import { getBiomeKey } from "#app/field/arena";
|
||||||
import { PokemonType } from "#enums/pokemon-type";
|
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 { TrainerSlot } from "#enums/trainer-slot";
|
||||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
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 { AiType, PlayerPokemon } from "#app/field/pokemon";
|
||||||
import type Pokemon from "#app/field/pokemon";
|
import type Pokemon from "#app/field/pokemon";
|
||||||
import { EnemyPokemon, FieldPosition, PokemonMove } from "#app/field/pokemon";
|
import { EnemyPokemon, FieldPosition, PokemonMove } from "#app/field/pokemon";
|
||||||
import type { CustomModifierSettings, ModifierType } from "#app/modifier/modifier-type";
|
|
||||||
import {
|
import {
|
||||||
getPartyLuckValue,
|
type ModifierType,
|
||||||
ModifierPoolType,
|
|
||||||
ModifierTypeGenerator,
|
ModifierTypeGenerator,
|
||||||
ModifierTypeOption,
|
ModifierTypeOption,
|
||||||
modifierTypes,
|
modifierTypes,
|
||||||
regenerateModifierPoolThresholds,
|
|
||||||
} from "#app/modifier/modifier-type";
|
} from "#app/modifier/modifier-type";
|
||||||
|
import {
|
||||||
|
type CustomModifierSettings,
|
||||||
|
ModifierPoolType,
|
||||||
|
regenerateModifierPoolThresholds,
|
||||||
|
withTierFromPool,
|
||||||
|
} from "#app/modifier/modifier-pool";
|
||||||
|
import { getPartyLuckValue } from "#app/modifier/modifier-utils";
|
||||||
import {
|
import {
|
||||||
MysteryEncounterBattlePhase,
|
MysteryEncounterBattlePhase,
|
||||||
MysteryEncounterBattleStartCleanupPhase,
|
MysteryEncounterBattleStartCleanupPhase,
|
||||||
@ -513,9 +517,11 @@ export function generateModifierType(modifier: () => ModifierType, pregenArgs?:
|
|||||||
let result: ModifierType = modifierTypes[modifierId]();
|
let result: ModifierType = modifierTypes[modifierId]();
|
||||||
|
|
||||||
// Populates item id and tier (order matters)
|
// Populates item id and tier (order matters)
|
||||||
result = result
|
result = withTierFromPool(
|
||||||
.withIdFromFunc(modifierTypes[modifierId])
|
result.withIdFromFunc(modifierTypes[modifierId]),
|
||||||
.withTierFromPool(ModifierPoolType.PLAYER, globalScene.getPlayerParty());
|
ModifierPoolType.PLAYER,
|
||||||
|
globalScene.getPlayerParty(),
|
||||||
|
);
|
||||||
|
|
||||||
return result instanceof ModifierTypeGenerator
|
return result instanceof ModifierTypeGenerator
|
||||||
? result.generateType(globalScene.getPlayerParty(), pregenArgs)
|
? 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 { ModifierTier } from "#app/modifier/modifier-tier";
|
||||||
import type { ModifierTypeOption, ModifierType } from "#app/modifier/modifier-type";
|
import type { ModifierTypeOption, ModifierType } from "#app/modifier/modifier-type";
|
||||||
import {
|
import {
|
||||||
regenerateModifierPoolThresholds,
|
|
||||||
getPlayerShopModifierTypeOptionsForWave,
|
|
||||||
PokemonModifierType,
|
PokemonModifierType,
|
||||||
FusePokemonModifierType,
|
FusePokemonModifierType,
|
||||||
PokemonMoveModifierType,
|
PokemonMoveModifierType,
|
||||||
@ -11,9 +9,14 @@ import {
|
|||||||
RememberMoveModifierType,
|
RememberMoveModifierType,
|
||||||
PokemonPpRestoreModifierType,
|
PokemonPpRestoreModifierType,
|
||||||
PokemonPpUpModifierType,
|
PokemonPpUpModifierType,
|
||||||
|
} from "#app/modifier/modifier-type";
|
||||||
|
import {
|
||||||
|
regenerateModifierPoolThresholds,
|
||||||
|
getPlayerShopModifierTypeOptionsForWave,
|
||||||
ModifierPoolType,
|
ModifierPoolType,
|
||||||
getPlayerModifierTypeOptions,
|
getPlayerModifierTypeOptions,
|
||||||
} from "#app/modifier/modifier-type";
|
type CustomModifierSettings,
|
||||||
|
} from "#app/modifier/modifier-pool";
|
||||||
import type { Modifier } from "#app/modifier/modifier";
|
import type { Modifier } from "#app/modifier/modifier";
|
||||||
import {
|
import {
|
||||||
ExtraModifierModifier,
|
ExtraModifierModifier,
|
||||||
@ -28,7 +31,6 @@ import { UiMode } from "#enums/ui-mode";
|
|||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { BattlePhase } from "./battle-phase";
|
import { BattlePhase } from "./battle-phase";
|
||||||
import Overrides from "#app/overrides";
|
import Overrides from "#app/overrides";
|
||||||
import type { CustomModifierSettings } from "#app/modifier/modifier-type";
|
|
||||||
import { isNullOrUndefined, NumberHolder } from "#app/utils/common";
|
import { isNullOrUndefined, NumberHolder } from "#app/utils/common";
|
||||||
|
|
||||||
export class SelectModifierPhase extends BattlePhase {
|
export class SelectModifierPhase extends BattlePhase {
|
||||||
|
Loading…
Reference in New Issue
Block a user