From aea2c178c9fcf2aa7320f64d055333abeef00a5e Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Tue, 10 Jun 2025 19:54:44 -0400 Subject: [PATCH 01/10] [i18n] Added locales text for force switch moves (#5930) --- src/phases/switch-summon-phase.ts | 42 +++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index f6395397920..71136be0c93 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -174,19 +174,7 @@ export class SwitchSummonPhase extends SummonPhase { party[this.slotIndex] = this.lastPokemon; party[this.fieldIndex] = switchedInPokemon; const showTextAndSummon = () => { - globalScene.ui.showText( - this.player - ? i18next.t("battle:playerGo", { - pokemonName: getPokemonNameWithAffix(switchedInPokemon), - }) - : i18next.t("battle:trainerGo", { - trainerName: globalScene.currentBattle.trainer?.getName( - !(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER, - ), - pokemonName: this.getPokemon().getNameToRender(), - }), - ); - + globalScene.ui.showText(this.getSendOutText(switchedInPokemon)); /** * If this switch is passing a Substitute, make the switched Pokemon matches the returned Pokemon's state as it left. * Otherwise, clear any persisting tags on the returned Pokemon. @@ -265,4 +253,32 @@ export class SwitchSummonPhase extends SummonPhase { queuePostSummon(): void { globalScene.phaseManager.unshiftNew("PostSummonPhase", this.getPokemon().getBattlerIndex()); } + + /** + * Get the text to be displayed when a pokemon is forced to switch and leave the field. + * @param switchedInPokemon - The Pokemon having newly been sent in. + * @returns The text to display. + */ + private getSendOutText(switchedInPokemon: Pokemon): string { + if (this.switchType === SwitchType.FORCE_SWITCH) { + // "XYZ was dragged out!" + return i18next.t("battle:pokemonDraggedOut", { + pokemonName: getPokemonNameWithAffix(switchedInPokemon), + }); + } + if (this.player) { + // "Go! XYZ!" + return i18next.t("battle:playerGo", { + pokemonName: getPokemonNameWithAffix(switchedInPokemon), + }); + } + + // "Trainer sent out XYZ!" + return i18next.t("battle:trainerGo", { + trainerName: globalScene.currentBattle.trainer?.getName( + !(this.fieldIndex % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER, + ), + pokemonName: this.getPokemon().getNameToRender(), + }); + } } From f499ea056866c17bb2fbfce7292469a2a939cdc8 Mon Sep 17 00:00:00 2001 From: Lugiad <2070109+Adri1@users.noreply.github.com> Date: Wed, 11 Jun 2025 06:44:30 +0200 Subject: [PATCH 02/10] [UI/UX] [Localization] Type icons corrections (#5952) * Updated both Spanish type icons * Update Brazilian Portuguese type icons * Update Catalan type icons * Update Traditional Chinese type icons * Update Turkish type icons * Update Russian type icons * Update Catalan type icons * Delete error * Update Russian type icon * Update Russian type icons --- public/images/types_ca.png | Bin 6383 -> 6381 bytes public/images/types_es-ES.png | Bin 2388 -> 5902 bytes public/images/types_es-MX.png | Bin 6131 -> 6290 bytes public/images/types_pt-BR.png | Bin 2374 -> 5919 bytes public/images/types_ru.png | Bin 7570 -> 7637 bytes public/images/types_tr.png | Bin 4467 -> 6175 bytes public/images/types_zh-CN.png | Bin 4412 -> 5646 bytes 7 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/images/types_ca.png b/public/images/types_ca.png index e85c84ed9c987049fd9965771a4a64a12dcc6b0b..a1c295d7b9b1c737a045d399597b661ad82ca5a4 100644 GIT binary patch delta 4498 zcma)9cQD-F*Z#1qh=|^zMvb!37K;_DM+=EWCwd4WN?3y3Xpsb~NAD#?U4)1bb@dj} z`$mhtHbj5-`}gmk_s*TU&zyVDbMBmZX3jag(%aHiE#&m_5GjR+(uzu?Ee8{ql1UmO z=l);g8M&c=y|bgEqJo1xMApH<86xEjb%NN-%Sc09oTL>UWb7TBUF2&#K;J-u|Br`K zNoX+h|Az6RDnV&Yg{uMpeUq-H+Cya4fK7-o%LL2icAvXero5D)Nc{N8-2_0}MJX46sx2dS&W(Ft;f;u{37vb*cUHeD3F$&TP#R}JAC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1x!(2lGvi6E3NQ0fRHu{JNwoI!y8Y znMU*%R~tEOzKboHzSRc8H3v&FP0SoGd~ufMo=mE2B`9Z{lA<4edVVuU0}e^6YGBj3 zR4S*wL~G6~jw|8R5MB@yuf5=(%p(Na$FiT{Hos+)`84riKjdy2e@67p&@0I;LU%-7 zu;B_G2(cs2Wz$nB#Z7tsL0r+x^_;`k79x&&t-`kqG46Y%Th9u@_U%sAS)l;E_{;uh zr~CVYs&0qbh2gXxU-)zLd|vaWrtwvUgSP8WbS%R|0d9mtRFJ+Jba<)jV} z;3~r>9ynlmtRlNFJp+mOa%;8qQP^(cbsc2plf?qvhEX|2c^TH0rPkFhy8(d~c}VL~ zpV}(^PV2Kr!{t}L0UHl@xig-cyZQ+}5Z$9A$uX2=XT?hZcyD8ny`^DZ%Atu~<)Bou zeysq60;7|G2>zz8vQ1kfv+IK3>^oAX;~=C-&Q%u$%-VNZ-8h(m_aUuZy&V+~P+{)8 z?jKJijc7wRZeIGyFlKu`{6h&d3cSnh-xACgYkYp*93afdZtw6EHJ(eJ^7M70dEQzz z#qMLWBz2?wV z_hRoMRXrWpMn*;=>Z8hG@J4#$zurRRwjw1{RpbLNUZ0RBoPN2{ zzI^3AML$3_$_DrxJC<6#s4#R$6CU?vzs;0BB|$M{2GbpRdn1u!GAz8$H}KM_HjC{{ z_2~f(qW^tO`(I(L%74V)zo+=@{EftRxOZyieD=Yj%s50)q5JCKReB`Ri$zS#vRY%# z`-t<79mfn#T**Jk^ZD1To$1v*ahbH^flzz4krP&>2cRzZ86Gk~ZMvEU8s%!%5&r=h C4ruQH diff --git a/public/images/types_es-ES.png b/public/images/types_es-ES.png index 8a321e515c491a3589a7ff7fd2b0c9cd495e3602..3596b7f6a0abf9a35bf0c3f288eeae39a28ef0a8 100644 GIT binary patch literal 5902 zcmbVQ2{@E}*T3x{dl5YtlP%kfVJu_IR)mq|$-d5vF_@(>#*(eVgDfdaCZv?5h^!@v z$WC@jp@l37A!PeTPfyqTe&6%H@ArL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yb UjQiS2?q3SnTf3lZE%7P;0bJ6D7ytkO diff --git a/public/images/types_ru.png b/public/images/types_ru.png index 571e162e8dc9f3da298566982b2634402f9ff570..1e0615f721f27d8cccceed1245195bea8eab43ac 100644 GIT binary patch delta 4800 zcma);c|6qL_s8F3Uz&`uRmgMJ2#}H_+dCNUqwTVpQDSTpQDzeA4Y{AA%&2IOa0&Aq&R9rK?MalSClkT8jf&v z#K4`ANEF;j8tDp`mv?eR$f2At&Q9`)G@^p8PEHCKR~c!zysMKdTn2$ez@6lrUEtCv zXIU9%gd7HmP^dAYkp(5O( zO9E@`;$6d>4i%EamXmZF2)8#p{Nhh~7?1v)f>fsT2u7$!GP&FXo628=aEY4;Q-7j~ z{702@xu)lxlb=vD+G%2z@6Bt<+FJVBlaK*ai7nQ^gj!c-ffoI{mK&YgE28v9pi5t(m`DxXaK3cGsvcGWg7=qL)e|;n}4^! zHyqhVy6-GL)Ne^k3m54^HQTTCu8}6*q^tdDn>4Lo=umiuL_7`YM{jpVy-4% zZA;ic$`%b~S%3#Xhf@;URU_r>NvUg!Us+$5kMLBeT_K1$>O1n?JGl#l6^wfn{VH73 zV|7dAVatS{(@8y+-7pIu`^K$5*Zt6( z{mZ{`eXMI04z5jhblE|H{U8YS$tB4ihgH=9o-Nwj;^Maj5@Jq!vl6|FMr=-#{Zb~M z`6|Dz+ZkS89op3~(t)r{s@o`r@c`6@YM_3`-eyu- z?OY|yxjOlVpM7HyCE9x2Ci!nKDkt1U!7R^Crii$_;@*;VP;nBZw1j>XJw|=lj}q9* zy5OHtQ(YtaZ1QqB^Db%pO<^gBmt;3iMm7Z9EO{ybBdsFv1B9q$!;+;94h^2IOd@YM z#cpt93;+&$+zEAkS=L*t@e|{6RD#dd{g6oA8HK3nlDD^*CKGmaL`5UK$h5Wk)Z3bZ zOij-G(aDtT0g#jXMEsBQOW|;TezAX}p=v8Ei71iL%*nz8I>B8}xiT0~)#kn;-uDVUK% z>XK=v>U(4Ff9U|vb*6RxMD8T8v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 Subject: [PATCH 03/10] [UI/UX] Default cursor to no when stop trying to teach move https://github.com/pagefaultgames/pokerogue/pull/5924 * [UI/UX] "Stop trying to teach move" Defaulting to "No" * [Test] setCursor to 0, 'Yes' to end learning move * Move confirmUIMode to its own file in enums, add docs --------- Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> --- src/enums/confirm-ui-mode.ts | 13 +++++++++++++ src/phases/learn-move-phase.ts | 5 +++++ src/ui/confirm-ui-handler.ts | 14 +++++++++++++- test/phases/learn-move-phase.test.ts | 4 ++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/enums/confirm-ui-mode.ts diff --git a/src/enums/confirm-ui-mode.ts b/src/enums/confirm-ui-mode.ts new file mode 100644 index 00000000000..46bc42374cd --- /dev/null +++ b/src/enums/confirm-ui-mode.ts @@ -0,0 +1,13 @@ +// biome-ignore lint/correctness/noUnusedImports: Used in tsdoc +import type ConfirmUiHandler from "#app/ui/confirm-ui-handler"; + +/** + * Used by {@linkcode ConfirmUiHandler} to determine whether the cursor should start on Yes or No + */ +export const ConfirmUiMode = Object.freeze({ + /** Start cursor on Yes */ + DEFAULT_YES: 1, + /** Start cursor on No */ + DEFAULT_NO: 2 +}); +export type ConfirmUiMode = typeof ConfirmUiMode[keyof typeof ConfirmUiMode]; \ No newline at end of file diff --git a/src/phases/learn-move-phase.ts b/src/phases/learn-move-phase.ts index e24efa63b5a..e197f876d76 100644 --- a/src/phases/learn-move-phase.ts +++ b/src/phases/learn-move-phase.ts @@ -12,6 +12,7 @@ import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { PlayerPartyMemberPokemonPhase } from "#app/phases/player-party-member-pokemon-phase"; import type Pokemon from "#app/field/pokemon"; +import { ConfirmUiMode } from "#enums/confirm-ui-mode"; import { LearnMoveType } from "#enums/learn-move-type"; export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { @@ -163,6 +164,10 @@ export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { globalScene.ui.setMode(this.messageMode); this.replaceMoveCheck(move, pokemon); }, + false, + 0, + 0, + ConfirmUiMode.DEFAULT_NO, ); } diff --git a/src/ui/confirm-ui-handler.ts b/src/ui/confirm-ui-handler.ts index 7b5ca3d7e63..37fd50ca671 100644 --- a/src/ui/confirm-ui-handler.ts +++ b/src/ui/confirm-ui-handler.ts @@ -4,8 +4,11 @@ import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { Button } from "#enums/buttons"; import { globalScene } from "#app/global-scene"; +import { ConfirmUiMode } from "#enums/confirm-ui-mode"; export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { + private confirmUiMode: ConfirmUiMode; + public static readonly windowWidth: number = 48; private switchCheck: boolean; @@ -105,7 +108,16 @@ export default class ConfirmUiHandler extends AbstractOptionSelectUiHandler { this.optionSelectContainer.setPosition(globalScene.game.canvas.width / 6 - 1 + xOffset, -48 + yOffset); - this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); + this.confirmUiMode = args.length >= 6 ? (args[5] as ConfirmUiMode) : ConfirmUiMode.DEFAULT_YES; + + switch (this.confirmUiMode) { + case ConfirmUiMode.DEFAULT_YES: + this.setCursor(this.switchCheck ? this.switchCheckCursor : 0); + break; + case ConfirmUiMode.DEFAULT_NO: + this.setCursor(this.switchCheck ? this.switchCheckCursor : 1); + break; + } return true; } diff --git a/test/phases/learn-move-phase.test.ts b/test/phases/learn-move-phase.test.ts index 88b8187069b..05dbf71d1f4 100644 --- a/test/phases/learn-move-phase.test.ts +++ b/test/phases/learn-move-phase.test.ts @@ -92,6 +92,10 @@ describe("Learn Move Phase", () => { game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { game.scene.ui.processInput(Button.ACTION); }); + game.onNextPrompt("LearnMovePhase", UiMode.CONFIRM, () => { + game.scene.ui.setCursor(0); + game.scene.ui.processInput(Button.ACTION); + }); await game.phaseInterceptor.to(LearnMovePhase); const levelReq = bulbasaur.getLevelMoves(5)[0][0]; From 1029afcdbf538b84942ef17b4c4c83ac29543702 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Wed, 11 Jun 2025 21:42:04 -0500 Subject: [PATCH 04/10] [Refactor] Remove circular dependencies (part 4) (#5964) * Add abilityAttr.is methods * [WIP] move modifier stuff around * Untangle circular deps from modifiers * Move unlockables to own file * Untangle all circular deps outside of MEs * Move constants in MEs to their own files * Re-add missing import to battle.ts * Add necessary overload for getTag * Add missing type import in weather.ts * Init modifier types and pools in loading-scene * Remove stray commented code * Apply kev's suggestions from code review Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --- src/@types/ability-types.ts | 22 +- src/@types/modifier-types.ts | 32 + src/battle-scene.ts | 35 +- src/battle.ts | 6 +- src/constants.ts | 40 + src/data/abilities/ab-attrs/ab-attr.ts | 58 - src/data/abilities/ability-class.ts | 137 -- src/data/abilities/ability.ts | 1167 +++++++---------- src/data/abilities/apply-ab-attrs.ts | 829 ++++++++++++ src/data/arena-tag.ts | 26 +- src/data/balance/pokemon-evolutions.ts | 11 +- src/data/balance/tms.ts | 2 +- src/data/battle-anims.ts | 3 +- src/data/battler-tags.ts | 33 +- src/data/berry.ts | 16 +- src/data/challenge.ts | 2 +- src/data/data-lists.ts | 6 +- src/data/dialogue.ts | 43 - src/data/double-battle-dialogue.ts | 44 + src/data/moves/move.ts | 106 +- .../encounters/a-trainers-test-encounter.ts | 4 +- .../encounters/absolute-avarice-encounter.ts | 2 +- .../an-offer-you-cant-refuse-encounter.ts | 2 +- .../encounters/berries-abound-encounter.ts | 4 +- .../encounters/bug-type-superfan-encounter.ts | 4 +- .../encounters/clowning-around-encounter.ts | 9 +- .../encounters/dancing-lessons-encounter.ts | 2 +- .../encounters/dark-deal-encounter.ts | 2 +- .../encounters/delibirdy-encounter.ts | 2 +- .../department-store-sale-encounter.ts | 4 +- .../encounters/field-trip-encounter.ts | 2 +- .../encounters/fiery-fallout-encounter.ts | 6 +- .../encounters/fight-or-flight-encounter.ts | 4 +- .../encounters/fun-and-games-encounter.ts | 2 +- .../global-trade-system-encounter.ts | 4 +- .../mysterious-challengers-encounter.ts | 4 +- .../encounters/mysterious-chest-encounter.ts | 2 +- .../shady-vitamin-dealer-encounter.ts | 2 +- .../slumbering-snorlax-encounter.ts | 2 +- .../teleporting-hijinks-encounter.ts | 3 +- .../the-expert-pokemon-breeder-encounter.ts | 2 +- .../encounters/the-strong-stuff-encounter.ts | 2 +- .../the-winstrate-challenge-encounter.ts | 8 +- .../encounters/training-session-encounter.ts | 2 +- .../encounters/trash-to-treasure-encounter.ts | 4 +- .../encounters/weird-dream-encounter.ts | 4 +- .../mystery-encounter-save-data.ts | 2 +- .../mystery-encounters/mystery-encounters.ts | 36 - .../utils/encounter-phase-utils.ts | 9 +- .../utils/encounter-pokemon-utils.ts | 2 +- src/data/pokeball.ts | 3 +- src/data/trainers/trainer-config.ts | 6 +- src/data/weather.ts | 6 +- src/enums/modifier-pool-type.ts | 7 + src/{modifier => enums}/modifier-tier.ts | 0 src/enums/unlockables.ts | 7 + src/field/arena.ts | 11 +- src/field/pokemon.ts | 179 ++- src/loading-scene.ts | 5 + src/modifier/init-modifier-pools.ts | 854 ++++++++++++ src/modifier/modifier-pools.ts | 16 + src/modifier/modifier-type.ts | 946 ++----------- src/modifier/modifier.ts | 177 ++- src/overrides.ts | 2 +- src/phases/add-enemy-buff-modifier-phase.ts | 4 +- src/phases/attempt-run-phase.ts | 11 +- src/phases/battle-end-phase.ts | 4 +- src/phases/berry-phase.ts | 13 +- src/phases/encounter-phase.ts | 16 +- src/phases/faint-phase.ts | 13 +- src/phases/game-over-phase.ts | 4 +- src/phases/modifier-reward-phase.ts | 5 +- src/phases/move-effect-phase.ts | 33 +- src/phases/move-end-phase.ts | 4 +- src/phases/move-phase.ts | 34 +- src/phases/new-biome-encounter-phase.ts | 4 +- src/phases/obtain-status-effect-phase.ts | 4 +- src/phases/post-summon-phase.ts | 6 +- src/phases/post-turn-status-effect-phase.ts | 17 +- src/phases/quiet-form-change-phase.ts | 13 +- src/phases/ribbon-modifier-reward-phase.ts | 2 +- src/phases/select-modifier-phase.ts | 4 +- src/phases/stat-stage-change-phase.ts | 28 +- src/phases/summon-phase.ts | 4 +- src/phases/switch-summon-phase.ts | 14 +- src/phases/title-phase.ts | 11 +- src/phases/trainer-victory-phase.ts | 2 +- src/phases/turn-end-phase.ts | 4 +- src/phases/turn-start-phase.ts | 6 +- src/phases/unlock-phase.ts | 2 +- src/phases/victory-phase.ts | 2 +- src/phases/weather-effect-phase.ts | 14 +- src/system/game-data.ts | 2 +- src/system/unlockables.ts | 8 +- src/ui/party-ui-handler.ts | 21 +- src/ui/starter-select-ui-handler.ts | 2 +- src/ui/summary-ui-handler.ts | 2 +- src/ui/text.ts | 2 +- src/utils/modifier-utils.ts | 35 + test/abilities/healer.test.ts | 4 +- test/abilities/neutralizing_gas.test.ts | 3 +- .../abilities/normal-move-type-change.test.ts | 5 +- test/abilities/quick_draw.test.ts | 9 +- test/abilities/sand_veil.test.ts | 3 +- test/abilities/shield_dust.test.ts | 11 +- test/abilities/unburden.test.ts | 3 +- test/battle/damage_calculation.test.ts | 2 +- test/items/light_ball.test.ts | 2 +- test/items/lock_capsule.test.ts | 2 +- test/items/metal_powder.test.ts | 2 +- test/items/quick_powder.test.ts | 2 +- test/items/thick_club.test.ts | 2 +- test/moves/safeguard.test.ts | 3 +- test/moves/secret_power.test.ts | 3 +- .../clowning-around-encounter.test.ts | 4 +- .../encounters/delibirdy-encounter.test.ts | 2 +- .../global-trade-system-encounter.test.ts | 4 +- .../mysterious-challengers-encounter.test.ts | 2 +- .../trash-to-treasure-encounter.test.ts | 5 +- .../uncommon-breed-encounter.test.ts | 2 +- .../encounters/weird-dream-encounter.test.ts | 2 +- test/phases/form-change-phase.test.ts | 2 +- test/phases/game-over-phase.test.ts | 2 +- test/phases/select-modifier-phase.test.ts | 5 +- test/testUtils/gameManager.ts | 3 +- test/testUtils/helpers/field-helper.ts | 2 +- test/testUtils/helpers/overridesHelper.ts | 2 +- test/testUtils/testFileInitialization.ts | 4 + 128 files changed, 2994 insertions(+), 2427 deletions(-) create mode 100644 src/@types/modifier-types.ts delete mode 100644 src/data/abilities/ab-attrs/ab-attr.ts delete mode 100644 src/data/abilities/ability-class.ts create mode 100644 src/data/abilities/apply-ab-attrs.ts create mode 100644 src/data/double-battle-dialogue.ts create mode 100644 src/enums/modifier-pool-type.ts rename src/{modifier => enums}/modifier-tier.ts (100%) create mode 100644 src/enums/unlockables.ts create mode 100644 src/modifier/init-modifier-pools.ts create mode 100644 src/modifier/modifier-pools.ts create mode 100644 src/utils/modifier-utils.ts diff --git a/src/@types/ability-types.ts b/src/@types/ability-types.ts index 5d21aaaa844..6f21a012b64 100644 --- a/src/@types/ability-types.ts +++ b/src/@types/ability-types.ts @@ -1,11 +1,27 @@ -import type { AbAttr } from "#app/data/abilities/ab-attrs/ab-attr"; +import type { AbAttr } from "#app/data/abilities/ability"; import type Move from "#app/data/moves/move"; import type Pokemon from "#app/field/pokemon"; import type { BattleStat } from "#enums/stat"; +import type { AbAttrConstructorMap } from "#app/data/abilities/ability"; -export type AbAttrApplyFunc = (attr: TAttr, passive: boolean) => void; -export type AbAttrSuccessFunc = (attr: TAttr, passive: boolean) => boolean; +// Intentionally re-export all types from the ability attributes module +export type * from "#app/data/abilities/ability"; + +export type AbAttrApplyFunc = (attr: TAttr, passive: boolean, ...args: any[]) => void; +export type AbAttrSuccessFunc = (attr: TAttr, passive: boolean, ...args: any[]) => boolean; export type AbAttrCondition = (pokemon: Pokemon) => boolean; export type PokemonAttackCondition = (user: Pokemon | null, target: Pokemon | null, move: Move) => boolean; export type PokemonDefendCondition = (target: Pokemon, user: Pokemon, move: Move) => boolean; export type PokemonStatStageChangeCondition = (target: Pokemon, statsChanged: BattleStat[], stages: number) => boolean; + +/** + * Union type of all ability attribute class names as strings + */ +export type AbAttrString = keyof AbAttrConstructorMap; + +/** + * Map of ability attribute class names to an instance of the class. + */ +export type AbAttrMap = { + [K in keyof AbAttrConstructorMap]: InstanceType; +}; diff --git a/src/@types/modifier-types.ts b/src/@types/modifier-types.ts new file mode 100644 index 00000000000..6c0136e655e --- /dev/null +++ b/src/@types/modifier-types.ts @@ -0,0 +1,32 @@ +/** + * Re-exports of all the types defined in the modifier module. + */ + +import type Pokemon from "#app/field/pokemon"; +import type { ModifierConstructorMap } from "#app/modifier/modifier"; +import type { ModifierType, WeightedModifierType } from "#app/modifier/modifier-type"; +export type ModifierTypeFunc = () => ModifierType; +export type WeightedModifierTypeWeightFunc = (party: Pokemon[], rerollCount?: number) => number; + +export type { ModifierConstructorMap } from "#app/modifier/modifier"; + +/** + * Map of modifier names to their respective instance types + */ +export type ModifierInstanceMap = { + [K in keyof ModifierConstructorMap]: InstanceType; +}; + +/** + * Union type of all modifier constructors. + */ +export type ModifierClass = ModifierConstructorMap[keyof ModifierConstructorMap]; + +/** + * Union type of all modifier names as strings. + */ +export type ModifierString = keyof ModifierConstructorMap; + +export type ModifierPool = { + [tier: string]: WeightedModifierType[]; +} \ No newline at end of file diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 5586691a48d..d5cb5dcae42 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -58,23 +58,15 @@ import { getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, - getModifierPoolForType, - getModifierType, getPartyLuckValue, - ModifierPoolType, - modifierTypes, PokemonHeldItemModifierType, } from "#app/modifier/modifier-type"; +import { getModifierType } from "./utils/modifier-utils"; +import { modifierTypes } from "./data/data-lists"; +import { getModifierPoolForType } from "./utils/modifier-utils"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import AbilityBar from "#app/ui/ability-bar"; -import { - applyAbAttrs, - applyPostBattleInitAbAttrs, - applyPostItemLostAbAttrs, - BlockItemTheftAbAttr, - DoubleBattleChanceAbAttr, - PostBattleInitAbAttr, - PostItemLostAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs, applyPostBattleInitAbAttrs, applyPostItemLostAbAttrs } from "./data/abilities/apply-ab-attrs"; import { allAbilities } from "./data/data-lists"; import type { FixedBattleConfig } from "#app/battle"; import Battle from "#app/battle"; @@ -145,14 +137,13 @@ import { LoadingScene } from "#app/loading-scene"; import type { MovePhase } from "#app/phases/move-phase"; import { ShopCursorTarget } from "#app/enums/shop-cursor-target"; import MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; +import { allMysteryEncounters, mysteryEncountersByBiome } from "#app/data/mystery-encounters/mystery-encounters"; import { - allMysteryEncounters, ANTI_VARIANCE_WEIGHT_MODIFIER, AVERAGE_ENCOUNTERS_PER_RUN_TARGET, BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT, MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT, - mysteryEncountersByBiome, -} from "#app/data/mystery-encounters/mystery-encounters"; +} from "./constants"; import { MysteryEncounterSaveData } from "#app/data/mystery-encounters/mystery-encounter-save-data"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; @@ -1264,7 +1255,7 @@ export default class BattleScene extends SceneBase { const doubleChance = new NumberHolder(newWaveIndex % 10 === 0 ? 32 : 8); this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance); for (const p of playerField) { - applyAbAttrs(DoubleBattleChanceAbAttr, p, null, false, doubleChance); + applyAbAttrs("DoubleBattleChanceAbAttr", p, null, false, doubleChance); } return Math.max(doubleChance.value, 1); } @@ -1469,7 +1460,7 @@ export default class BattleScene extends SceneBase { for (const pokemon of this.getPlayerParty()) { pokemon.resetBattleAndWaveData(); pokemon.resetTera(); - applyPostBattleInitAbAttrs(PostBattleInitAbAttr, pokemon); + applyPostBattleInitAbAttrs("PostBattleInitAbAttr", pokemon); if ( pokemon.hasSpecies(SpeciesId.TERAPAGOS) || (this.gameMode.isClassic && this.currentBattle.waveIndex > 180 && this.currentBattle.waveIndex <= 190) @@ -2745,7 +2736,7 @@ export default class BattleScene extends SceneBase { const cancelled = new BooleanHolder(false); if (source && source.isPlayer() !== target.isPlayer()) { - applyAbAttrs(BlockItemTheftAbAttr, source, cancelled); + applyAbAttrs("BlockItemTheftAbAttr", source, cancelled); } if (cancelled.value) { @@ -2785,13 +2776,13 @@ export default class BattleScene extends SceneBase { if (target.isPlayer()) { this.addModifier(newItemModifier, ignoreUpdate, playSound, false, instant); if (source && itemLost) { - applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false); + applyPostItemLostAbAttrs("PostItemLostAbAttr", source, false); } return true; } this.addEnemyModifier(newItemModifier, ignoreUpdate, instant); if (source && itemLost) { - applyPostItemLostAbAttrs(PostItemLostAbAttr, source, false); + applyPostItemLostAbAttrs("PostItemLostAbAttr", source, false); } return true; } @@ -2814,7 +2805,7 @@ export default class BattleScene extends SceneBase { const cancelled = new BooleanHolder(false); if (source && source.isPlayer() !== target.isPlayer()) { - applyAbAttrs(BlockItemTheftAbAttr, source, cancelled); + applyAbAttrs("BlockItemTheftAbAttr", source, cancelled); } if (cancelled.value) { diff --git a/src/battle.ts b/src/battle.ts index 0cf01a0873d..245705f4801 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -13,7 +13,7 @@ import { import Trainer from "./field/trainer"; import { TrainerVariant } from "#enums/trainer-variant"; import type { GameMode } from "./game-mode"; -import { MoneyMultiplierModifier, PokemonHeldItemModifier } from "./modifier/modifier"; +import { MoneyMultiplierModifier, type PokemonHeldItemModifier } from "./modifier/modifier"; import type { PokeballType } from "#enums/pokeball"; import { trainerConfigs } from "#app/data/trainers/trainer-config"; import { SpeciesFormKey } from "#enums/species-form-key"; @@ -30,7 +30,7 @@ import i18next from "#app/plugins/i18n"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; import type { CustomModifierSettings } from "#app/modifier/modifier-type"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { BattleType } from "#enums/battle-type"; import { ClassicFixedBossWaves } from "#enums/fixed-boss-waves"; @@ -173,7 +173,7 @@ export default class Battle { this.postBattleLoot.push( ...globalScene .findModifiers( - m => m instanceof PokemonHeldItemModifier && m.pokemonId === enemyPokemon.id && m.isTransferable, + m => m.is("PokemonHeldItemModifier") && m.pokemonId === enemyPokemon.id && m.isTransferable, false, ) .map(i => { diff --git a/src/constants.ts b/src/constants.ts index 62056ecc0d4..f3b37563d11 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -54,3 +54,43 @@ export const defaultStarterSpecies: SpeciesId[] = [ ]; export const saveKey = "x0i2O7WRiANTqPmZ"; // Temporary; secure encryption is not yet necessary + +/** + * Spawn chance: (BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT + WIGHT_INCREMENT_ON_SPAWN_MISS * ) / MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT + */ +export const BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT = 3; + +/** + * The divisor for determining ME spawns, defines the "maximum" weight required for a spawn + * If spawn_weight === MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT, 100% chance to spawn a ME + */ +export const MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT = 256; + +/** + * When an ME spawn roll fails, WEIGHT_INCREMENT_ON_SPAWN_MISS is added to future rolls for ME spawn checks. + * These values are cleared whenever the next ME spawns, and spawn weight returns to BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT + */ +export const WEIGHT_INCREMENT_ON_SPAWN_MISS = 3; + +/** + * Specifies the target average for total ME spawns in a single Classic run. + * Used by anti-variance mechanic to check whether a run is above or below the target on a given wave. + */ +export const AVERAGE_ENCOUNTERS_PER_RUN_TARGET = 12; + +/** + * Will increase/decrease the chance of spawning a ME based on the current run's total MEs encountered vs AVERAGE_ENCOUNTERS_PER_RUN_TARGET + * Example: + * AVERAGE_ENCOUNTERS_PER_RUN_TARGET = 17 (expects avg 1 ME every 10 floors) + * ANTI_VARIANCE_WEIGHT_MODIFIER = 15 + * + * On wave 20, if 1 ME has been encountered, the difference from expected average is 0 MEs. + * So anti-variance adds 0/256 to the spawn weight check for ME spawn. + * + * On wave 20, if 0 MEs have been encountered, the difference from expected average is 1 ME. + * So anti-variance adds 15/256 to the spawn weight check for ME spawn. + * + * On wave 20, if 2 MEs have been encountered, the difference from expected average is -1 ME. + * So anti-variance adds -15/256 to the spawn weight check for ME spawn. + */ +export const ANTI_VARIANCE_WEIGHT_MODIFIER = 15; diff --git a/src/data/abilities/ab-attrs/ab-attr.ts b/src/data/abilities/ab-attrs/ab-attr.ts deleted file mode 100644 index 24fbb6dc338..00000000000 --- a/src/data/abilities/ab-attrs/ab-attr.ts +++ /dev/null @@ -1,58 +0,0 @@ -import type { AbAttrCondition } from "#app/@types/ability-types"; -import type Pokemon from "#app/field/pokemon"; -import type { BooleanHolder } from "#app/utils/common"; - -export abstract class AbAttr { - public showAbility: boolean; - private extraCondition: AbAttrCondition; - - /** - * @param showAbility - Whether to show this ability as a flyout during battle; default `true`. - * Should be kept in parity with mainline where possible. - */ - constructor(showAbility = true) { - this.showAbility = showAbility; - } - - /** - * Applies ability effects without checking conditions - * @param _pokemon - The pokemon to apply this ability to - * @param _passive - Whether or not the ability is a passive - * @param _simulated - Whether the call is simulated - * @param _args - Extra args passed to the function. Handled by child classes. - * @see {@linkcode canApply} - */ - apply( - _pokemon: Pokemon, - _passive: boolean, - _simulated: boolean, - _cancelled: BooleanHolder | null, - _args: any[], - ): void {} - - getTriggerMessage(_pokemon: Pokemon, _abilityName: string, ..._args: any[]): string | null { - return null; - } - - getCondition(): AbAttrCondition | null { - return this.extraCondition || null; - } - - addCondition(condition: AbAttrCondition): AbAttr { - this.extraCondition = condition; - return this; - } - - /** - * Returns a boolean describing whether the ability can be applied under current conditions - * @param _pokemon - The pokemon to apply this ability to - * @param _passive - Whether or not the ability is a passive - * @param _simulated - Whether the call is simulated - * @param _args - Extra args passed to the function. Handled by child classes. - * @returns `true` if the ability can be applied, `false` otherwise - * @see {@linkcode apply} - */ - canApply(_pokemon: Pokemon, _passive: boolean, _simulated: boolean, _args: any[]): boolean { - return true; - } -} diff --git a/src/data/abilities/ability-class.ts b/src/data/abilities/ability-class.ts deleted file mode 100644 index 10bd01f3987..00000000000 --- a/src/data/abilities/ability-class.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { AbilityId } from "#enums/ability-id"; -import type { AbAttrCondition } from "#app/@types/ability-types"; -import type { AbAttr } from "#app/data/abilities/ab-attrs/ab-attr"; -import i18next from "i18next"; -import type { Localizable } from "#app/@types/locales"; -import type { Constructor } from "#app/utils/common"; - -export class Ability implements Localizable { - public id: AbilityId; - - private nameAppend: string; - public name: string; - public description: string; - public generation: number; - public isBypassFaint: boolean; - public isIgnorable: boolean; - public isSuppressable = true; - public isCopiable = true; - public isReplaceable = true; - public attrs: AbAttr[]; - public conditions: AbAttrCondition[]; - - constructor(id: AbilityId, generation: number) { - this.id = id; - - this.nameAppend = ""; - this.generation = generation; - this.attrs = []; - this.conditions = []; - - this.isSuppressable = true; - this.isCopiable = true; - this.isReplaceable = true; - - this.localize(); - } - - public get isSwappable(): boolean { - return this.isCopiable && this.isReplaceable; - } - localize(): void { - const i18nKey = AbilityId[this.id] - .split("_") - .filter(f => f) - .map((f, i) => (i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase())) - .join("") as string; - - this.name = this.id ? `${i18next.t(`ability:${i18nKey}.name`) as string}${this.nameAppend}` : ""; - this.description = this.id ? (i18next.t(`ability:${i18nKey}.description`) as string) : ""; - } - - /** - * Get all ability attributes that match `attrType` - * @param attrType any attribute that extends {@linkcode AbAttr} - * @returns Array of attributes that match `attrType`, Empty Array if none match. - */ - getAttrs(attrType: Constructor): T[] { - return this.attrs.filter((a): a is T => a instanceof attrType); - } - - /** - * Check if an ability has an attribute that matches `attrType` - * @param attrType any attribute that extends {@linkcode AbAttr} - * @returns true if the ability has attribute `attrType` - */ - hasAttr(attrType: Constructor): boolean { - return this.attrs.some(attr => attr instanceof attrType); - } - - attr>(AttrType: T, ...args: ConstructorParameters): Ability { - const attr = new AttrType(...args); - this.attrs.push(attr); - - return this; - } - - conditionalAttr>( - condition: AbAttrCondition, - AttrType: T, - ...args: ConstructorParameters - ): Ability { - const attr = new AttrType(...args); - attr.addCondition(condition); - this.attrs.push(attr); - - return this; - } - - bypassFaint(): Ability { - this.isBypassFaint = true; - return this; - } - - ignorable(): Ability { - this.isIgnorable = true; - return this; - } - - unsuppressable(): Ability { - this.isSuppressable = false; - return this; - } - - uncopiable(): Ability { - this.isCopiable = false; - return this; - } - - unreplaceable(): Ability { - this.isReplaceable = false; - return this; - } - - condition(condition: AbAttrCondition): Ability { - this.conditions.push(condition); - - return this; - } - - partial(): this { - this.nameAppend += " (P)"; - return this; - } - - unimplemented(): this { - this.nameAppend += " (N)"; - return this; - } - - /** - * Internal flag used for developers to document edge cases. When using this, please be sure to document the edge case. - * @returns the ability - */ - edgeCase(): this { - return this; - } -} diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index 128e772217f..2efe3607b4f 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -37,8 +37,6 @@ import { BattleType } from "#enums/battle-type"; import type { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { globalScene } from "#app/global-scene"; import { allAbilities } from "#app/data/data-lists"; -import { AbAttr } from "#app/data/abilities/ab-attrs/ab-attr"; -import { Ability } from "#app/data/abilities/ability-class"; // Enum imports import { Stat, type BattleStat, BATTLE_STATS, EFFECTIVE_STATS, getStatKey, type EffectiveStat } from "#enums/stat"; @@ -71,13 +69,223 @@ import type { PokemonDefendCondition, PokemonStatStageChangeCondition, PokemonAttackCondition, - AbAttrApplyFunc, - AbAttrSuccessFunc, + AbAttrString, + AbAttrMap, } from "#app/@types/ability-types"; import type { BattlerIndex } from "#enums/battler-index"; import type Move from "#app/data/moves/move"; import type { ArenaTrapTag, SuppressAbilitiesTag } from "#app/data/arena-tag"; import { noAbilityTypeOverrideMoves } from "../moves/invalid-moves"; +import type { Localizable } from "#app/@types/locales"; +import { applyAbAttrs } from "./apply-ab-attrs"; + +export class Ability implements Localizable { + public id: AbilityId; + + private nameAppend: string; + public name: string; + public description: string; + public generation: number; + public isBypassFaint: boolean; + public isIgnorable: boolean; + public isSuppressable = true; + public isCopiable = true; + public isReplaceable = true; + public attrs: AbAttr[]; + public conditions: AbAttrCondition[]; + + constructor(id: AbilityId, generation: number) { + this.id = id; + + this.nameAppend = ""; + this.generation = generation; + this.attrs = []; + this.conditions = []; + + this.localize(); + } + + public get isSwappable(): boolean { + return this.isCopiable && this.isReplaceable; + } + + localize(): void { + const i18nKey = AbilityId[this.id] + .split("_") + .filter(f => f) + .map((f, i) => (i ? `${f[0]}${f.slice(1).toLowerCase()}` : f.toLowerCase())) + .join("") as string; + + this.name = this.id ? `${i18next.t(`ability:${i18nKey}.name`) as string}${this.nameAppend}` : ""; + this.description = this.id ? (i18next.t(`ability:${i18nKey}.description`) as string) : ""; + } + + /** + * Get all ability attributes that match `attrType` + * @param attrType - any attribute that extends {@linkcode AbAttr} + * @returns Array of attributes that match `attrType`, Empty Array if none match. + */ + getAttrs(attrType: T): AbAttrMap[T][] { + const targetAttr = AbilityAttrs[attrType]; + if (!targetAttr) { + return []; + } + return this.attrs.filter((a): a is AbAttrMap[T] => a instanceof targetAttr); + } + + /** + * Check if an ability has an attribute that matches `attrType` + * @param attrType - any attribute that extends {@linkcode AbAttr} + * @returns true if the ability has attribute `attrType` + */ + hasAttr(attrType: T): boolean { + const targetAttr = AbilityAttrs[attrType]; + if (!targetAttr) { + return false; + } + return this.attrs.some(attr => attr instanceof targetAttr); + } + + attr>(AttrType: T, ...args: ConstructorParameters): Ability { + const attr = new AttrType(...args); + this.attrs.push(attr); + + return this; + } + + conditionalAttr>( + condition: AbAttrCondition, + AttrType: T, + ...args: ConstructorParameters + ): Ability { + const attr = new AttrType(...args); + attr.addCondition(condition); + this.attrs.push(attr); + + return this; + } + + bypassFaint(): Ability { + this.isBypassFaint = true; + return this; + } + + ignorable(): Ability { + this.isIgnorable = true; + return this; + } + + unsuppressable(): Ability { + this.isSuppressable = false; + return this; + } + + uncopiable(): Ability { + this.isCopiable = false; + return this; + } + + unreplaceable(): Ability { + this.isReplaceable = false; + return this; + } + + condition(condition: AbAttrCondition): Ability { + this.conditions.push(condition); + + return this; + } + + partial(): this { + this.nameAppend += " (P)"; + return this; + } + + unimplemented(): this { + this.nameAppend += " (N)"; + return this; + } + + /** + * Internal flag used for developers to document edge cases. When using this, please be sure to document the edge case. + * @returns the ability + */ + edgeCase(): this { + return this; + } +} + +export abstract class AbAttr { + public showAbility: boolean; + private extraCondition: AbAttrCondition; + + /** + * Return whether this attribute is of the given type. + * + * @remarks + * Used to avoid requiring the caller to have imported the specific attribute type, avoiding circular dependencies. + * + * @param attr - The attribute to check against + * @returns Whether the attribute is an instance of the given type + */ + public is(attr: K): this is AbAttrMap[K] { + const targetAttr = AbilityAttrs[attr]; + if (!targetAttr) { + return false; + } + return this instanceof targetAttr; + } + + /** + * @param showAbility - Whether to show this ability as a flyout during battle; default `true`. + * Should be kept in parity with mainline where possible. + */ + constructor(showAbility = true) { + this.showAbility = showAbility; + } + + /** + * Applies ability effects without checking conditions + * @param _pokemon - The pokemon to apply this ability to + * @param _passive - Whether or not the ability is a passive + * @param _simulated - Whether the call is simulated + * @param _args - Extra args passed to the function. Handled by child classes. + * @see {@linkcode canApply} + */ + apply( + _pokemon: Pokemon, + _passive: boolean, + _simulated: boolean, + _cancelled: BooleanHolder | null, + _args: any[], + ): void {} + + getTriggerMessage(_pokemon: Pokemon, _abilityName: string, ..._args: any[]): string | null { + return null; + } + + getCondition(): AbAttrCondition | null { + return this.extraCondition || null; + } + + addCondition(condition: AbAttrCondition): AbAttr { + this.extraCondition = condition; + return this; + } + + /** + * Returns a boolean describing whether the ability can be applied under current conditions + * @param _pokemon - The pokemon to apply this ability to + * @param _passive - Whether or not the ability is a passive + * @param _simulated - Whether the call is simulated + * @param _args - Extra args passed to the function. Handled by child classes. + * @returns `true` if the ability can be applied, `false` otherwise + * @see {@linkcode apply} + */ + canApply(_pokemon: Pokemon, _passive: boolean, _simulated: boolean, _args: any[]): boolean { + return true; + } +} export class BlockRecoilDamageAttr extends AbAttr { constructor() { @@ -131,11 +339,11 @@ export class DoubleBattleChanceAbAttr extends AbAttr { } export class PostBattleInitAbAttr extends AbAttr { - canApplyPostBattleInit(_pokemon: Pokemon, _passive: boolean, _simulated: boolean, _args: any[]): boolean { + canApplyPostBattleInit(_pokemon: Pokemon, _passive: boolean, _simulated: boolean, _args?: any[]): boolean { return true; } - applyPostBattleInit(_pokemon: Pokemon, _passive: boolean, _simulated: boolean, _args: any[]): void {} + applyPostBattleInit(_pokemon: Pokemon, _passive: boolean, _simulated: boolean, _args?: any[]): void {} } export class PostBattleInitFormChangeAbAttr extends PostBattleInitAbAttr { @@ -147,7 +355,7 @@ export class PostBattleInitFormChangeAbAttr extends PostBattleInitAbAttr { this.formFunc = formFunc; } - override canApplyPostBattleInit(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: any[]): boolean { + override canApplyPostBattleInit(pokemon: Pokemon, _passive: boolean, simulated: boolean, _args: never[]): boolean { const formIndex = this.formFunc(pokemon); return formIndex !== pokemon.formIndex && !simulated; } @@ -1478,7 +1686,7 @@ export class PostDefendContactDamageAbAttr extends PostDefendAbAttr { return ( !simulated && move.doesFlagEffectApply({ flag: MoveFlags.MAKES_CONTACT, user: attacker, target: pokemon }) && - !attacker.hasAbilityWithAttr(BlockNonDirectDamageAbAttr) + !attacker.hasAbilityWithAttr("BlockNonDirectDamageAbAttr") ); } @@ -1657,7 +1865,7 @@ export class PostDefendAbilityGiveAbAttr extends PostDefendAbAttr { return ( move.doesFlagEffectApply({ flag: MoveFlags.MAKES_CONTACT, user: attacker, target: pokemon }) && attacker.getAbility().isSuppressable && - !attacker.getAbility().hasAttr(PostDefendAbilityGiveAbAttr) + !attacker.getAbility().hasAttr("PostDefendAbilityGiveAbAttr") ); } @@ -1924,9 +2132,7 @@ export class FieldMultiplyStatAbAttr extends AbAttr { this.canStack || (!hasApplied.value && this.stat === stat && - checkedPokemon - .getAbilityAttrs(FieldMultiplyStatAbAttr) - .every(attr => (attr as FieldMultiplyStatAbAttr).stat !== stat)) + checkedPokemon.getAbilityAttrs("FieldMultiplyStatAbAttr").every(attr => attr.stat !== stat)) ); } @@ -2650,7 +2856,7 @@ export class PostAttackApplyStatusEffectAbAttr extends PostAttackAbAttr { if ( super.canApplyPostAttack(pokemon, passive, simulated, attacker, move, hitResult, args) && (simulated || - (!attacker.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && + (!attacker.hasAbilityWithAttr("IgnoreMoveEffectsAbAttr") && pokemon !== attacker && (!this.contactRequired || move.doesFlagEffectApply({ flag: MoveFlags.MAKES_CONTACT, user: attacker, target: pokemon })) && @@ -2715,7 +2921,7 @@ export class PostAttackApplyBattlerTagAbAttr extends PostAttackAbAttr { /**Battler tags inflicted by abilities post attacking are also considered additional effects.*/ return ( super.canApplyPostAttack(pokemon, passive, simulated, attacker, move, hitResult, args) && - !attacker.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && + !attacker.hasAbilityWithAttr("IgnoreMoveEffectsAbAttr") && pokemon !== attacker && (!this.contactRequired || move.doesFlagEffectApply({ flag: MoveFlags.MAKES_CONTACT, user: attacker, target: pokemon })) && @@ -3308,8 +3514,8 @@ export class PostSummonStatStageChangeAbAttr extends PostSummonAbAttr { for (const opponent of pokemon.getOpponents()) { const cancelled = new BooleanHolder(false); if (this.intimidate) { - applyAbAttrs(IntimidateImmunityAbAttr, opponent, cancelled, simulated); - applyAbAttrs(PostIntimidateStatStageChangeAbAttr, opponent, cancelled, simulated); + applyAbAttrs("IntimidateImmunityAbAttr", opponent, cancelled, simulated); + applyAbAttrs("PostIntimidateStatStageChangeAbAttr", opponent, cancelled, simulated); if (opponent.getTag(BattlerTagType.SUBSTITUTE)) { cancelled.value = true; @@ -5243,7 +5449,7 @@ export class PostWeatherLapseDamageAbAttr extends PostWeatherLapseAbAttr { _weather: Weather | null, _args: any[], ): boolean { - return !pokemon.hasAbilityWithAttr(BlockNonDirectDamageAbAttr); + return !pokemon.hasAbilityWithAttr("BlockNonDirectDamageAbAttr"); } override applyPostWeatherLapse( @@ -5544,7 +5750,7 @@ export class RepeatBerryNextTurnAbAttr extends PostTurnAbAttr { } // uncomment to make cheek pouch work with cud chew - // applyAbAttrs(HealFromBerryUseAbAttr, pokemon, new BooleanHolder(false)); + // applyAbAttrs("HealFromBerryUseAbAttr", pokemon, new BooleanHolder(false)); } /** @@ -5671,7 +5877,7 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr { .some( opp => (opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(AbilityId.COMATOSE)) && - !opp.hasAbilityWithAttr(BlockNonDirectDamageAbAttr) && + !opp.hasAbilityWithAttr("BlockNonDirectDamageAbAttr") && !opp.switchOutStatus, ); } @@ -5686,7 +5892,7 @@ export class PostTurnHurtIfSleepingAbAttr extends PostTurnAbAttr { for (const opp of pokemon.getOpponents()) { if ( (opp.status?.effect === StatusEffect.SLEEP || opp.hasAbility(AbilityId.COMATOSE)) && - !opp.hasAbilityWithAttr(BlockNonDirectDamageAbAttr) && + !opp.hasAbilityWithAttr("BlockNonDirectDamageAbAttr") && !opp.switchOutStatus ) { if (!simulated) { @@ -6326,8 +6532,8 @@ export class PostFaintContactDamageAbAttr extends PostFaintAbAttr { attacker !== undefined && move.doesFlagEffectApply({ flag: MoveFlags.MAKES_CONTACT, user: attacker, target: pokemon }); const cancelled = new BooleanHolder(false); - globalScene.getField(true).map(p => applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled, simulated)); - return !(!diedToDirectDamage || cancelled.value || attacker!.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)); + globalScene.getField(true).map(p => applyAbAttrs("FieldPreventExplosiveMovesAbAttr", p, cancelled, simulated)); + return !(!diedToDirectDamage || cancelled.value || attacker!.hasAbilityWithAttr("BlockNonDirectDamageAbAttr")); } override applyPostFaint( @@ -7160,64 +7366,6 @@ export class TerrainEventTypeChangeAbAttr extends PostSummonAbAttr { } } -function applySingleAbAttrs( - pokemon: Pokemon, - passive: boolean, - attrType: Constructor, - applyFunc: AbAttrApplyFunc, - successFunc: AbAttrSuccessFunc, - args: any[], - gainedMidTurn = false, - simulated = false, - messages: string[] = [], -) { - if (!pokemon?.canApplyAbility(passive) || (passive && pokemon.getPassiveAbility().id === pokemon.getAbility().id)) { - return; - } - - const ability = passive ? pokemon.getPassiveAbility() : pokemon.getAbility(); - if ( - gainedMidTurn && - ability.getAttrs(attrType).some(attr => attr instanceof PostSummonAbAttr && !attr.shouldActivateOnGain()) - ) { - return; - } - - for (const attr of ability.getAttrs(attrType)) { - const condition = attr.getCondition(); - let abShown = false; - if ((condition && !condition(pokemon)) || !successFunc(attr, passive)) { - continue; - } - - globalScene.phaseManager.setPhaseQueueSplice(); - - if (attr.showAbility && !simulated) { - globalScene.phaseManager.queueAbilityDisplay(pokemon, passive, true); - abShown = true; - } - const message = attr.getTriggerMessage(pokemon, ability.name, args); - if (message) { - if (!simulated) { - globalScene.phaseManager.queueMessage(message); - } - messages.push(message); - } - - applyFunc(attr, passive); - - if (abShown) { - globalScene.phaseManager.queueAbilityDisplay(pokemon, passive, false); - } - - if (!simulated) { - pokemon.waveData.abilitiesApplied.add(ability.id); - } - - globalScene.phaseManager.clearPhaseQueueSplice(); - } -} - class ForceSwitchOutHelper { constructor(private switchType: SwitchType) {} @@ -7329,7 +7477,7 @@ class ForceSwitchOutHelper { if (player) { const blockedByAbility = new BooleanHolder(false); - applyAbAttrs(ForceSwitchOutImmunityAbAttr, opponent, blockedByAbility); + applyAbAttrs("ForceSwitchOutImmunityAbAttr", opponent, blockedByAbility); return !blockedByAbility.value; } @@ -7367,7 +7515,7 @@ class ForceSwitchOutHelper { */ public getFailedText(target: Pokemon): string | null { const blockedByAbility = new BooleanHolder(false); - applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, blockedByAbility); + applyAbAttrs("ForceSwitchOutImmunityAbAttr", target, blockedByAbility); return blockedByAbility.value ? i18next.t("moveTriggers:cannotBeSwitchedOut", { pokemonName: getPokemonNameWithAffix(target) }) : null; @@ -7522,646 +7670,233 @@ export class PostDamageForceSwitchAbAttr extends PostDamageAbAttr { this.helper.switchOutLogic(pokemon); } } -function applyAbAttrsInternal( - attrType: Constructor, - pokemon: Pokemon | null, - applyFunc: AbAttrApplyFunc, - successFunc: AbAttrSuccessFunc, - args: any[], - simulated = false, - messages: string[] = [], - gainedMidTurn = false, -) { - for (const passive of [false, true]) { - if (pokemon) { - applySingleAbAttrs(pokemon, passive, attrType, applyFunc, successFunc, args, gainedMidTurn, simulated, messages); - globalScene.phaseManager.clearPhaseQueueSplice(); - } - } -} - -export function applyAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - cancelled: BooleanHolder | null, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.apply(pokemon, passive, simulated, cancelled, args), - (attr, passive) => attr.canApply(pokemon, passive, simulated, args), - args, - simulated, - ); -} - -export function applyPostBattleInitAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostBattleInit(pokemon, passive, simulated, args), - (attr, passive) => attr.canApplyPostBattleInit(pokemon, passive, simulated, args), - args, - simulated, - ); -} - -export function applyPreDefendAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - attacker: Pokemon, - move: Move | null, - cancelled: BooleanHolder | null, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args), - (attr, passive) => attr.canApplyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args), - args, - simulated, - ); -} - -export function applyPostDefendAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - attacker: Pokemon, - move: Move, - hitResult: HitResult | null, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostDefend(pokemon, passive, simulated, attacker, move, hitResult, args), - (attr, passive) => attr.canApplyPostDefend(pokemon, passive, simulated, attacker, move, hitResult, args), - args, - simulated, - ); -} - -export function applyPostMoveUsedAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - move: PokemonMove, - source: Pokemon, - targets: BattlerIndex[], - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, _passive) => attr.applyPostMoveUsed(pokemon, move, source, targets, simulated, args), - (attr, _passive) => attr.canApplyPostMoveUsed(pokemon, move, source, targets, simulated, args), - args, - simulated, - ); -} - -export function applyStatMultiplierAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - stat: BattleStat, - statValue: NumberHolder, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyStatStage(pokemon, passive, simulated, stat, statValue, args), - (attr, passive) => attr.canApplyStatStage(pokemon, passive, simulated, stat, statValue, args), - args, - ); -} /** - * Applies an ally's Stat multiplier attribute - * @param attrType - {@linkcode AllyStatMultiplierAbAttr} should always be AllyStatMultiplierAbAttr for the time being - * @param pokemon - The {@linkcode Pokemon} with the ability - * @param stat - The type of the checked {@linkcode Stat} - * @param statValue - {@linkcode NumberHolder} containing the value of the checked stat - * @param checkedPokemon - The {@linkcode Pokemon} with the checked stat - * @param ignoreAbility - Whether or not the ability should be ignored by the pokemon or its move. - * @param args - unused + * Map of all ability attribute constructors, for use with the `.is` method. */ -export function applyAllyStatMultiplierAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - stat: BattleStat, - statValue: NumberHolder, - simulated = false, - checkedPokemon: Pokemon, - ignoreAbility: boolean, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => - attr.applyAllyStat(pokemon, passive, simulated, stat, statValue, checkedPokemon, ignoreAbility, args), - (attr, passive) => - attr.canApplyAllyStat(pokemon, passive, simulated, stat, statValue, checkedPokemon, ignoreAbility, args), - args, - simulated, - ); -} - -export function applyPostSetStatusAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - effect: StatusEffect, - sourcePokemon?: Pokemon | null, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostSetStatus(pokemon, sourcePokemon, passive, effect, simulated, args), - (attr, passive) => attr.canApplyPostSetStatus(pokemon, sourcePokemon, passive, effect, simulated, args), - args, - simulated, - ); -} - -export function applyPostDamageAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - damage: number, - _passive: boolean, - simulated = false, - args: any[], - source?: Pokemon, -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostDamage(pokemon, damage, passive, simulated, args, source), - (attr, passive) => attr.canApplyPostDamage(pokemon, damage, passive, simulated, args, source), - args, - ); -} +const AbilityAttrs = Object.freeze({ + BlockRecoilDamageAttr, + DoubleBattleChanceAbAttr, + PostBattleInitAbAttr, + PostBattleInitFormChangeAbAttr, + PostTeraFormChangeStatChangeAbAttr, + ClearWeatherAbAttr, + ClearTerrainAbAttr, + PreDefendAbAttr, + PreDefendFullHpEndureAbAttr, + BlockItemTheftAbAttr, + StabBoostAbAttr, + ReceivedMoveDamageMultiplierAbAttr, + AlliedFieldDamageReductionAbAttr, + ReceivedTypeDamageMultiplierAbAttr, + TypeImmunityAbAttr, + AttackTypeImmunityAbAttr, + TypeImmunityHealAbAttr, + NonSuperEffectiveImmunityAbAttr, + FullHpResistTypeAbAttr, + PostDefendAbAttr, + FieldPriorityMoveImmunityAbAttr, + PostStatStageChangeAbAttr, + MoveImmunityAbAttr, + WonderSkinAbAttr, + MoveImmunityStatStageChangeAbAttr, + ReverseDrainAbAttr, + PostDefendStatStageChangeAbAttr, + PostDefendHpGatedStatStageChangeAbAttr, + PostDefendApplyArenaTrapTagAbAttr, + PostDefendApplyBattlerTagAbAttr, + PostDefendTypeChangeAbAttr, + PostDefendTerrainChangeAbAttr, + PostDefendContactApplyStatusEffectAbAttr, + EffectSporeAbAttr, + PostDefendContactApplyTagChanceAbAttr, + PostDefendCritStatStageChangeAbAttr, + PostDefendContactDamageAbAttr, + PostDefendPerishSongAbAttr, + PostDefendWeatherChangeAbAttr, + PostDefendAbilitySwapAbAttr, + PostDefendAbilityGiveAbAttr, + PostDefendMoveDisableAbAttr, + PostStatStageChangeStatStageChangeAbAttr, + PreAttackAbAttr, + MoveEffectChanceMultiplierAbAttr, + IgnoreMoveEffectsAbAttr, + VariableMovePowerAbAttr, + FieldPreventExplosiveMovesAbAttr, + FieldMultiplyStatAbAttr, + MoveTypeChangeAbAttr, + PokemonTypeChangeAbAttr, + AddSecondStrikeAbAttr, + DamageBoostAbAttr, + MovePowerBoostAbAttr, + MoveTypePowerBoostAbAttr, + LowHpMoveTypePowerBoostAbAttr, + VariableMovePowerBoostAbAttr, + FieldMovePowerBoostAbAttr, + PreAttackFieldMoveTypePowerBoostAbAttr, + FieldMoveTypePowerBoostAbAttr, + UserFieldMoveTypePowerBoostAbAttr, + AllyMoveCategoryPowerBoostAbAttr, + StatMultiplierAbAttr, + PostAttackAbAttr, + AllyStatMultiplierAbAttr, + ExecutedMoveAbAttr, + GorillaTacticsAbAttr, + PostAttackStealHeldItemAbAttr, + PostAttackApplyStatusEffectAbAttr, + PostAttackContactApplyStatusEffectAbAttr, + PostAttackApplyBattlerTagAbAttr, + PostDefendStealHeldItemAbAttr, + PostSetStatusAbAttr, + SynchronizeStatusAbAttr, + PostVictoryAbAttr, + PostVictoryFormChangeAbAttr, + PostKnockOutAbAttr, + PostKnockOutStatStageChangeAbAttr, + CopyFaintedAllyAbilityAbAttr, + IgnoreOpponentStatStagesAbAttr, + IntimidateImmunityAbAttr, + PostIntimidateStatStageChangeAbAttr, + PostSummonAbAttr, + PostSummonRemoveEffectAbAttr, + PostSummonRemoveArenaTagAbAttr, + PostSummonAddArenaTagAbAttr, + PostSummonMessageAbAttr, + PostSummonUnnamedMessageAbAttr, + PostSummonAddBattlerTagAbAttr, + PostSummonRemoveBattlerTagAbAttr, + PostSummonStatStageChangeAbAttr, + PostSummonAllyHealAbAttr, + PostSummonClearAllyStatStagesAbAttr, + DownloadAbAttr, + PostSummonWeatherChangeAbAttr, + PostSummonTerrainChangeAbAttr, + PostSummonHealStatusAbAttr, + PostSummonFormChangeAbAttr, + PostSummonCopyAbilityAbAttr, + PostSummonUserFieldRemoveStatusEffectAbAttr, + PostSummonCopyAllyStatsAbAttr, + PostSummonTransformAbAttr, + PostSummonWeatherSuppressedFormChangeAbAttr, + PostSummonFormChangeByWeatherAbAttr, + CommanderAbAttr, + PreSwitchOutAbAttr, + PreSwitchOutResetStatusAbAttr, + PreSwitchOutClearWeatherAbAttr, + PreSwitchOutHealAbAttr, + PreSwitchOutFormChangeAbAttr, + PreLeaveFieldAbAttr, + PreLeaveFieldClearWeatherAbAttr, + PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, + PreStatStageChangeAbAttr, + ReflectStatStageChangeAbAttr, + ProtectStatAbAttr, + ConfusionOnStatusEffectAbAttr, + PreSetStatusAbAttr, + PreSetStatusEffectImmunityAbAttr, + StatusEffectImmunityAbAttr, + UserFieldStatusEffectImmunityAbAttr, + ConditionalUserFieldStatusEffectImmunityAbAttr, + ConditionalUserFieldProtectStatAbAttr, + PreApplyBattlerTagAbAttr, + PreApplyBattlerTagImmunityAbAttr, + BattlerTagImmunityAbAttr, + UserFieldBattlerTagImmunityAbAttr, + ConditionalUserFieldBattlerTagImmunityAbAttr, + BlockCritAbAttr, + BonusCritAbAttr, + MultCritAbAttr, + ConditionalCritAbAttr, + BlockNonDirectDamageAbAttr, + BlockStatusDamageAbAttr, + BlockOneHitKOAbAttr, + ChangeMovePriorityAbAttr, + IgnoreContactAbAttr, + PreWeatherEffectAbAttr, + PreWeatherDamageAbAttr, + SuppressWeatherEffectAbAttr, + ForewarnAbAttr, + FriskAbAttr, + PostWeatherChangeAbAttr, + PostWeatherChangeFormChangeAbAttr, + PostWeatherLapseAbAttr, + PostWeatherLapseHealAbAttr, + PostWeatherLapseDamageAbAttr, + PostTerrainChangeAbAttr, + PostTurnAbAttr, + PostTurnStatusHealAbAttr, + PostTurnResetStatusAbAttr, + PostTurnRestoreBerryAbAttr, + RepeatBerryNextTurnAbAttr, + MoodyAbAttr, + SpeedBoostAbAttr, + PostTurnHealAbAttr, + PostTurnFormChangeAbAttr, + PostTurnHurtIfSleepingAbAttr, + FetchBallAbAttr, + PostBiomeChangeAbAttr, + PostBiomeChangeWeatherChangeAbAttr, + PostBiomeChangeTerrainChangeAbAttr, + PostMoveUsedAbAttr, + PostDancingMoveAbAttr, + PostItemLostAbAttr, + PostItemLostApplyBattlerTagAbAttr, + StatStageChangeMultiplierAbAttr, + StatStageChangeCopyAbAttr, + BypassBurnDamageReductionAbAttr, + ReduceBurnDamageAbAttr, + DoubleBerryEffectAbAttr, + PreventBerryUseAbAttr, + HealFromBerryUseAbAttr, + RunSuccessAbAttr, + CheckTrappedAbAttr, + ArenaTrapAbAttr, + MaxMultiHitAbAttr, + PostBattleAbAttr, + PostBattleLootAbAttr, + PostFaintAbAttr, + PostFaintUnsuppressedWeatherFormChangeAbAttr, + PostFaintContactDamageAbAttr, + PostFaintHPDamageAbAttr, + RedirectMoveAbAttr, + RedirectTypeMoveAbAttr, + BlockRedirectAbAttr, + ReduceStatusEffectDurationAbAttr, + FlinchEffectAbAttr, + FlinchStatStageChangeAbAttr, + IncreasePpAbAttr, + ForceSwitchOutImmunityAbAttr, + ReduceBerryUseThresholdAbAttr, + WeightMultiplierAbAttr, + SyncEncounterNatureAbAttr, + MoveAbilityBypassAbAttr, + AlwaysHitAbAttr, + IgnoreProtectOnContactAbAttr, + InfiltratorAbAttr, + ReflectStatusMoveAbAttr, + NoTransformAbilityAbAttr, + NoFusionAbilityAbAttr, + IgnoreTypeImmunityAbAttr, + IgnoreTypeStatusEffectImmunityAbAttr, + MoneyAbAttr, + PostSummonStatStageChangeOnArenaAbAttr, + FormBlockDamageAbAttr, + PreSummonAbAttr, + IllusionPreSummonAbAttr, + IllusionBreakAbAttr, + PostDefendIllusionBreakAbAttr, + IllusionPostBattleAbAttr, + BypassSpeedChanceAbAttr, + PreventBypassSpeedChanceAbAttr, + TerrainEventTypeChangeAbAttr, + PostDamageAbAttr, + PostDamageForceSwitchAbAttr, +}); /** - * Applies a field Stat multiplier attribute - * @param attrType {@linkcode FieldMultiplyStatAbAttr} should always be FieldMultiplyBattleStatAbAttr for the time being - * @param pokemon {@linkcode Pokemon} the Pokemon applying this ability - * @param stat {@linkcode Stat} the type of the checked stat - * @param statValue {@linkcode NumberHolder} the value of the checked stat - * @param checkedPokemon {@linkcode Pokemon} the Pokemon with the checked stat - * @param hasApplied {@linkcode BooleanHolder} whether or not a FieldMultiplyBattleStatAbAttr has already affected this stat - * @param args unused + * A map of of all {@linkcode AbAttr} constructors */ -export function applyFieldStatMultiplierAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - stat: Stat, - statValue: NumberHolder, - checkedPokemon: Pokemon, - hasApplied: BooleanHolder, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => - attr.applyFieldStat(pokemon, passive, simulated, stat, statValue, checkedPokemon, hasApplied, args), - (attr, passive) => - attr.canApplyFieldStat(pokemon, passive, simulated, stat, statValue, checkedPokemon, hasApplied, args), - args, - ); -} - -export function applyPreAttackAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - defender: Pokemon | null, - move: Move, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreAttack(pokemon, passive, simulated, defender, move, args), - (attr, passive) => attr.canApplyPreAttack(pokemon, passive, simulated, defender, move, args), - args, - simulated, - ); -} - -export function applyExecutedMoveAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - attr => attr.applyExecutedMove(pokemon, simulated), - attr => attr.canApplyExecutedMove(pokemon, simulated), - args, - simulated, - ); -} - -export function applyPostAttackAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - defender: Pokemon, - move: Move, - hitResult: HitResult | null, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostAttack(pokemon, passive, simulated, defender, move, hitResult, args), - (attr, passive) => attr.canApplyPostAttack(pokemon, passive, simulated, defender, move, hitResult, args), - args, - simulated, - ); -} - -export function applyPostKnockOutAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - knockedOut: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostKnockOut(pokemon, passive, simulated, knockedOut, args), - (attr, passive) => attr.canApplyPostKnockOut(pokemon, passive, simulated, knockedOut, args), - args, - simulated, - ); -} - -export function applyPostVictoryAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostVictory(pokemon, passive, simulated, args), - (attr, passive) => attr.canApplyPostVictory(pokemon, passive, simulated, args), - args, - simulated, - ); -} - -export function applyPostSummonAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args), - (attr, passive) => attr.canApplyPostSummon(pokemon, passive, simulated, args), - args, - simulated, - ); -} - -export function applyPreSummonAbAttrs(attrType: Constructor, pokemon: Pokemon, ...args: any[]): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreSummon(pokemon, passive, args), - (attr, passive) => attr.canApplyPreSummon(pokemon, passive, args), - args, - ); -} - -export function applyPreSwitchOutAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreSwitchOut(pokemon, passive, simulated, args), - (attr, passive) => attr.canApplyPreSwitchOut(pokemon, passive, simulated, args), - args, - simulated, - ); -} - -export function applyPreLeaveFieldAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreLeaveField(pokemon, passive, simulated, args), - (attr, passive) => attr.canApplyPreLeaveField(pokemon, passive, simulated, args), - args, - simulated, - ); -} - -export function applyPreStatStageChangeAbAttrs( - attrType: Constructor, - pokemon: Pokemon | null, - stat: BattleStat, - cancelled: BooleanHolder, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), - (attr, passive) => attr.canApplyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), - args, - simulated, - ); -} - -export function applyPostStatStageChangeAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - stats: BattleStat[], - stages: number, - selfTarget: boolean, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, _passive) => attr.applyPostStatStageChange(pokemon, simulated, stats, stages, selfTarget, args), - (attr, _passive) => attr.canApplyPostStatStageChange(pokemon, simulated, stats, stages, selfTarget, args), - args, - simulated, - ); -} - -export function applyPreSetStatusAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - effect: StatusEffect | undefined, - cancelled: BooleanHolder, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreSetStatus(pokemon, passive, simulated, effect, cancelled, args), - (attr, passive) => attr.canApplyPreSetStatus(pokemon, passive, simulated, effect, cancelled, args), - args, - simulated, - ); -} - -export function applyPreApplyBattlerTagAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - tag: BattlerTag, - cancelled: BooleanHolder, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreApplyBattlerTag(pokemon, passive, simulated, tag, cancelled, args), - (attr, passive) => attr.canApplyPreApplyBattlerTag(pokemon, passive, simulated, tag, cancelled, args), - args, - simulated, - ); -} - -export function applyPreWeatherEffectAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - weather: Weather | null, - cancelled: BooleanHolder, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPreWeatherEffect(pokemon, passive, simulated, weather, cancelled, args), - (attr, passive) => attr.canApplyPreWeatherEffect(pokemon, passive, simulated, weather, cancelled, args), - args, - simulated, - ); -} - -export function applyPostTurnAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostTurn(pokemon, passive, simulated, args), - (attr, passive) => attr.canApplyPostTurn(pokemon, passive, simulated, args), - args, - simulated, - ); -} - -export function applyPostWeatherChangeAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - weather: WeatherType, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostWeatherChange(pokemon, passive, simulated, weather, args), - (attr, passive) => attr.canApplyPostWeatherChange(pokemon, passive, simulated, weather, args), - args, - simulated, - ); -} - -export function applyPostWeatherLapseAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - weather: Weather | null, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostWeatherLapse(pokemon, passive, simulated, weather, args), - (attr, passive) => attr.canApplyPostWeatherLapse(pokemon, passive, simulated, weather, args), - args, - simulated, - ); -} - -export function applyPostTerrainChangeAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - terrain: TerrainType, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostTerrainChange(pokemon, passive, simulated, terrain, args), - (attr, passive) => attr.canApplyPostTerrainChange(pokemon, passive, simulated, terrain, args), - args, - simulated, - ); -} - -export function applyCheckTrappedAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - trapped: BooleanHolder, - otherPokemon: Pokemon, - messages: string[], - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyCheckTrapped(pokemon, passive, simulated, trapped, otherPokemon, args), - (attr, passive) => attr.canApplyCheckTrapped(pokemon, passive, simulated, trapped, otherPokemon, args), - args, - simulated, - messages, - ); -} - -export function applyPostBattleAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostBattle(pokemon, passive, simulated, args), - (attr, passive) => attr.canApplyPostBattle(pokemon, passive, simulated, args), - args, - simulated, - ); -} - -export function applyPostFaintAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - attacker?: Pokemon, - move?: Move, - hitResult?: HitResult, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, passive) => attr.applyPostFaint(pokemon, passive, simulated, attacker, move, hitResult, args), - (attr, passive) => attr.canApplyPostFaint(pokemon, passive, simulated, attacker, move, hitResult, args), - args, - simulated, - ); -} - -export function applyPostItemLostAbAttrs( - attrType: Constructor, - pokemon: Pokemon, - simulated = false, - ...args: any[] -): void { - applyAbAttrsInternal( - attrType, - pokemon, - (attr, _passive) => attr.applyPostItemLost(pokemon, simulated, args), - (attr, _passive) => attr.canApplyPostItemLost(pokemon, simulated, args), - args, - ); -} - -/** - * Applies abilities when they become active mid-turn (ability switch) - * - * Ignores passives as they don't change and shouldn't be reapplied when main abilities change - */ -export function applyOnGainAbAttrs(pokemon: Pokemon, passive = false, simulated = false, ...args: any[]): void { - applySingleAbAttrs( - pokemon, - passive, - PostSummonAbAttr, - (attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args), - (attr, passive) => attr.canApplyPostSummon(pokemon, passive, simulated, args), - args, - true, - simulated, - ); -} - -/** - * Applies ability attributes which activate when the ability is lost or suppressed (i.e. primal weather) - */ -export function applyOnLoseAbAttrs(pokemon: Pokemon, passive = false, simulated = false, ...args: any[]): void { - applySingleAbAttrs( - pokemon, - passive, - PreLeaveFieldAbAttr, - (attr, passive) => attr.applyPreLeaveField(pokemon, passive, simulated, [...args, true]), - (attr, passive) => attr.canApplyPreLeaveField(pokemon, passive, simulated, [...args, true]), - args, - true, - simulated, - ); - - applySingleAbAttrs( - pokemon, - passive, - IllusionBreakAbAttr, - (attr, passive) => attr.apply(pokemon, passive, simulated, null, args), - (attr, passive) => attr.canApply(pokemon, passive, simulated, args), - args, - true, - simulated, - ); -} +export type AbAttrConstructorMap = typeof AbilityAttrs; /** * Sets the ability of a Pokémon as revealed. diff --git a/src/data/abilities/apply-ab-attrs.ts b/src/data/abilities/apply-ab-attrs.ts new file mode 100644 index 00000000000..e2f8ec9c14c --- /dev/null +++ b/src/data/abilities/apply-ab-attrs.ts @@ -0,0 +1,829 @@ +import type { AbAttrApplyFunc, AbAttrMap, AbAttrString, AbAttrSuccessFunc } from "#app/@types/ability-types"; +import type Pokemon from "#app/field/pokemon"; +import { globalScene } from "#app/global-scene"; +import type { BooleanHolder, NumberHolder } from "#app/utils/common"; +import type { BattlerIndex } from "#enums/battler-index"; +import type { HitResult } from "#enums/hit-result"; +import type { BattleStat, Stat } from "#enums/stat"; +import type { StatusEffect } from "#enums/status-effect"; +import type { WeatherType } from "#enums/weather-type"; +import type { BattlerTag } from "../battler-tags"; +import type Move from "../moves/move"; +import type { PokemonMove } from "../moves/pokemon-move"; +import type { TerrainType } from "../terrain"; +import type { Weather } from "../weather"; +import type { + PostBattleInitAbAttr, + PreDefendAbAttr, + PostDefendAbAttr, + PostMoveUsedAbAttr, + StatMultiplierAbAttr, + AllyStatMultiplierAbAttr, + PostSetStatusAbAttr, + PostDamageAbAttr, + FieldMultiplyStatAbAttr, + PreAttackAbAttr, + ExecutedMoveAbAttr, + PostAttackAbAttr, + PostKnockOutAbAttr, + PostVictoryAbAttr, + PostSummonAbAttr, + PreSummonAbAttr, + PreSwitchOutAbAttr, + PreLeaveFieldAbAttr, + PreStatStageChangeAbAttr, + PostStatStageChangeAbAttr, + PreSetStatusAbAttr, + PreApplyBattlerTagAbAttr, + PreWeatherEffectAbAttr, + PreWeatherDamageAbAttr, + PostTurnAbAttr, + PostWeatherChangeAbAttr, + PostWeatherLapseAbAttr, + PostTerrainChangeAbAttr, + CheckTrappedAbAttr, + PostBattleAbAttr, + PostFaintAbAttr, + PostItemLostAbAttr, +} from "./ability"; + +function applySingleAbAttrs( + pokemon: Pokemon, + passive: boolean, + attrType: T, + applyFunc: AbAttrApplyFunc, + successFunc: AbAttrSuccessFunc, + args: any[], + gainedMidTurn = false, + simulated = false, + messages: string[] = [], +) { + if (!pokemon?.canApplyAbility(passive) || (passive && pokemon.getPassiveAbility().id === pokemon.getAbility().id)) { + return; + } + + const ability = passive ? pokemon.getPassiveAbility() : pokemon.getAbility(); + if ( + gainedMidTurn && + ability.getAttrs(attrType).some(attr => { + attr.is("PostSummonAbAttr") && !attr.shouldActivateOnGain(); + }) + ) { + return; + } + + for (const attr of ability.getAttrs(attrType)) { + const condition = attr.getCondition(); + let abShown = false; + if ((condition && !condition(pokemon)) || !successFunc(attr, passive)) { + continue; + } + + globalScene.phaseManager.setPhaseQueueSplice(); + + if (attr.showAbility && !simulated) { + globalScene.phaseManager.queueAbilityDisplay(pokemon, passive, true); + abShown = true; + } + const message = attr.getTriggerMessage(pokemon, ability.name, args); + if (message) { + if (!simulated) { + globalScene.phaseManager.queueMessage(message); + } + messages.push(message); + } + + applyFunc(attr, passive); + + if (abShown) { + globalScene.phaseManager.queueAbilityDisplay(pokemon, passive, false); + } + + if (!simulated) { + pokemon.waveData.abilitiesApplied.add(ability.id); + } + + globalScene.phaseManager.clearPhaseQueueSplice(); + } +} + +function applyAbAttrsInternal( + attrType: T, + pokemon: Pokemon | null, + applyFunc: AbAttrApplyFunc, + successFunc: AbAttrSuccessFunc, + args: any[], + simulated = false, + messages: string[] = [], + gainedMidTurn = false, +) { + for (const passive of [false, true]) { + if (pokemon) { + applySingleAbAttrs(pokemon, passive, attrType, applyFunc, successFunc, args, gainedMidTurn, simulated, messages); + globalScene.phaseManager.clearPhaseQueueSplice(); + } + } +} + +export function applyAbAttrs( + attrType: T, + pokemon: Pokemon, + cancelled: BooleanHolder | null, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + // @ts-expect-error: TODO: fix the error on `cancelled` + (attr, passive) => attr.apply(pokemon, passive, simulated, cancelled, args), + (attr, passive) => attr.canApply(pokemon, passive, simulated, args), + args, + simulated, + ); +} + +// TODO: Improve the type signatures of the following methods / refactor the apply methods + +export function applyPostBattleInitAbAttrs( + attrType: AbAttrMap[K] extends PostBattleInitAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PostBattleInitAbAttr).applyPostBattleInit(pokemon, passive, simulated, args), + (attr, passive) => (attr as PostBattleInitAbAttr).canApplyPostBattleInit(pokemon, passive, simulated, args), + args, + simulated, + ); +} + +export function applyPreDefendAbAttrs( + attrType: AbAttrMap[K] extends PreDefendAbAttr ? K : never, + pokemon: Pokemon, + attacker: Pokemon, + move: Move | null, + cancelled: BooleanHolder | null, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PreDefendAbAttr).applyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args), + (attr, passive) => + (attr as PreDefendAbAttr).canApplyPreDefend(pokemon, passive, simulated, attacker, move, cancelled, args), + args, + simulated, + ); +} + +export function applyPostDefendAbAttrs( + attrType: AbAttrMap[K] extends PostDefendAbAttr ? K : never, + pokemon: Pokemon, + attacker: Pokemon, + move: Move, + hitResult: HitResult | null, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PostDefendAbAttr).applyPostDefend(pokemon, passive, simulated, attacker, move, hitResult, args), + (attr, passive) => + (attr as PostDefendAbAttr).canApplyPostDefend(pokemon, passive, simulated, attacker, move, hitResult, args), + args, + simulated, + ); +} + +export function applyPostMoveUsedAbAttrs( + attrType: AbAttrMap[K] extends PostMoveUsedAbAttr ? K : never, + pokemon: Pokemon, + move: PokemonMove, + source: Pokemon, + targets: BattlerIndex[], + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, _passive) => (attr as PostMoveUsedAbAttr).applyPostMoveUsed(pokemon, move, source, targets, simulated, args), + (attr, _passive) => + (attr as PostMoveUsedAbAttr).canApplyPostMoveUsed(pokemon, move, source, targets, simulated, args), + args, + simulated, + ); +} + +export function applyStatMultiplierAbAttrs( + attrType: AbAttrMap[K] extends StatMultiplierAbAttr ? K : never, + pokemon: Pokemon, + stat: BattleStat, + statValue: NumberHolder, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as StatMultiplierAbAttr).applyStatStage(pokemon, passive, simulated, stat, statValue, args), + (attr, passive) => + (attr as StatMultiplierAbAttr).canApplyStatStage(pokemon, passive, simulated, stat, statValue, args), + args, + ); +} + +/** + * Applies an ally's Stat multiplier attribute + * @param attrType - {@linkcode AllyStatMultiplierAbAttr} should always be AllyStatMultiplierAbAttr for the time being + * @param pokemon - The {@linkcode Pokemon} with the ability + * @param stat - The type of the checked {@linkcode Stat} + * @param statValue - {@linkcode NumberHolder} containing the value of the checked stat + * @param checkedPokemon - The {@linkcode Pokemon} with the checked stat + * @param ignoreAbility - Whether or not the ability should be ignored by the pokemon or its move. + * @param args - unused + */ +export function applyAllyStatMultiplierAbAttrs( + attrType: AbAttrMap[K] extends AllyStatMultiplierAbAttr ? K : never, + pokemon: Pokemon, + stat: BattleStat, + statValue: NumberHolder, + simulated = false, + checkedPokemon: Pokemon, + ignoreAbility: boolean, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as AllyStatMultiplierAbAttr).applyAllyStat( + pokemon, + passive, + simulated, + stat, + statValue, + checkedPokemon, + ignoreAbility, + args, + ), + (attr, passive) => + (attr as AllyStatMultiplierAbAttr).canApplyAllyStat( + pokemon, + passive, + simulated, + stat, + statValue, + checkedPokemon, + ignoreAbility, + args, + ), + args, + simulated, + ); +} + +export function applyPostSetStatusAbAttrs( + attrType: AbAttrMap[K] extends PostSetStatusAbAttr ? K : never, + pokemon: Pokemon, + effect: StatusEffect, + sourcePokemon?: Pokemon | null, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PostSetStatusAbAttr).applyPostSetStatus(pokemon, sourcePokemon, passive, effect, simulated, args), + (attr, passive) => + (attr as PostSetStatusAbAttr).canApplyPostSetStatus(pokemon, sourcePokemon, passive, effect, simulated, args), + args, + simulated, + ); +} + +export function applyPostDamageAbAttrs( + attrType: AbAttrMap[K] extends PostDamageAbAttr ? K : never, + pokemon: Pokemon, + damage: number, + _passive: boolean, + simulated = false, + args: any[], + source?: Pokemon, +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PostDamageAbAttr).applyPostDamage(pokemon, damage, passive, simulated, args, source), + (attr, passive) => (attr as PostDamageAbAttr).canApplyPostDamage(pokemon, damage, passive, simulated, args, source), + args, + ); +} +/** + * Applies a field Stat multiplier attribute + * @param attrType {@linkcode FieldMultiplyStatAbAttr} should always be FieldMultiplyBattleStatAbAttr for the time being + * @param pokemon {@linkcode Pokemon} the Pokemon applying this ability + * @param stat {@linkcode Stat} the type of the checked stat + * @param statValue {@linkcode NumberHolder} the value of the checked stat + * @param checkedPokemon {@linkcode Pokemon} the Pokemon with the checked stat + * @param hasApplied {@linkcode BooleanHolder} whether or not a FieldMultiplyBattleStatAbAttr has already affected this stat + * @param args unused + */ + +export function applyFieldStatMultiplierAbAttrs( + attrType: AbAttrMap[K] extends FieldMultiplyStatAbAttr ? K : never, + pokemon: Pokemon, + stat: Stat, + statValue: NumberHolder, + checkedPokemon: Pokemon, + hasApplied: BooleanHolder, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as FieldMultiplyStatAbAttr).applyFieldStat( + pokemon, + passive, + simulated, + stat, + statValue, + checkedPokemon, + hasApplied, + args, + ), + (attr, passive) => + (attr as FieldMultiplyStatAbAttr).canApplyFieldStat( + pokemon, + passive, + simulated, + stat, + statValue, + checkedPokemon, + hasApplied, + args, + ), + args, + ); +} + +export function applyPreAttackAbAttrs( + attrType: AbAttrMap[K] extends PreAttackAbAttr ? K : never, + pokemon: Pokemon, + defender: Pokemon | null, + move: Move, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PreAttackAbAttr).applyPreAttack(pokemon, passive, simulated, defender, move, args), + (attr, passive) => (attr as PreAttackAbAttr).canApplyPreAttack(pokemon, passive, simulated, defender, move, args), + args, + simulated, + ); +} + +export function applyExecutedMoveAbAttrs( + attrType: AbAttrMap[K] extends ExecutedMoveAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + attr => (attr as ExecutedMoveAbAttr).applyExecutedMove(pokemon, simulated), + attr => (attr as ExecutedMoveAbAttr).canApplyExecutedMove(pokemon, simulated), + args, + simulated, + ); +} + +export function applyPostAttackAbAttrs( + attrType: AbAttrMap[K] extends PostAttackAbAttr ? K : never, + pokemon: Pokemon, + defender: Pokemon, + move: Move, + hitResult: HitResult | null, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PostAttackAbAttr).applyPostAttack(pokemon, passive, simulated, defender, move, hitResult, args), + (attr, passive) => + (attr as PostAttackAbAttr).canApplyPostAttack(pokemon, passive, simulated, defender, move, hitResult, args), + args, + simulated, + ); +} + +export function applyPostKnockOutAbAttrs( + attrType: AbAttrMap[K] extends PostKnockOutAbAttr ? K : never, + pokemon: Pokemon, + knockedOut: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PostKnockOutAbAttr).applyPostKnockOut(pokemon, passive, simulated, knockedOut, args), + (attr, passive) => (attr as PostKnockOutAbAttr).canApplyPostKnockOut(pokemon, passive, simulated, knockedOut, args), + args, + simulated, + ); +} + +export function applyPostVictoryAbAttrs( + attrType: AbAttrMap[K] extends PostVictoryAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PostVictoryAbAttr).applyPostVictory(pokemon, passive, simulated, args), + (attr, passive) => (attr as PostVictoryAbAttr).canApplyPostVictory(pokemon, passive, simulated, args), + args, + simulated, + ); +} + +export function applyPostSummonAbAttrs( + attrType: AbAttrMap[K] extends PostSummonAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PostSummonAbAttr).applyPostSummon(pokemon, passive, simulated, args), + (attr, passive) => (attr as PostSummonAbAttr).canApplyPostSummon(pokemon, passive, simulated, args), + args, + simulated, + ); +} + +export function applyPreSummonAbAttrs( + attrType: AbAttrMap[K] extends PreSummonAbAttr ? K : never, + pokemon: Pokemon, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PreSummonAbAttr).applyPreSummon(pokemon, passive, args), + (attr, passive) => (attr as PreSummonAbAttr).canApplyPreSummon(pokemon, passive, args), + args, + ); +} + +export function applyPreSwitchOutAbAttrs( + attrType: AbAttrMap[K] extends PreSwitchOutAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PreSwitchOutAbAttr).applyPreSwitchOut(pokemon, passive, simulated, args), + (attr, passive) => (attr as PreSwitchOutAbAttr).canApplyPreSwitchOut(pokemon, passive, simulated, args), + args, + simulated, + ); +} + +export function applyPreLeaveFieldAbAttrs( + attrType: AbAttrMap[K] extends PreLeaveFieldAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PreLeaveFieldAbAttr).applyPreLeaveField(pokemon, passive, simulated, args), + (attr, passive) => (attr as PreLeaveFieldAbAttr).canApplyPreLeaveField(pokemon, passive, simulated, args), + args, + simulated, + ); +} + +export function applyPreStatStageChangeAbAttrs( + attrType: AbAttrMap[K] extends PreStatStageChangeAbAttr ? K : never, + pokemon: Pokemon | null, + stat: BattleStat, + cancelled: BooleanHolder, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PreStatStageChangeAbAttr).applyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), + (attr, passive) => + (attr as PreStatStageChangeAbAttr).canApplyPreStatStageChange(pokemon, passive, simulated, stat, cancelled, args), + args, + simulated, + ); +} + +export function applyPostStatStageChangeAbAttrs( + attrType: AbAttrMap[K] extends PostStatStageChangeAbAttr ? K : never, + pokemon: Pokemon, + stats: BattleStat[], + stages: number, + selfTarget: boolean, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, _passive) => + (attr as PostStatStageChangeAbAttr).applyPostStatStageChange(pokemon, simulated, stats, stages, selfTarget, args), + (attr, _passive) => + (attr as PostStatStageChangeAbAttr).canApplyPostStatStageChange( + pokemon, + simulated, + stats, + stages, + selfTarget, + args, + ), + args, + simulated, + ); +} + +export function applyPreSetStatusAbAttrs( + attrType: AbAttrMap[K] extends PreSetStatusAbAttr ? K : never, + pokemon: Pokemon, + effect: StatusEffect | undefined, + cancelled: BooleanHolder, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PreSetStatusAbAttr).applyPreSetStatus(pokemon, passive, simulated, effect, cancelled, args), + (attr, passive) => + (attr as PreSetStatusAbAttr).canApplyPreSetStatus(pokemon, passive, simulated, effect, cancelled, args), + args, + simulated, + ); +} + +export function applyPreApplyBattlerTagAbAttrs( + attrType: AbAttrMap[K] extends PreApplyBattlerTagAbAttr ? K : never, + pokemon: Pokemon, + tag: BattlerTag, + cancelled: BooleanHolder, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PreApplyBattlerTagAbAttr).applyPreApplyBattlerTag(pokemon, passive, simulated, tag, cancelled, args), + (attr, passive) => + (attr as PreApplyBattlerTagAbAttr).canApplyPreApplyBattlerTag(pokemon, passive, simulated, tag, cancelled, args), + args, + simulated, + ); +} + +export function applyPreWeatherEffectAbAttrs( + attrType: AbAttrMap[K] extends PreWeatherEffectAbAttr ? K : never, + pokemon: Pokemon, + weather: Weather | null, + cancelled: BooleanHolder, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PreWeatherDamageAbAttr).applyPreWeatherEffect(pokemon, passive, simulated, weather, cancelled, args), + (attr, passive) => + (attr as PreWeatherDamageAbAttr).canApplyPreWeatherEffect(pokemon, passive, simulated, weather, cancelled, args), + args, + simulated, + ); +} + +export function applyPostTurnAbAttrs( + attrType: AbAttrMap[K] extends PostTurnAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PostTurnAbAttr).applyPostTurn(pokemon, passive, simulated, args), + (attr, passive) => (attr as PostTurnAbAttr).canApplyPostTurn(pokemon, passive, simulated, args), + args, + simulated, + ); +} + +export function applyPostWeatherChangeAbAttrs( + attrType: AbAttrMap[K] extends PostWeatherChangeAbAttr ? K : never, + pokemon: Pokemon, + weather: WeatherType, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PostWeatherChangeAbAttr).applyPostWeatherChange(pokemon, passive, simulated, weather, args), + (attr, passive) => + (attr as PostWeatherChangeAbAttr).canApplyPostWeatherChange(pokemon, passive, simulated, weather, args), + args, + simulated, + ); +} + +export function applyPostWeatherLapseAbAttrs( + attrType: AbAttrMap[K] extends PostWeatherLapseAbAttr ? K : never, + pokemon: Pokemon, + weather: Weather | null, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PostWeatherLapseAbAttr).applyPostWeatherLapse(pokemon, passive, simulated, weather, args), + (attr, passive) => + (attr as PostWeatherLapseAbAttr).canApplyPostWeatherLapse(pokemon, passive, simulated, weather, args), + args, + simulated, + ); +} + +export function applyPostTerrainChangeAbAttrs( + attrType: AbAttrMap[K] extends PostTerrainChangeAbAttr ? K : never, + pokemon: Pokemon, + terrain: TerrainType, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PostTerrainChangeAbAttr).applyPostTerrainChange(pokemon, passive, simulated, terrain, args), + (attr, passive) => + (attr as PostTerrainChangeAbAttr).canApplyPostTerrainChange(pokemon, passive, simulated, terrain, args), + args, + simulated, + ); +} + +export function applyCheckTrappedAbAttrs( + attrType: AbAttrMap[K] extends CheckTrappedAbAttr ? K : never, + pokemon: Pokemon, + trapped: BooleanHolder, + otherPokemon: Pokemon, + messages: string[], + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as CheckTrappedAbAttr).applyCheckTrapped(pokemon, passive, simulated, trapped, otherPokemon, args), + (attr, passive) => + (attr as CheckTrappedAbAttr).canApplyCheckTrapped(pokemon, passive, simulated, trapped, otherPokemon, args), + args, + simulated, + messages, + ); +} + +export function applyPostBattleAbAttrs( + attrType: AbAttrMap[K] extends PostBattleAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => (attr as PostBattleAbAttr).applyPostBattle(pokemon, passive, simulated, args), + (attr, passive) => (attr as PostBattleAbAttr).canApplyPostBattle(pokemon, passive, simulated, args), + args, + simulated, + ); +} + +export function applyPostFaintAbAttrs( + attrType: AbAttrMap[K] extends PostFaintAbAttr ? K : never, + pokemon: Pokemon, + attacker?: Pokemon, + move?: Move, + hitResult?: HitResult, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, passive) => + (attr as PostFaintAbAttr).applyPostFaint(pokemon, passive, simulated, attacker, move, hitResult, args), + (attr, passive) => + (attr as PostFaintAbAttr).canApplyPostFaint(pokemon, passive, simulated, attacker, move, hitResult, args), + args, + simulated, + ); +} + +export function applyPostItemLostAbAttrs( + attrType: AbAttrMap[K] extends PostItemLostAbAttr ? K : never, + pokemon: Pokemon, + simulated = false, + ...args: any[] +): void { + applyAbAttrsInternal( + attrType, + pokemon, + (attr, _passive) => (attr as PostItemLostAbAttr).applyPostItemLost(pokemon, simulated, args), + (attr, _passive) => (attr as PostItemLostAbAttr).canApplyPostItemLost(pokemon, simulated, args), + args, + ); +} + +/** + * Applies abilities when they become active mid-turn (ability switch) + * + * Ignores passives as they don't change and shouldn't be reapplied when main abilities change + */ +export function applyOnGainAbAttrs(pokemon: Pokemon, passive = false, simulated = false, ...args: any[]): void { + applySingleAbAttrs( + pokemon, + passive, + "PostSummonAbAttr", + (attr, passive) => attr.applyPostSummon(pokemon, passive, simulated, args), + (attr, passive) => attr.canApplyPostSummon(pokemon, passive, simulated, args), + args, + true, + simulated, + ); +} +/** + * Applies ability attributes which activate when the ability is lost or suppressed (i.e. primal weather) + */ +export function applyOnLoseAbAttrs(pokemon: Pokemon, passive = false, simulated = false, ...args: any[]): void { + applySingleAbAttrs( + pokemon, + passive, + "PreLeaveFieldAbAttr", + (attr, passive) => attr.applyPreLeaveField(pokemon, passive, simulated, [...args, true]), + (attr, passive) => attr.canApplyPreLeaveField(pokemon, passive, simulated, [...args, true]), + args, + true, + simulated, + ); + + applySingleAbAttrs( + pokemon, + passive, + "IllusionBreakAbAttr", + (attr, passive) => attr.apply(pokemon, passive, simulated, null, args), + (attr, passive) => attr.canApply(pokemon, passive, simulated, args), + args, + true, + simulated, + ); +} diff --git a/src/data/arena-tag.ts b/src/data/arena-tag.ts index e18ee5ac556..da1bbbda2e9 100644 --- a/src/data/arena-tag.ts +++ b/src/data/arena-tag.ts @@ -10,15 +10,7 @@ import type Pokemon from "#app/field/pokemon"; import { HitResult } from "#enums/hit-result"; import { StatusEffect } from "#enums/status-effect"; import type { BattlerIndex } from "#enums/battler-index"; -import { - BlockNonDirectDamageAbAttr, - InfiltratorAbAttr, - PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, - ProtectStatAbAttr, - applyAbAttrs, - applyOnGainAbAttrs, - applyOnLoseAbAttrs, -} from "#app/data/abilities/ability"; +import { applyAbAttrs, applyOnGainAbAttrs, applyOnLoseAbAttrs } from "./abilities/apply-ab-attrs"; import { Stat } from "#enums/stat"; import { CommonBattleAnim } from "#app/data/battle-anims"; import { CommonAnim } from "#enums/move-anims-common"; @@ -144,7 +136,7 @@ export class MistTag extends ArenaTag { if (attacker) { const bypassed = new BooleanHolder(false); // TODO: Allow this to be simulated - applyAbAttrs(InfiltratorAbAttr, attacker, null, false, bypassed); + applyAbAttrs("InfiltratorAbAttr", attacker, null, false, bypassed); if (bypassed.value) { return false; } @@ -209,7 +201,7 @@ export class WeakenMoveScreenTag extends ArenaTag { ): boolean { if (this.weakenedCategories.includes(moveCategory)) { const bypassed = new BooleanHolder(false); - applyAbAttrs(InfiltratorAbAttr, attacker, null, false, bypassed); + applyAbAttrs("InfiltratorAbAttr", attacker, null, false, bypassed); if (bypassed.value) { return false; } @@ -765,7 +757,7 @@ class SpikesTag extends ArenaTrapTag { } const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); if (simulated || cancelled.value) { return !cancelled.value; } @@ -953,7 +945,7 @@ class StealthRockTag extends ArenaTrapTag { override activateTrap(pokemon: Pokemon, simulated: boolean): boolean { const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); if (cancelled.value) { return false; } @@ -1010,7 +1002,7 @@ class StickyWebTag extends ArenaTrapTag { override activateTrap(pokemon: Pokemon, simulated: boolean): boolean { if (pokemon.isGrounded()) { const cancelled = new BooleanHolder(false); - applyAbAttrs(ProtectStatAbAttr, pokemon, cancelled); + applyAbAttrs("ProtectStatAbAttr", pokemon, cancelled); if (simulated) { return !cancelled.value; @@ -1444,8 +1436,8 @@ export class SuppressAbilitiesTag extends ArenaTag { // Could have a custom message that plays when a specific pokemon's NG ends? This entire thing exists due to passives after all const setter = globalScene .getField() - .filter(p => p?.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false))[0]; - applyOnGainAbAttrs(setter, setter.getAbility().hasAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr)); + .filter(p => p?.hasAbilityWithAttr("PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr", false))[0]; + applyOnGainAbAttrs(setter, setter.getAbility().hasAttr("PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr")); } } @@ -1457,7 +1449,7 @@ export class SuppressAbilitiesTag extends ArenaTag { for (const pokemon of globalScene.getField(true)) { // There is only one pokemon with this attr on the field on removal, so its abilities are already active - if (pokemon && !pokemon.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false)) { + if (pokemon && !pokemon.hasAbilityWithAttr("PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr", false)) { [true, false].forEach(passive => applyOnGainAbAttrs(pokemon, passive)); } } diff --git a/src/data/balance/pokemon-evolutions.ts b/src/data/balance/pokemon-evolutions.ts index 298cf2d0719..d307f5cfbf6 100644 --- a/src/data/balance/pokemon-evolutions.ts +++ b/src/data/balance/pokemon-evolutions.ts @@ -11,7 +11,6 @@ import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; import { SpeciesFormKey } from "#enums/species-form-key"; import { TimeOfDay } from "#enums/time-of-day"; -import { DamageMoneyRewardModifier, ExtraModifierModifier, MoneyMultiplierModifier, SpeciesStatBoosterModifier, TempExtraModifierModifier } from "#app/modifier/modifier"; import type { SpeciesStatBoosterModifierType } from "#app/modifier/modifier-type"; import { speciesStarterCosts } from "./starters"; import i18next from "i18next"; @@ -275,9 +274,9 @@ class MoveTypeEvolutionCondition extends SpeciesEvolutionCondition { class TreasureEvolutionCondition extends SpeciesEvolutionCondition { constructor() { super(p => p.evoCounter - + p.getHeldItems().filter(m => m instanceof DamageMoneyRewardModifier).length - + globalScene.findModifiers(m => m instanceof MoneyMultiplierModifier - || m instanceof ExtraModifierModifier || m instanceof TempExtraModifierModifier).length > 9); + + p.getHeldItems().filter(m => m.is("DamageMoneyRewardModifier")).length + + globalScene.findModifiers(m => m.is("MoneyMultiplierModifier") + || m.is("ExtraModifierModifier") || m.is("TempExtraModifierModifier")).length > 9); this.description = i18next.t("pokemonEvolutions:treasure"); } } @@ -1794,8 +1793,8 @@ export const pokemonEvolutions: PokemonEvolutions = { ], [SpeciesId.CLAMPERL]: [ // TODO: Change the SpeciesEvolutionConditions here to use a bespoke HeldItemEvolutionCondition after the modifier rework - new SpeciesEvolution(SpeciesId.HUNTAIL, 1, EvolutionItem.LINKING_CORD, new SpeciesEvolutionCondition(p => p.getHeldItems().some(m => m instanceof SpeciesStatBoosterModifier && (m.type as SpeciesStatBoosterModifierType).key === "DEEP_SEA_TOOTH")), SpeciesWildEvolutionDelay.VERY_LONG), - new SpeciesEvolution(SpeciesId.GOREBYSS, 1, EvolutionItem.LINKING_CORD, new SpeciesEvolutionCondition(p => p.getHeldItems().some(m => m instanceof SpeciesStatBoosterModifier && (m.type as SpeciesStatBoosterModifierType).key === "DEEP_SEA_SCALE")), SpeciesWildEvolutionDelay.VERY_LONG) + new SpeciesEvolution(SpeciesId.HUNTAIL, 1, EvolutionItem.LINKING_CORD, new SpeciesEvolutionCondition(p => p.getHeldItems().some(m => m.is("SpeciesStatBoosterModifier") && (m.type as SpeciesStatBoosterModifierType).key === "DEEP_SEA_TOOTH")), SpeciesWildEvolutionDelay.VERY_LONG), + new SpeciesEvolution(SpeciesId.GOREBYSS, 1, EvolutionItem.LINKING_CORD, new SpeciesEvolutionCondition(p => p.getHeldItems().some(m => m.is("SpeciesStatBoosterModifier") && (m.type as SpeciesStatBoosterModifierType).key === "DEEP_SEA_SCALE")), SpeciesWildEvolutionDelay.VERY_LONG) ], [SpeciesId.BOLDORE]: [ new SpeciesEvolution(SpeciesId.GIGALITH, 1, EvolutionItem.LINKING_CORD, null, SpeciesWildEvolutionDelay.VERY_LONG) diff --git a/src/data/balance/tms.ts b/src/data/balance/tms.ts index 2b0e8f5142d..e194dc4040c 100644 --- a/src/data/balance/tms.ts +++ b/src/data/balance/tms.ts @@ -1,4 +1,4 @@ -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { MoveId } from "#enums/move-id"; import { SpeciesId } from "#enums/species-id"; diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index 0b40469b255..7aa419ca470 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -10,6 +10,7 @@ import { isNullOrUndefined } from "../utils/common"; import Phaser from "phaser"; import { EncounterAnim } from "#enums/encounter-anims"; import { AnimBlendType, AnimFrameTarget, AnimFocus, ChargeAnim, CommonAnim } from "#enums/move-anims-common"; +import { BattlerTagType } from "#enums/battler-tag-type"; export class AnimConfig { public id: number; @@ -770,7 +771,7 @@ export abstract class BattleAnim { const user = !isOppAnim ? this.user : this.target; const target = !isOppAnim ? this.target : this.user; - const targetSubstitute = onSubstitute && user !== target ? target!.getTag(SubstituteTag) : null; + const targetSubstitute = onSubstitute && user !== target ? target!.getTag(BattlerTagType.SUBSTITUTE) : null; const userInitialX = user!.x; // TODO: is this bang correct? const userInitialY = user!.y; // TODO: is this bang correct? diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index ffa179c6aab..0daf1913737 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -1,13 +1,6 @@ import { globalScene } from "#app/global-scene"; import Overrides from "#app/overrides"; -import { - applyAbAttrs, - BlockNonDirectDamageAbAttr, - FlinchEffectAbAttr, - ProtectStatAbAttr, - ConditionalUserFieldProtectStatAbAttr, - ReverseDrainAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs } from "./abilities/apply-ab-attrs"; import { allAbilities } from "./data-lists"; import { CommonBattleAnim, MoveChargeAnim } from "#app/data/battle-anims"; import { ChargeAnim, CommonAnim } from "#enums/move-anims-common"; @@ -648,7 +641,7 @@ export class FlinchedTag extends BattlerTag { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon), }), ); - applyAbAttrs(FlinchEffectAbAttr, pokemon, null); + applyAbAttrs("FlinchEffectAbAttr", pokemon, null); return true; } @@ -942,7 +935,7 @@ export class SeedTag extends BattlerTag { const source = pokemon.getOpponents().find(o => o.getBattlerIndex() === this.sourceIndex); if (source) { const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); if (!cancelled.value) { globalScene.phaseManager.unshiftNew( @@ -953,7 +946,7 @@ export class SeedTag extends BattlerTag { ); const damage = pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8), { result: HitResult.INDIRECT }); - const reverseDrain = pokemon.hasAbilityWithAttr(ReverseDrainAbAttr, false); + const reverseDrain = pokemon.hasAbilityWithAttr("ReverseDrainAbAttr", false); globalScene.phaseManager.unshiftNew( "PokemonHealPhase", source.getBattlerIndex(), @@ -1026,7 +1019,7 @@ export class PowderTag extends BattlerTag { globalScene.phaseManager.unshiftNew("CommonAnimPhase", idx, idx, CommonAnim.POWDER); const cancelDamage = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelDamage); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelDamage); if (!cancelDamage.value) { pokemon.damageAndUpdate(Math.floor(pokemon.getMaxHp() / 4), { result: HitResult.INDIRECT }); } @@ -1079,7 +1072,7 @@ export class NightmareTag extends BattlerTag { phaseManager.unshiftNew("CommonAnimPhase", pokemon.getBattlerIndex(), undefined, CommonAnim.CURSE); // TODO: Update animation type const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); if (!cancelled.value) { pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 4), { result: HitResult.INDIRECT }); @@ -1438,7 +1431,7 @@ export abstract class DamagingTrapTag extends TrappedTag { phaseManager.unshiftNew("CommonAnimPhase", pokemon.getBattlerIndex(), undefined, this.commonAnim); const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); if (!cancelled.value) { pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 8), { result: HitResult.INDIRECT }); @@ -1681,7 +1674,7 @@ export class ContactDamageProtectedTag extends ContactProtectedTag { */ override onContact(attacker: Pokemon, user: Pokemon): void { const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", user, cancelled); if (!cancelled.value) { attacker.damageAndUpdate(toDmgValue(attacker.getMaxHp() * (1 / this.damageRatio)), { result: HitResult.INDIRECT, @@ -2277,7 +2270,7 @@ export class SaltCuredTag extends BattlerTag { ); const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); if (!cancelled.value) { const pokemonSteelOrWater = pokemon.isOfType(PokemonType.STEEL) || pokemon.isOfType(PokemonType.WATER); @@ -2331,7 +2324,7 @@ export class CursedTag extends BattlerTag { ); const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); if (!cancelled.value) { pokemon.damageAndUpdate(toDmgValue(pokemon.getMaxHp() / 4), { result: HitResult.INDIRECT }); @@ -2666,7 +2659,7 @@ export class GulpMissileTag extends BattlerTag { } const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, attacker, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", attacker, cancelled); if (!cancelled.value) { attacker.damageAndUpdate(Math.max(1, Math.floor(attacker.getMaxHp() / 4)), { result: HitResult.INDIRECT }); @@ -3056,8 +3049,8 @@ export class MysteryEncounterPostSummonTag extends BattlerTag { if (lapseType === BattlerTagLapseType.CUSTOM) { const cancelled = new BooleanHolder(false); - applyAbAttrs(ProtectStatAbAttr, pokemon, cancelled); - applyAbAttrs(ConditionalUserFieldProtectStatAbAttr, pokemon, cancelled, false, pokemon); + applyAbAttrs("ProtectStatAbAttr", pokemon, cancelled); + applyAbAttrs("ConditionalUserFieldProtectStatAbAttr", pokemon, cancelled, false, pokemon); if (!cancelled.value) { if (pokemon.mysteryEncounterBattleEffects) { pokemon.mysteryEncounterBattleEffects(pokemon); diff --git a/src/data/berry.ts b/src/data/berry.ts index df500fa0609..7d1e62362a8 100644 --- a/src/data/berry.ts +++ b/src/data/berry.ts @@ -3,7 +3,7 @@ import type Pokemon from "../field/pokemon"; import { HitResult } from "#enums/hit-result"; import { getStatusEffectHealText } from "./status-effect"; import { NumberHolder, toDmgValue, randSeedInt } from "#app/utils/common"; -import { DoubleBerryEffectAbAttr, ReduceBerryUseThresholdAbAttr, applyAbAttrs } from "./abilities/ability"; +import { applyAbAttrs } from "./abilities/apply-ab-attrs"; import i18next from "i18next"; import { BattlerTagType } from "#enums/battler-tag-type"; import { BerryType } from "#enums/berry-type"; @@ -38,25 +38,25 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate { const threshold = new NumberHolder(0.25); // Offset BerryType such that LIECHI -> Stat.ATK = 1, GANLON -> Stat.DEF = 2, so on and so forth const stat: BattleStat = berryType - BerryType.ENIGMA; - applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold); + applyAbAttrs("ReduceBerryUseThresholdAbAttr", pokemon, null, false, threshold); return pokemon.getHpRatio() < threshold.value && pokemon.getStatStage(stat) < 6; }; case BerryType.LANSAT: return (pokemon: Pokemon) => { const threshold = new NumberHolder(0.25); - applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold); + applyAbAttrs("ReduceBerryUseThresholdAbAttr", pokemon, null, false, threshold); return pokemon.getHpRatio() < 0.25 && !pokemon.getTag(BattlerTagType.CRIT_BOOST); }; case BerryType.STARF: return (pokemon: Pokemon) => { const threshold = new NumberHolder(0.25); - applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold); + applyAbAttrs("ReduceBerryUseThresholdAbAttr", pokemon, null, false, threshold); return pokemon.getHpRatio() < 0.25; }; case BerryType.LEPPA: return (pokemon: Pokemon) => { const threshold = new NumberHolder(0.25); - applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, false, threshold); + applyAbAttrs("ReduceBerryUseThresholdAbAttr", pokemon, null, false, threshold); return !!pokemon.getMoveset().find(m => !m.getPpRatio()); }; } @@ -72,7 +72,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { case BerryType.ENIGMA: { const hpHealed = new NumberHolder(toDmgValue(consumer.getMaxHp() / 4)); - applyAbAttrs(DoubleBerryEffectAbAttr, consumer, null, false, hpHealed); + applyAbAttrs("DoubleBerryEffectAbAttr", consumer, null, false, hpHealed); globalScene.phaseManager.unshiftNew( "PokemonHealPhase", consumer.getBattlerIndex(), @@ -105,7 +105,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { // Offset BerryType such that LIECHI --> Stat.ATK = 1, GANLON --> Stat.DEF = 2, etc etc. const stat: BattleStat = berryType - BerryType.ENIGMA; const statStages = new NumberHolder(1); - applyAbAttrs(DoubleBerryEffectAbAttr, consumer, null, false, statStages); + applyAbAttrs("DoubleBerryEffectAbAttr", consumer, null, false, statStages); globalScene.phaseManager.unshiftNew( "StatStageChangePhase", consumer.getBattlerIndex(), @@ -126,7 +126,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc { { const randStat = randSeedInt(Stat.SPD, Stat.ATK); const stages = new NumberHolder(2); - applyAbAttrs(DoubleBerryEffectAbAttr, consumer, null, false, stages); + applyAbAttrs("DoubleBerryEffectAbAttr", consumer, null, false, stages); globalScene.phaseManager.unshiftNew( "StatStageChangePhase", consumer.getBattlerIndex(), diff --git a/src/data/challenge.ts b/src/data/challenge.ts index 8bdccb6d5fd..683fb48a9ba 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -21,7 +21,7 @@ import { TrainerType } from "#enums/trainer-type"; import { Nature } from "#enums/nature"; import type { MoveId } from "#enums/move-id"; import { TypeColor, TypeShadow } from "#enums/color"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { globalScene } from "#app/global-scene"; import { pokemonFormChanges } from "./pokemon-forms"; import { pokemonEvolutions } from "./balance/pokemon-evolutions"; diff --git a/src/data/data-lists.ts b/src/data/data-lists.ts index c763a001280..4d482dc2d7d 100644 --- a/src/data/data-lists.ts +++ b/src/data/data-lists.ts @@ -1,5 +1,9 @@ -import type { Ability } from "./abilities/ability-class"; +import type { ModifierTypes } from "#app/modifier/modifier-type"; +import type { Ability } from "./abilities/ability"; import type Move from "./moves/move"; export const allAbilities: Ability[] = []; export const allMoves: Move[] = []; + +// TODO: Figure out what this is used for and provide an appropriate tsdoc comment +export const modifierTypes = {} as ModifierTypes; diff --git a/src/data/dialogue.ts b/src/data/dialogue.ts index fa640e92b00..6bb96f0efb2 100644 --- a/src/data/dialogue.ts +++ b/src/data/dialogue.ts @@ -1723,49 +1723,6 @@ export const trainerTypeDialogue: TrainerTypeDialogue = { ], }; -export const doubleBattleDialogue = { - blue_red_double: { - encounter: ["doubleBattleDialogue:blue_red_double.encounter.1"], - victory: ["doubleBattleDialogue:blue_red_double.victory.1"], - }, - red_blue_double: { - encounter: ["doubleBattleDialogue:red_blue_double.encounter.1"], - victory: ["doubleBattleDialogue:red_blue_double.victory.1"], - }, - tate_liza_double: { - encounter: ["doubleBattleDialogue:tate_liza_double.encounter.1"], - victory: ["doubleBattleDialogue:tate_liza_double.victory.1"], - }, - liza_tate_double: { - encounter: ["doubleBattleDialogue:liza_tate_double.encounter.1"], - victory: ["doubleBattleDialogue:liza_tate_double.victory.1"], - }, - wallace_steven_double: { - encounter: ["doubleBattleDialogue:wallace_steven_double.encounter.1"], - victory: ["doubleBattleDialogue:wallace_steven_double.victory.1"], - }, - steven_wallace_double: { - encounter: ["doubleBattleDialogue:steven_wallace_double.encounter.1"], - victory: ["doubleBattleDialogue:steven_wallace_double.victory.1"], - }, - alder_iris_double: { - encounter: ["doubleBattleDialogue:alder_iris_double.encounter.1"], - victory: ["doubleBattleDialogue:alder_iris_double.victory.1"], - }, - iris_alder_double: { - encounter: ["doubleBattleDialogue:iris_alder_double.encounter.1"], - victory: ["doubleBattleDialogue:iris_alder_double.victory.1"], - }, - marnie_piers_double: { - encounter: ["doubleBattleDialogue:marnie_piers_double.encounter.1"], - victory: ["doubleBattleDialogue:marnie_piers_double.victory.1"], - }, - piers_marnie_double: { - encounter: ["doubleBattleDialogue:piers_marnie_double.encounter.1"], - victory: ["doubleBattleDialogue:piers_marnie_double.victory.1"], - }, -}; - export const battleSpecDialogue = { [BattleSpec.FINAL_BOSS]: { encounter: "battleSpecDialogue:encounter", diff --git a/src/data/double-battle-dialogue.ts b/src/data/double-battle-dialogue.ts new file mode 100644 index 00000000000..f15b74e4729 --- /dev/null +++ b/src/data/double-battle-dialogue.ts @@ -0,0 +1,44 @@ +// TODO: Move this back into `dialogue.ts` after finding a suitable way to remove the circular dependencies +// that caused this to be moved out in the first place +export const doubleBattleDialogue = { + blue_red_double: { + encounter: ["doubleBattleDialogue:blue_red_double.encounter.1"], + victory: ["doubleBattleDialogue:blue_red_double.victory.1"], + }, + red_blue_double: { + encounter: ["doubleBattleDialogue:red_blue_double.encounter.1"], + victory: ["doubleBattleDialogue:red_blue_double.victory.1"], + }, + tate_liza_double: { + encounter: ["doubleBattleDialogue:tate_liza_double.encounter.1"], + victory: ["doubleBattleDialogue:tate_liza_double.victory.1"], + }, + liza_tate_double: { + encounter: ["doubleBattleDialogue:liza_tate_double.encounter.1"], + victory: ["doubleBattleDialogue:liza_tate_double.victory.1"], + }, + wallace_steven_double: { + encounter: ["doubleBattleDialogue:wallace_steven_double.encounter.1"], + victory: ["doubleBattleDialogue:wallace_steven_double.victory.1"], + }, + steven_wallace_double: { + encounter: ["doubleBattleDialogue:steven_wallace_double.encounter.1"], + victory: ["doubleBattleDialogue:steven_wallace_double.victory.1"], + }, + alder_iris_double: { + encounter: ["doubleBattleDialogue:alder_iris_double.encounter.1"], + victory: ["doubleBattleDialogue:alder_iris_double.victory.1"], + }, + iris_alder_double: { + encounter: ["doubleBattleDialogue:iris_alder_double.encounter.1"], + victory: ["doubleBattleDialogue:iris_alder_double.victory.1"], + }, + marnie_piers_double: { + encounter: ["doubleBattleDialogue:marnie_piers_double.encounter.1"], + victory: ["doubleBattleDialogue:marnie_piers_double.victory.1"], + }, + piers_marnie_double: { + encounter: ["doubleBattleDialogue:piers_marnie_double.encounter.1"], + victory: ["doubleBattleDialogue:piers_marnie_double.victory.1"], + }, +}; diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index 57660b51391..e713020cf9c 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -33,38 +33,12 @@ import type { ArenaTrapTag } from "../arena-tag"; import { WeakenMoveTypeTag } from "../arena-tag"; import { ArenaTagSide } from "#enums/arena-tag-side"; import { - AllyMoveCategoryPowerBoostAbAttr, applyAbAttrs, applyPostAttackAbAttrs, applyPostItemLostAbAttrs, applyPreAttackAbAttrs, - applyPreDefendAbAttrs, - BlockItemTheftAbAttr, - BlockNonDirectDamageAbAttr, - BlockOneHitKOAbAttr, - BlockRecoilDamageAttr, - ChangeMovePriorityAbAttr, - ConfusionOnStatusEffectAbAttr, - FieldMoveTypePowerBoostAbAttr, - FieldPreventExplosiveMovesAbAttr, - ForceSwitchOutImmunityAbAttr, - HealFromBerryUseAbAttr, - IgnoreContactAbAttr, - IgnoreMoveEffectsAbAttr, - IgnoreProtectOnContactAbAttr, - InfiltratorAbAttr, - MaxMultiHitAbAttr, - MoveAbilityBypassAbAttr, - MoveEffectChanceMultiplierAbAttr, - MoveTypeChangeAbAttr, - PostDamageForceSwitchAbAttr, - PostItemLostAbAttr, - ReflectStatusMoveAbAttr, - ReverseDrainAbAttr, - UserFieldMoveTypePowerBoostAbAttr, - VariableMovePowerAbAttr, - WonderSkinAbAttr, -} from "../abilities/ability"; + applyPreDefendAbAttrs +} from "../abilities/apply-ab-attrs"; import { allAbilities, allMoves } from "../data-lists"; import { AttackTypeBoosterModifier, @@ -77,7 +51,7 @@ import { import type { BattlerIndex } from "#enums/battler-index"; import { BattleType } from "#enums/battle-type"; import { TerrainType } from "../terrain"; -import { ModifierPoolType } from "#app/modifier/modifier-type"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import { Command } from "#enums/command"; import i18next from "i18next"; import type { Localizable } from "#app/@types/locales"; @@ -377,7 +351,7 @@ export default abstract class Move implements Localizable { const bypassed = new BooleanHolder(false); // TODO: Allow this to be simulated - applyAbAttrs(InfiltratorAbAttr, user, null, false, bypassed); + applyAbAttrs("InfiltratorAbAttr", user, null, false, bypassed); return !bypassed.value && !this.hasFlag(MoveFlags.SOUND_BASED) @@ -668,14 +642,14 @@ export default abstract class Move implements Localizable { // special cases below, eg: if the move flag is MAKES_CONTACT, and the user pokemon has an ability that ignores contact (like "Long Reach"), then overrides and move does not make contact switch (flag) { case MoveFlags.MAKES_CONTACT: - if (user.hasAbilityWithAttr(IgnoreContactAbAttr) || this.hitsSubstitute(user, target)) { + if (user.hasAbilityWithAttr("IgnoreContactAbAttr") || this.hitsSubstitute(user, target)) { return false; } break; case MoveFlags.IGNORE_ABILITIES: - if (user.hasAbilityWithAttr(MoveAbilityBypassAbAttr)) { + if (user.hasAbilityWithAttr("MoveAbilityBypassAbAttr")) { const abilityEffectsIgnored = new BooleanHolder(false); - applyAbAttrs(MoveAbilityBypassAbAttr, user, abilityEffectsIgnored, false, this); + applyAbAttrs("MoveAbilityBypassAbAttr", user, abilityEffectsIgnored, false, this); if (abilityEffectsIgnored.value) { return true; } @@ -684,7 +658,7 @@ export default abstract class Move implements Localizable { } return this.hasFlag(MoveFlags.IGNORE_ABILITIES) && !isFollowUp; case MoveFlags.IGNORE_PROTECT: - if (user.hasAbilityWithAttr(IgnoreProtectOnContactAbAttr) + if (user.hasAbilityWithAttr("IgnoreProtectOnContactAbAttr") && this.doesFlagEffectApply({ flag: MoveFlags.MAKES_CONTACT, user })) { return true; } @@ -695,7 +669,7 @@ export default abstract class Move implements Localizable { target?.getTag(SemiInvulnerableTag) || !(target?.getTag(BattlerTagType.MAGIC_COAT) || (!this.doesFlagEffectApply({ flag: MoveFlags.IGNORE_ABILITIES, user, target }) && - target?.hasAbilityWithAttr(ReflectStatusMoveAbAttr))) + target?.hasAbilityWithAttr("ReflectStatusMoveAbAttr"))) ) { return false; } @@ -792,7 +766,7 @@ export default abstract class Move implements Localizable { const moveAccuracy = new NumberHolder(this.accuracy); applyMoveAttrs("VariableAccuracyAttr", user, target, this, moveAccuracy); - applyPreDefendAbAttrs(WonderSkinAbAttr, target, user, this, { value: false }, simulated, moveAccuracy); + applyPreDefendAbAttrs("WonderSkinAbAttr", target, user, this, { value: false }, simulated, moveAccuracy); if (moveAccuracy.value === -1) { return moveAccuracy.value; @@ -835,25 +809,25 @@ export default abstract class Move implements Localizable { const typeChangeMovePowerMultiplier = new NumberHolder(1); const typeChangeHolder = new NumberHolder(this.type); - applyPreAttackAbAttrs(MoveTypeChangeAbAttr, source, target, this, true, typeChangeHolder, typeChangeMovePowerMultiplier); + applyPreAttackAbAttrs("MoveTypeChangeAbAttr", source, target, this, true, typeChangeHolder, typeChangeMovePowerMultiplier); const sourceTeraType = source.getTeraType(); if (source.isTerastallized && sourceTeraType === this.type && power.value < 60 && this.priority <= 0 && !this.hasAttr("MultiHitAttr") && !globalScene.findModifier(m => m instanceof PokemonMultiHitModifier && m.pokemonId === source.id)) { power.value = 60; } - applyPreAttackAbAttrs(VariableMovePowerAbAttr, source, target, this, simulated, power); + applyPreAttackAbAttrs("VariableMovePowerAbAttr", source, target, this, simulated, power); const ally = source.getAlly(); if (!isNullOrUndefined(ally)) { - applyPreAttackAbAttrs(AllyMoveCategoryPowerBoostAbAttr, ally, target, this, simulated, power); + applyPreAttackAbAttrs("AllyMoveCategoryPowerBoostAbAttr", ally, target, this, simulated, power); } const fieldAuras = new Set( globalScene.getField(true) - .map((p) => p.getAbilityAttrs(FieldMoveTypePowerBoostAbAttr).filter(attr => { + .map((p) => p.getAbilityAttrs("FieldMoveTypePowerBoostAbAttr").filter(attr => { const condition = attr.getCondition(); return (!condition || condition(p)); - }) as FieldMoveTypePowerBoostAbAttr[]) + })) .flat(), ); for (const aura of fieldAuras) { @@ -861,7 +835,7 @@ export default abstract class Move implements Localizable { } const alliedField: Pokemon[] = source.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); - alliedField.forEach(p => applyPreAttackAbAttrs(UserFieldMoveTypePowerBoostAbAttr, p, target, this, simulated, power)); + alliedField.forEach(p => applyPreAttackAbAttrs("UserFieldMoveTypePowerBoostAbAttr", p, target, this, simulated, power)); power.value *= typeChangeMovePowerMultiplier.value; @@ -888,7 +862,7 @@ export default abstract class Move implements Localizable { const priority = new NumberHolder(this.priority); applyMoveAttrs("IncrementMovePriorityAttr", user, null, this, priority); - applyAbAttrs(ChangeMovePriorityAbAttr, user, null, simulated, this, priority); + applyAbAttrs("ChangeMovePriorityAbAttr", user, null, simulated, this, priority); return priority.value; } @@ -1340,7 +1314,7 @@ export class MoveEffectAttr extends MoveAttr { getMoveChance(user: Pokemon, target: Pokemon, move: Move, selfEffect?: Boolean, showAbility?: Boolean): number { const moveChance = new NumberHolder(this.effectChanceOverride ?? move.chance); - applyAbAttrs(MoveEffectChanceMultiplierAbAttr, user, null, !showAbility, moveChance, move); + applyAbAttrs("MoveEffectChanceMultiplierAbAttr", user, null, !showAbility, moveChance, move); if ((!move.hasAttr("FlinchAttr") || moveChance.value <= move.chance) && !move.hasAttr("SecretPowerAttr")) { const userSide = user.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY; @@ -1348,7 +1322,7 @@ export class MoveEffectAttr extends MoveAttr { } if (!selfEffect) { - applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, target, user, null, null, !showAbility, moveChance); + applyPreDefendAbAttrs("IgnoreMoveEffectsAbAttr", target, user, null, null, !showAbility, moveChance); } return moveChance.value; } @@ -1726,8 +1700,8 @@ export class RecoilAttr extends MoveEffectAttr { const cancelled = new BooleanHolder(false); if (!this.unblockable) { - applyAbAttrs(BlockRecoilDamageAttr, user, cancelled); - applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); + applyAbAttrs("BlockRecoilDamageAttr", user, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", user, cancelled); } if (cancelled.value) { @@ -1860,7 +1834,7 @@ export class HalfSacrificialAttr extends MoveEffectAttr { const cancelled = new BooleanHolder(false); // Check to see if the Pokemon has an ability that blocks non-direct damage - applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", user, cancelled); if (!cancelled.value) { user.damageAndUpdate(toDmgValue(user.getMaxHp() / 2), { result: HitResult.INDIRECT, ignoreSegments: true }); globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:cutHpPowerUpMove", { pokemonName: getPokemonNameWithAffix(user) })); // Queue recoil message @@ -2059,7 +2033,7 @@ export class FlameBurstAttr extends MoveEffectAttr { const cancelled = new BooleanHolder(false); if (!isNullOrUndefined(targetAlly)) { - applyAbAttrs(BlockNonDirectDamageAbAttr, targetAlly, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", targetAlly, cancelled); } if (cancelled.value || !targetAlly || targetAlly.switchOutStatus) { @@ -2289,7 +2263,7 @@ export class HitHealAttr extends MoveEffectAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { let healAmount = 0; let message = ""; - const reverseDrain = target.hasAbilityWithAttr(ReverseDrainAbAttr, false); + const reverseDrain = target.hasAbilityWithAttr("ReverseDrainAbAttr", false); if (this.healStat !== null) { // Strength Sap formula healAmount = target.getEffectiveStat(this.healStat); @@ -2300,7 +2274,7 @@ export class HitHealAttr extends MoveEffectAttr { message = i18next.t("battle:regainHealth", { pokemonName: getPokemonNameWithAffix(user) }); } if (reverseDrain) { - if (user.hasAbilityWithAttr(BlockNonDirectDamageAbAttr)) { + if (user.hasAbilityWithAttr("BlockNonDirectDamageAbAttr")) { healAmount = 0; message = ""; } else { @@ -2430,7 +2404,7 @@ export class MultiHitAttr extends MoveAttr { { const rand = user.randBattleSeedInt(20); const hitValue = new NumberHolder(rand); - applyAbAttrs(MaxMultiHitAbAttr, user, null, false, hitValue); + applyAbAttrs("MaxMultiHitAbAttr", user, null, false, hitValue); if (hitValue.value >= 13) { return 2; } else if (hitValue.value >= 6) { @@ -2538,7 +2512,7 @@ export class StatusEffectAttr extends MoveEffectAttr { } if (((!pokemon.status || this.overrideStatus) || (pokemon.status.effect === this.effect && moveChance < 0)) && pokemon.trySetStatus(this.effect, true, user, this.turnsRemaining, null, this.overrideStatus, quiet)) { - applyPostAttackAbAttrs(ConfusionOnStatusEffectAbAttr, user, target, move, null, false, this.effect); + applyPostAttackAbAttrs("ConfusionOnStatusEffectAbAttr", user, target, move, null, false, this.effect); return true; } } @@ -2694,7 +2668,7 @@ export class RemoveHeldItemAttr extends MoveEffectAttr { // Check for abilities that block item theft // TODO: This should not trigger if the target would faint beforehand const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); + applyAbAttrs("BlockItemTheftAbAttr", target, cancelled); if (cancelled.value) { return false; @@ -2811,8 +2785,8 @@ export class EatBerryAttr extends MoveEffectAttr { protected eatBerry(consumer: Pokemon, berryOwner: Pokemon = consumer, updateHarvest = consumer === berryOwner) { // consumer eats berry, owner triggers unburden and similar effects getBerryEffectFunc(this.chosenBerry.berryType)(consumer); - applyPostItemLostAbAttrs(PostItemLostAbAttr, berryOwner, false); - applyAbAttrs(HealFromBerryUseAbAttr, consumer, new BooleanHolder(false)); + applyPostItemLostAbAttrs("PostItemLostAbAttr", berryOwner, false); + applyAbAttrs("HealFromBerryUseAbAttr", consumer, new BooleanHolder(false)); consumer.recordEatenBerry(this.chosenBerry.berryType, updateHarvest); } } @@ -2837,7 +2811,7 @@ export class StealEatBerryAttr extends EatBerryAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { // check for abilities that block item theft const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockItemTheftAbAttr, target, cancelled); + applyAbAttrs("BlockItemTheftAbAttr", target, cancelled); if (cancelled.value === true) { return false; } @@ -2851,7 +2825,7 @@ export class StealEatBerryAttr extends EatBerryAttr { // pick a random berry and eat it this.chosenBerry = heldBerries[user.randBattleSeedInt(heldBerries.length)]; - applyPostItemLostAbAttrs(PostItemLostAbAttr, target, false); + applyPostItemLostAbAttrs("PostItemLostAbAttr", target, false); const message = i18next.t("battle:stealEatBerry", { pokemonName: user.name, targetName: target.name, berryName: this.chosenBerry.type.name }); globalScene.phaseManager.queueMessage(message); this.reduceBerryModifier(target); @@ -2892,7 +2866,7 @@ export class HealStatusEffectAttr extends MoveEffectAttr { // Special edge case for shield dust blocking Sparkling Aria curing burn const moveTargets = getMoveTargets(user, move.id); - if (target.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && move.id === MoveId.SPARKLING_ARIA && moveTargets.targets.length === 1) { + if (target.hasAbilityWithAttr("IgnoreMoveEffectsAbAttr") && move.id === MoveId.SPARKLING_ARIA && moveTargets.targets.length === 1) { return false; } @@ -3042,7 +3016,7 @@ export class OneHitKOAttr extends MoveAttr { getCondition(): MoveConditionFunc { return (user, target, move) => { const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockOneHitKOAbAttr, target, cancelled); + applyAbAttrs("BlockOneHitKOAbAttr", target, cancelled); return !cancelled.value && user.level >= target.level; }; } @@ -5442,7 +5416,7 @@ export class NoEffectAttr extends MoveAttr { const crashDamageFunc = (user: Pokemon, move: Move) => { const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, user, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", user, cancelled); if (cancelled.value) { return false; } @@ -6302,7 +6276,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { * Check if Wimp Out/Emergency Exit activates due to being hit by U-turn or Volt Switch * If it did, the user of U-turn or Volt Switch will not be switched out. */ - if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) + if (target.getAbility().hasAttr("PostDamageForceSwitchAbAttr") && [ MoveId.U_TURN, MoveId.VOLT_SWITCH, MoveId.FLIP_TURN ].includes(move.id) ) { if (this.hpDroppedBelowHalf(target)) { @@ -6391,7 +6365,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { * Check if Wimp Out/Emergency Exit activates due to being hit by U-turn or Volt Switch * If it did, the user of U-turn or Volt Switch will not be switched out. */ - if (target.getAbility().hasAttr(PostDamageForceSwitchAbAttr) + if (target.getAbility().hasAttr("PostDamageForceSwitchAbAttr") && [ MoveId.U_TURN, MoveId.VOLT_SWITCH, MoveId.FLIP_TURN ].includes(move.id) ) { if (this.hpDroppedBelowHalf(target)) { @@ -6434,7 +6408,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { getFailedText(_user: Pokemon, target: Pokemon, _move: Move): string | undefined { const blockedByAbility = new BooleanHolder(false); - applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, blockedByAbility); + applyAbAttrs("ForceSwitchOutImmunityAbAttr", target, blockedByAbility); if (blockedByAbility.value) { return i18next.t("moveTriggers:cannotBeSwitchedOut", { pokemonName: getPokemonNameWithAffix(target) }); } @@ -6474,7 +6448,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr { } const blockedByAbility = new BooleanHolder(false); - applyAbAttrs(ForceSwitchOutImmunityAbAttr, target, blockedByAbility); + applyAbAttrs("ForceSwitchOutImmunityAbAttr", target, blockedByAbility); if (blockedByAbility.value) { return false; } @@ -7981,7 +7955,7 @@ const failIfSingleBattle: MoveConditionFunc = (user, target, move) => globalScen const failIfDampCondition: MoveConditionFunc = (user, target, move) => { const cancelled = new BooleanHolder(false); - globalScene.getField(true).map(p=>applyAbAttrs(FieldPreventExplosiveMovesAbAttr, p, cancelled)); + globalScene.getField(true).map(p=>applyAbAttrs("FieldPreventExplosiveMovesAbAttr", p, cancelled)); // Queue a message if an ability prevented usage of the move if (cancelled.value) { globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:cannotUseMove", { pokemonName: getPokemonNameWithAffix(user), moveName: move.name })); diff --git a/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts b/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts index 11081892205..7a1c9821e89 100644 --- a/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts +++ b/src/data/mystery-encounters/encounters/a-trainers-test-encounter.ts @@ -19,8 +19,8 @@ import i18next from "i18next"; import type { IEggOptions } from "#app/data/egg"; import { EggSourceType } from "#enums/egg-source-types"; import { EggTier } from "#enums/egg-type"; -import { ModifierTier } from "#app/modifier/modifier-tier"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { ModifierTier } from "#enums/modifier-tier"; +import { modifierTypes } from "#app/data/data-lists"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants"; /** the i18n namespace for the encounter */ diff --git a/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts b/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts index 2213dc4afaa..3eda96e4028 100644 --- a/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts +++ b/src/data/mystery-encounters/encounters/absolute-avarice-encounter.ts @@ -10,7 +10,7 @@ import type Pokemon from "#app/field/pokemon"; import { EnemyPokemon } from "#app/field/pokemon"; import { PokemonMove } from "#app/data/moves/pokemon-move"; import type { BerryModifierType, PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { SpeciesId } from "#enums/species-id"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/an-offer-you-cant-refuse-encounter.ts b/src/data/mystery-encounters/encounters/an-offer-you-cant-refuse-encounter.ts index cdb98c56ed1..271346616d1 100644 --- a/src/data/mystery-encounters/encounters/an-offer-you-cant-refuse-encounter.ts +++ b/src/data/mystery-encounters/encounters/an-offer-you-cant-refuse-encounter.ts @@ -4,7 +4,7 @@ import { setEncounterExp, updatePlayerMoney, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { SpeciesId } from "#enums/species-id"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/berries-abound-encounter.ts b/src/data/mystery-encounters/encounters/berries-abound-encounter.ts index 65ae3ea6c4f..d86a8439804 100644 --- a/src/data/mystery-encounters/encounters/berries-abound-encounter.ts +++ b/src/data/mystery-encounters/encounters/berries-abound-encounter.ts @@ -12,7 +12,9 @@ import { import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; import type { BerryModifierType, ModifierTypeOption } from "#app/modifier/modifier-type"; -import { ModifierPoolType, modifierTypes, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; +import { regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import { randSeedInt } from "#app/utils/common"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; diff --git a/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts b/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts index c318efc0cb3..df06f40c159 100644 --- a/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts +++ b/src/data/mystery-encounters/encounters/bug-type-superfan-encounter.ts @@ -38,7 +38,7 @@ import { } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { PokemonType } from "#enums/pokemon-type"; import type { AttackTypeBoosterModifierType, ModifierTypeOption } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import type { PokemonHeldItemModifier } from "#app/modifier/modifier"; import { AttackTypeBoosterModifier, @@ -50,7 +50,7 @@ import { import i18next from "i18next"; import MoveInfoOverlay from "#app/ui/move-info-overlay"; import { allMoves } from "#app/data/data-lists"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants"; import { getSpriteKeysFromSpecies } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; diff --git a/src/data/mystery-encounters/encounters/clowning-around-encounter.ts b/src/data/mystery-encounters/encounters/clowning-around-encounter.ts index a81dcc841b7..542bd163713 100644 --- a/src/data/mystery-encounters/encounters/clowning-around-encounter.ts +++ b/src/data/mystery-encounters/encounters/clowning-around-encounter.ts @@ -11,9 +11,10 @@ import { import { trainerConfigs } from "#app/data/trainers/trainer-config"; import { TrainerPartyCompoundTemplate } from "#app/data/trainers/TrainerPartyTemplate"; import { TrainerPartyTemplate } from "#app/data/trainers/TrainerPartyTemplate"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { ModifierPoolType, modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { PartyMemberStrength } from "#enums/party-member-strength"; import { globalScene } from "#app/global-scene"; @@ -38,7 +39,6 @@ import i18next from "i18next"; import type { OptionSelectConfig } from "#app/ui/abstact-option-select-ui-handler"; import type { PlayerPokemon } from "#app/field/pokemon"; import { PokemonMove } from "#app/data/moves/pokemon-move"; -import { Ability } from "#app/data/abilities/ability-class"; import { BerryModifier } from "#app/modifier/modifier"; import { BerryType } from "#enums/berry-type"; import { BattlerIndex } from "#enums/battler-index"; @@ -49,6 +49,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 { allAbilities } from "#app/data/data-lists"; /** the i18n namespace for the encounter */ const namespace = "mysteryEncounters/clowningAround"; @@ -139,7 +140,7 @@ export const ClowningAroundEncounter: MysteryEncounter = MysteryEncounterBuilder // Generate random ability for Blacephalon from pool const ability = RANDOM_ABILITY_POOL[randSeedInt(RANDOM_ABILITY_POOL.length)]; - encounter.setDialogueToken("ability", new Ability(ability, 3).name); + encounter.setDialogueToken("ability", allAbilities[ability].name); encounter.misc = { ability }; // Decide the random types for Blacephalon. They should not be the same. diff --git a/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts b/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts index a74980919d6..4444a2e6b1b 100644 --- a/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts +++ b/src/data/mystery-encounters/encounters/dancing-lessons-encounter.ts @@ -26,7 +26,7 @@ import type Pokemon from "#app/field/pokemon"; import { EnemyPokemon } from "#app/field/pokemon"; import { PokemonMove } from "#app/data/moves/pokemon-move"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import PokemonData from "#app/system/pokemon-data"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { BattlerTagType } from "#enums/battler-tag-type"; diff --git a/src/data/mystery-encounters/encounters/dark-deal-encounter.ts b/src/data/mystery-encounters/encounters/dark-deal-encounter.ts index 6474df3570e..002b38f445d 100644 --- a/src/data/mystery-encounters/encounters/dark-deal-encounter.ts +++ b/src/data/mystery-encounters/encounters/dark-deal-encounter.ts @@ -3,7 +3,7 @@ import { isNullOrUndefined, randSeedInt } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { SpeciesId } from "#enums/species-id"; import { globalScene } from "#app/global-scene"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; import { MysteryEncounterBuilder } from "#app/data/mystery-encounters/mystery-encounter"; diff --git a/src/data/mystery-encounters/encounters/delibirdy-encounter.ts b/src/data/mystery-encounters/encounters/delibirdy-encounter.ts index 40893d93930..692ffe6e80e 100644 --- a/src/data/mystery-encounters/encounters/delibirdy-encounter.ts +++ b/src/data/mystery-encounters/encounters/delibirdy-encounter.ts @@ -28,7 +28,7 @@ import { PreserveBerryModifier, } from "#app/modifier/modifier"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import i18next from "#app/plugins/i18n"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { randSeedItem } from "#app/utils/common"; diff --git a/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts b/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts index 2b6ac9b7cf3..46152a7dc41 100644 --- a/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts +++ b/src/data/mystery-encounters/encounters/department-store-sale-encounter.ts @@ -2,8 +2,8 @@ import { leaveEncounterWithoutBattle, setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import type { ModifierTypeFunc } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import type { ModifierTypeFunc } from "#app/@types/modifier-types"; +import { modifierTypes } from "#app/data/data-lists"; import { randSeedInt } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { SpeciesId } from "#enums/species-id"; diff --git a/src/data/mystery-encounters/encounters/field-trip-encounter.ts b/src/data/mystery-encounters/encounters/field-trip-encounter.ts index 82fbfd51eec..6ab0f8a6a4b 100644 --- a/src/data/mystery-encounters/encounters/field-trip-encounter.ts +++ b/src/data/mystery-encounters/encounters/field-trip-encounter.ts @@ -9,7 +9,7 @@ import { } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PlayerPokemon } from "#app/field/pokemon"; import type { PokemonMove } from "#app/data/moves/pokemon-move"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import type { OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts b/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts index d42778cb17c..4b24bf9cada 100644 --- a/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts +++ b/src/data/mystery-encounters/encounters/fiery-fallout-encounter.ts @@ -10,7 +10,7 @@ import { generateModifierType, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; @@ -45,8 +45,8 @@ import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { Stat } from "#enums/stat"; -import { Ability } from "#app/data/abilities/ability-class"; import { FIRE_RESISTANT_ABILITIES } from "#app/data/mystery-encounters/requirements/requirement-groups"; +import { allAbilities } from "#app/data/data-lists"; /** the i18n namespace for the encounter */ const namespace = "mysteryEncounters/fieryFallout"; @@ -246,7 +246,7 @@ export const FieryFalloutEncounter: MysteryEncounter = MysteryEncounterBuilder.w if (chosenPokemon.trySetStatus(StatusEffect.BURN)) { // Burn applied encounter.setDialogueToken("burnedPokemon", chosenPokemon.getNameToRender()); - encounter.setDialogueToken("abilityName", new Ability(AbilityId.HEATPROOF, 3).name); + encounter.setDialogueToken("abilityName", allAbilities[AbilityId.HEATPROOF].name); queueEncounterMessage(`${namespace}:option.2.target_burned`); // Also permanently change the burned Pokemon's ability to Heatproof diff --git a/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts b/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts index 83538e9e0e9..f925452e143 100644 --- a/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts +++ b/src/data/mystery-encounters/encounters/fight-or-flight-encounter.ts @@ -9,13 +9,13 @@ import { } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { STEALING_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups"; import type Pokemon from "#app/field/pokemon"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import type { ModifierTypeOption } from "#app/modifier/modifier-type"; import { getPlayerModifierTypeOptions, - ModifierPoolType, regenerateModifierPoolThresholds, } from "#app/modifier/modifier-type"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; diff --git a/src/data/mystery-encounters/encounters/fun-and-games-encounter.ts b/src/data/mystery-encounters/encounters/fun-and-games-encounter.ts index 456562ca70e..48557541512 100644 --- a/src/data/mystery-encounters/encounters/fun-and-games-encounter.ts +++ b/src/data/mystery-encounters/encounters/fun-and-games-encounter.ts @@ -26,7 +26,7 @@ import { PlayerGender } from "#enums/player-gender"; import { getPokeballAtlasKey, getPokeballTintColor } from "#app/data/pokeball"; import { addPokeballOpenParticles } from "#app/field/anims"; import { SpeciesFormChangeActiveTrigger } from "#app/data/pokemon-forms/form-change-triggers"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { Nature } from "#enums/nature"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants"; import { isPokemonValidForEncounterOptionSelection } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; diff --git a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts index a84b0af30ed..1b188915de7 100644 --- a/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts +++ b/src/data/mystery-encounters/encounters/global-trade-system-encounter.ts @@ -4,14 +4,14 @@ import { setEncounterRewards, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { TrainerSlot } from "#enums/trainer-slot"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { MusicPreference } from "#app/system/settings/settings"; import type { ModifierTypeOption } from "#app/modifier/modifier-type"; import { getPlayerModifierTypeOptions, - ModifierPoolType, regenerateModifierPoolThresholds, } from "#app/modifier/modifier-type"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; diff --git a/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts b/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts index 6907e18cfdc..010358ea3b2 100644 --- a/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts +++ b/src/data/mystery-encounters/encounters/mysterious-challengers-encounter.ts @@ -7,8 +7,8 @@ import { trainerConfigs } from "#app/data/trainers/trainer-config"; import { trainerPartyTemplates } from "#app/data/trainers/TrainerPartyTemplate"; import { TrainerPartyCompoundTemplate } from "#app/data/trainers/TrainerPartyTemplate"; import { TrainerPartyTemplate } from "#app/data/trainers/TrainerPartyTemplate"; -import { ModifierTier } from "#app/modifier/modifier-tier"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { ModifierTier } from "#enums/modifier-tier"; +import { modifierTypes } from "#app/data/data-lists"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { PartyMemberStrength } from "#enums/party-member-strength"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts b/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts index 62029eb1847..022b0125fde 100644 --- a/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts +++ b/src/data/mystery-encounters/encounters/mysterious-chest-encounter.ts @@ -16,7 +16,7 @@ import { } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { randSeedInt } from "#app/utils/common"; import { MoveId } from "#enums/move-id"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; diff --git a/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts b/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts index 1afc67e1d12..967c105c740 100644 --- a/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts +++ b/src/data/mystery-encounters/encounters/shady-vitamin-dealer-encounter.ts @@ -7,7 +7,7 @@ import { } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PlayerPokemon } from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { randSeedInt } from "#app/utils/common"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { SpeciesId } from "#enums/species-id"; diff --git a/src/data/mystery-encounters/encounters/slumbering-snorlax-encounter.ts b/src/data/mystery-encounters/encounters/slumbering-snorlax-encounter.ts index 1ecd73143fc..483c577e851 100644 --- a/src/data/mystery-encounters/encounters/slumbering-snorlax-encounter.ts +++ b/src/data/mystery-encounters/encounters/slumbering-snorlax-encounter.ts @@ -1,6 +1,6 @@ import { STEALING_MOVES } from "#app/data/mystery-encounters/requirements/requirement-groups"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { SpeciesId } from "#enums/species-id"; import { globalScene } from "#app/global-scene"; diff --git a/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts b/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts index edc9cf13834..9c9232612c6 100644 --- a/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts +++ b/src/data/mystery-encounters/encounters/teleporting-hijinks-encounter.ts @@ -23,7 +23,8 @@ import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode import { BiomeId } from "#enums/biome-id"; import { getBiomeKey } from "#app/field/arena"; import { PokemonType } from "#enums/pokemon-type"; -import { getPartyLuckValue, modifierTypes } from "#app/modifier/modifier-type"; +import { getPartyLuckValue } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { TrainerSlot } from "#enums/trainer-slot"; import { BattlerTagType } from "#enums/battler-tag-type"; import { getPokemonNameWithAffix } from "#app/messages"; diff --git a/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts b/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts index fdfcc8f2f13..0676b40c548 100644 --- a/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter.ts @@ -26,7 +26,7 @@ import { EggSourceType } from "#enums/egg-source-types"; import { EggTier } from "#enums/egg-type"; import { MysteryEncounterOptionBuilder } from "#app/data/mystery-encounters/mystery-encounter-option"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { PokemonType } from "#enums/pokemon-type"; import { getPokeballTintColor } from "#app/data/pokeball"; diff --git a/src/data/mystery-encounters/encounters/the-strong-stuff-encounter.ts b/src/data/mystery-encounters/encounters/the-strong-stuff-encounter.ts index a3eb78f479e..61d9dcfccfd 100644 --- a/src/data/mystery-encounters/encounters/the-strong-stuff-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-strong-stuff-encounter.ts @@ -8,7 +8,7 @@ import { generateModifierType, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; diff --git a/src/data/mystery-encounters/encounters/the-winstrate-challenge-encounter.ts b/src/data/mystery-encounters/encounters/the-winstrate-challenge-encounter.ts index 91754629821..e2c87d8c0ae 100644 --- a/src/data/mystery-encounters/encounters/the-winstrate-challenge-encounter.ts +++ b/src/data/mystery-encounters/encounters/the-winstrate-challenge-encounter.ts @@ -8,7 +8,7 @@ import { transitionMysteryEncounterIntroVisuals, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; @@ -24,11 +24,11 @@ import { PokemonType } from "#enums/pokemon-type"; import { BerryType } from "#enums/berry-type"; import { Stat } from "#enums/stat"; import { SpeciesFormChangeAbilityTrigger } from "#app/data/pokemon-forms/form-change-triggers"; -import { applyPostBattleInitAbAttrs, PostBattleInitAbAttr } from "#app/data/abilities/ability"; +import { applyPostBattleInitAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { showEncounterDialogue, showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; import i18next from "i18next"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES } from "#app/constants"; import { BattlerTagType } from "#enums/battler-tag-type"; @@ -221,7 +221,7 @@ function endTrainerBattleAndShowDialogue(): Promise { // Each trainer battle is supposed to be a new fight, so reset all per-battle activation effects pokemon.resetBattleAndWaveData(); - applyPostBattleInitAbAttrs(PostBattleInitAbAttr, pokemon); + applyPostBattleInitAbAttrs("PostBattleInitAbAttr", pokemon); } globalScene.phaseManager.unshiftNew("ShowTrainerPhase"); diff --git a/src/data/mystery-encounters/encounters/training-session-encounter.ts b/src/data/mystery-encounters/encounters/training-session-encounter.ts index 9ab91f439bf..04e64083602 100644 --- a/src/data/mystery-encounters/encounters/training-session-encounter.ts +++ b/src/data/mystery-encounters/encounters/training-session-encounter.ts @@ -1,4 +1,4 @@ -import type { Ability } from "#app/data/abilities/ability-class"; +import type { Ability } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { diff --git a/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts b/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts index 8bcd024de5c..1416c63dd28 100644 --- a/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts +++ b/src/data/mystery-encounters/encounters/trash-to-treasure-encounter.ts @@ -8,7 +8,7 @@ import { transitionMysteryEncounterIntroVisuals, } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { MysteryEncounterType } from "#enums/mystery-encounter-type"; import { globalScene } from "#app/global-scene"; import type MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter"; @@ -21,7 +21,7 @@ import { HitHealModifier, PokemonHeldItemModifier, TurnHealModifier } from "#app import { applyModifierTypeToPlayerPokemon } from "#app/data/mystery-encounters/utils/encounter-pokemon-utils"; import { showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import i18next from "#app/plugins/i18n"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { MoveId } from "#enums/move-id"; import { BattlerIndex } from "#enums/battler-index"; diff --git a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts index fe1911c9007..83e876d1aa8 100644 --- a/src/data/mystery-encounters/encounters/weird-dream-encounter.ts +++ b/src/data/mystery-encounters/encounters/weird-dream-encounter.ts @@ -25,7 +25,7 @@ import { HiddenAbilityRateBoosterModifier, PokemonFormChangeItemModifier } from import { achvs } from "#app/system/achv"; import { showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import i18next from "#app/plugins/i18n"; import { doPokemonTransformationSequence, @@ -34,7 +34,7 @@ import { import { getLevelTotalExp } from "#app/data/exp"; import { Stat } from "#enums/stat"; import { Challenges } from "#enums/challenges"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { PlayerGender } from "#enums/player-gender"; import { TrainerType } from "#enums/trainer-type"; import PokemonData from "#app/system/pokemon-data"; diff --git a/src/data/mystery-encounters/mystery-encounter-save-data.ts b/src/data/mystery-encounters/mystery-encounter-save-data.ts index dd633390e46..20c10c7c5b9 100644 --- a/src/data/mystery-encounters/mystery-encounter-save-data.ts +++ b/src/data/mystery-encounters/mystery-encounter-save-data.ts @@ -1,5 +1,5 @@ import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; -import { BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT } from "#app/data/mystery-encounters/mystery-encounters"; +import { BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT } from "#app/constants"; import { isNullOrUndefined } from "#app/utils/common"; import type { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; diff --git a/src/data/mystery-encounters/mystery-encounters.ts b/src/data/mystery-encounters/mystery-encounters.ts index 3a1d3760c83..5ee289a6c56 100644 --- a/src/data/mystery-encounters/mystery-encounters.ts +++ b/src/data/mystery-encounters/mystery-encounters.ts @@ -34,42 +34,6 @@ import { GlobalTradeSystemEncounter } from "#app/data/mystery-encounters/encount import { TheExpertPokemonBreederEncounter } from "#app/data/mystery-encounters/encounters/the-expert-pokemon-breeder-encounter"; import { getBiomeName } from "#app/data/balance/biomes"; -/** - * Spawn chance: (BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT + WIGHT_INCREMENT_ON_SPAWN_MISS * ) / MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT - */ -export const BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT = 3; -/** - * The divisor for determining ME spawns, defines the "maximum" weight required for a spawn - * If spawn_weight === MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT, 100% chance to spawn a ME - */ -export const MYSTERY_ENCOUNTER_SPAWN_MAX_WEIGHT = 256; -/** - * When an ME spawn roll fails, WEIGHT_INCREMENT_ON_SPAWN_MISS is added to future rolls for ME spawn checks. - * These values are cleared whenever the next ME spawns, and spawn weight returns to BASE_MYSTERY_ENCOUNTER_SPAWN_WEIGHT - */ -export const WEIGHT_INCREMENT_ON_SPAWN_MISS = 3; -/** - * Specifies the target average for total ME spawns in a single Classic run. - * Used by anti-variance mechanic to check whether a run is above or below the target on a given wave. - */ -export const AVERAGE_ENCOUNTERS_PER_RUN_TARGET = 12; -/** - * Will increase/decrease the chance of spawning a ME based on the current run's total MEs encountered vs AVERAGE_ENCOUNTERS_PER_RUN_TARGET - * Example: - * AVERAGE_ENCOUNTERS_PER_RUN_TARGET = 17 (expects avg 1 ME every 10 floors) - * ANTI_VARIANCE_WEIGHT_MODIFIER = 15 - * - * On wave 20, if 1 ME has been encountered, the difference from expected average is 0 MEs. - * So anti-variance adds 0/256 to the spawn weight check for ME spawn. - * - * On wave 20, if 0 MEs have been encountered, the difference from expected average is 1 ME. - * So anti-variance adds 15/256 to the spawn weight check for ME spawn. - * - * On wave 20, if 2 MEs have been encountered, the difference from expected average is -1 ME. - * So anti-variance adds -15/256 to the spawn weight check for ME spawn. - */ -export const ANTI_VARIANCE_WEIGHT_MODIFIER = 15; - export const EXTREME_ENCOUNTER_BIOMES = [ BiomeId.SEA, BiomeId.SEABED, diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 69984229681..599edb11628 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -3,10 +3,7 @@ import { BattlerIndex } from "#enums/battler-index"; import { BattleType } from "#enums/battle-type"; import { biomeLinks, BiomePoolTier } from "#app/data/balance/biomes"; import type MysteryEncounterOption from "#app/data/mystery-encounters/mystery-encounter-option"; -import { - AVERAGE_ENCOUNTERS_PER_RUN_TARGET, - WEIGHT_INCREMENT_ON_SPAWN_MISS, -} from "#app/data/mystery-encounters/mystery-encounters"; +import { AVERAGE_ENCOUNTERS_PER_RUN_TARGET, WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/constants"; import { showEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import type { PlayerPokemon } from "#app/field/pokemon"; import type { AiType } from "#enums/ai-type"; @@ -17,12 +14,12 @@ import { FieldPosition } from "#enums/field-position"; import type { CustomModifierSettings, ModifierType } from "#app/modifier/modifier-type"; import { getPartyLuckValue, - ModifierPoolType, ModifierTypeGenerator, ModifierTypeOption, - modifierTypes, regenerateModifierPoolThresholds, } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import type PokemonData from "#app/system/pokemon-data"; import type { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import type { PartyOption, PokemonSelectFilter } from "#app/ui/party-ui-handler"; diff --git a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts index e8a3db46cff..4671869a2ba 100644 --- a/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-pokemon-utils.ts @@ -29,7 +29,7 @@ import { } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; import { getPokemonNameWithAffix } from "#app/messages"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { Gender } from "#app/data/gender"; import type { PermanentStat } from "#enums/stat"; import { SummaryUiMode } from "#app/ui/summary-ui-handler"; diff --git a/src/data/pokeball.ts b/src/data/pokeball.ts index 7a44ebdda7c..a479fd8068a 100644 --- a/src/data/pokeball.ts +++ b/src/data/pokeball.ts @@ -1,5 +1,4 @@ import { globalScene } from "#app/global-scene"; -import { CriticalCatchChanceBoosterModifier } from "#app/modifier/modifier"; import { NumberHolder } from "#app/utils/common"; import { PokeballType } from "#enums/pokeball"; import i18next from "i18next"; @@ -94,7 +93,7 @@ export function getCriticalCaptureChance(modifiedCatchRate: number): number { } const dexCount = globalScene.gameData.getSpeciesCount(d => !!d.caughtAttr); const catchingCharmMultiplier = new NumberHolder(1); - globalScene.findModifier(m => m instanceof CriticalCatchChanceBoosterModifier)?.apply(catchingCharmMultiplier); + globalScene.findModifier(m => m.is("CriticalCatchChanceBoosterModifier"))?.apply(catchingCharmMultiplier); const dexMultiplier = globalScene.gameMode.isDaily || dexCount > 800 ? 2.5 diff --git a/src/data/trainers/trainer-config.ts b/src/data/trainers/trainer-config.ts index 2f1f7ed07a8..8c065666202 100644 --- a/src/data/trainers/trainer-config.ts +++ b/src/data/trainers/trainer-config.ts @@ -1,11 +1,11 @@ import { globalScene } from "#app/global-scene"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "../data-lists"; import { PokemonMove } from "../moves/pokemon-move"; import { toReadableString, isNullOrUndefined, randSeedItem, randSeedInt, randSeedIntRange } from "#app/utils/common"; import { pokemonEvolutions, pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { tmSpecies } from "#app/data/balance/tms"; -import { doubleBattleDialogue } from "#app/data/dialogue"; +import { doubleBattleDialogue } from "../double-battle-dialogue"; import { TrainerVariant } from "#enums/trainer-variant"; import { getIsInitialized, initI18n } from "#app/plugins/i18n"; import i18next from "i18next"; @@ -37,7 +37,7 @@ import { timedEventManager } from "#app/global-event-manager"; // Type imports import type { PokemonSpeciesFilter } from "#app/data/pokemon-species"; import type PokemonSpecies from "#app/data/pokemon-species"; -import type { ModifierTypeFunc } from "#app/modifier/modifier-type"; +import type { ModifierTypeFunc } from "#app/@types/modifier-types"; import type { EnemyPokemon } from "#app/field/pokemon"; import type { EvilTeam } from "./evil-admin-trainer-pools"; import type { diff --git a/src/data/weather.ts b/src/data/weather.ts index 822e5aa8303..425e15b12a8 100644 --- a/src/data/weather.ts +++ b/src/data/weather.ts @@ -5,12 +5,12 @@ import type Pokemon from "../field/pokemon"; import { PokemonType } from "#enums/pokemon-type"; import type Move from "./moves/move"; import { randSeedInt } from "#app/utils/common"; -import { SuppressWeatherEffectAbAttr } from "./abilities/ability"; import { TerrainType, getTerrainName } from "./terrain"; import i18next from "i18next"; import { globalScene } from "#app/global-scene"; import type { Arena } from "#app/field/arena"; import { timedEventManager } from "#app/global-event-manager"; +import type { SuppressWeatherEffectAbAttr } from "./abilities/ability"; export class Weather { public weatherType: WeatherType; @@ -108,10 +108,10 @@ export class Weather { for (const pokemon of field) { let suppressWeatherEffectAbAttr: SuppressWeatherEffectAbAttr | null = pokemon .getAbility() - .getAttrs(SuppressWeatherEffectAbAttr)[0]; + .getAttrs("SuppressWeatherEffectAbAttr")[0]; if (!suppressWeatherEffectAbAttr) { suppressWeatherEffectAbAttr = pokemon.hasPassive() - ? pokemon.getPassiveAbility().getAttrs(SuppressWeatherEffectAbAttr)[0] + ? pokemon.getPassiveAbility().getAttrs("SuppressWeatherEffectAbAttr")[0] : null; } if (suppressWeatherEffectAbAttr && (!this.isImmutable() || suppressWeatherEffectAbAttr.affectsImmutable)) { diff --git a/src/enums/modifier-pool-type.ts b/src/enums/modifier-pool-type.ts new file mode 100644 index 00000000000..0d2b92ba80d --- /dev/null +++ b/src/enums/modifier-pool-type.ts @@ -0,0 +1,7 @@ +export enum ModifierPoolType { + PLAYER, + WILD, + TRAINER, + ENEMY_BUFF, + DAILY_STARTER +} diff --git a/src/modifier/modifier-tier.ts b/src/enums/modifier-tier.ts similarity index 100% rename from src/modifier/modifier-tier.ts rename to src/enums/modifier-tier.ts diff --git a/src/enums/unlockables.ts b/src/enums/unlockables.ts new file mode 100644 index 00000000000..77b39a17e90 --- /dev/null +++ b/src/enums/unlockables.ts @@ -0,0 +1,7 @@ + +export enum Unlockables { + ENDLESS_MODE, + MINI_BLACK_HOLE, + SPLICED_ENDLESS_MODE, + EVIOLITE +} diff --git a/src/field/arena.ts b/src/field/arena.ts index fffbf8dfa26..c77c9a5b3ce 100644 --- a/src/field/arena.ts +++ b/src/field/arena.ts @@ -24,10 +24,7 @@ import { applyAbAttrs, applyPostTerrainChangeAbAttrs, applyPostWeatherChangeAbAttrs, - PostTerrainChangeAbAttr, - PostWeatherChangeAbAttr, - TerrainEventTypeChangeAbAttr, -} from "#app/data/abilities/ability"; +} from "#app/data/abilities/apply-ab-attrs"; import type Pokemon from "#app/field/pokemon"; import Overrides from "#app/overrides"; import { TagAddedEvent, TagRemovedEvent, TerrainChangedEvent, WeatherChangedEvent } from "#app/events/arena"; @@ -374,7 +371,7 @@ export class Arena { pokemon.findAndRemoveTags( t => "weatherTypes" in t && !(t.weatherTypes as WeatherType[]).find(t => t === weather), ); - applyPostWeatherChangeAbAttrs(PostWeatherChangeAbAttr, pokemon, weather); + applyPostWeatherChangeAbAttrs("PostWeatherChangeAbAttr", pokemon, weather); }); return true; @@ -463,8 +460,8 @@ export class Arena { pokemon.findAndRemoveTags( t => "terrainTypes" in t && !(t.terrainTypes as TerrainType[]).find(t => t === terrain), ); - applyPostTerrainChangeAbAttrs(PostTerrainChangeAbAttr, pokemon, terrain); - applyAbAttrs(TerrainEventTypeChangeAbAttr, pokemon, null, false); + applyPostTerrainChangeAbAttrs("PostTerrainChangeAbAttr", pokemon, terrain); + applyAbAttrs("TerrainEventTypeChangeAbAttr", pokemon, null, false); }); return true; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 7032cd06131..6a34d936a51 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -111,61 +111,23 @@ import { WeatherType } from "#enums/weather-type"; import { NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag"; import { ArenaTagSide } from "#enums/arena-tag-side"; import type { SuppressAbilitiesTag } from "#app/data/arena-tag"; -import type { Ability } from "#app/data/abilities/ability-class"; -import type { AbAttr } from "#app/data/abilities/ab-attrs/ab-attr"; +import type { Ability } from "#app/data/abilities/ability"; import { - StatMultiplierAbAttr, - BlockCritAbAttr, - BonusCritAbAttr, - BypassBurnDamageReductionAbAttr, - FieldPriorityMoveImmunityAbAttr, - IgnoreOpponentStatStagesAbAttr, - MoveImmunityAbAttr, - PreDefendFullHpEndureAbAttr, - ReceivedMoveDamageMultiplierAbAttr, - StabBoostAbAttr, - StatusEffectImmunityAbAttr, - TypeImmunityAbAttr, - WeightMultiplierAbAttr, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, - NoFusionAbilityAbAttr, - MultCritAbAttr, - IgnoreTypeImmunityAbAttr, - DamageBoostAbAttr, - IgnoreTypeStatusEffectImmunityAbAttr, - ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, - FieldMultiplyStatAbAttr, - AddSecondStrikeAbAttr, - UserFieldStatusEffectImmunityAbAttr, - UserFieldBattlerTagImmunityAbAttr, - BattlerTagImmunityAbAttr, - MoveTypeChangeAbAttr, - FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, - CheckTrappedAbAttr, - InfiltratorAbAttr, - AlliedFieldDamageReductionAbAttr, - PostDamageAbAttr, applyPostDamageAbAttrs, - CommanderAbAttr, applyPostItemLostAbAttrs, - PostItemLostAbAttr, applyOnGainAbAttrs, - PreLeaveFieldAbAttr, applyPreLeaveFieldAbAttrs, applyOnLoseAbAttrs, - PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, applyAllyStatMultiplierAbAttrs, - AllyStatMultiplierAbAttr, - MoveAbilityBypassAbAttr, - PreSummonAbAttr, -} from "#app/data/abilities/ability"; +} from "#app/data/abilities/apply-ab-attrs"; import { allAbilities } from "#app/data/data-lists"; import type PokemonData from "#app/system/pokemon-data"; import { BattlerIndex } from "#enums/battler-index"; @@ -192,7 +154,7 @@ import type { TrainerSlot } from "#enums/trainer-slot"; import Overrides from "#app/overrides"; import i18next from "i18next"; import { speciesEggMoves } from "#app/data/balance/egg-moves"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { applyChallenges } from "#app/data/challenge"; import { ChallengeType } from "#enums/challenge-type"; import { AbilityId } from "#enums/ability-id"; @@ -229,6 +191,7 @@ import { HitResult } from "#enums/hit-result"; import { AiType } from "#enums/ai-type"; import type { MoveResult } from "#enums/move-result"; import { PokemonMove } from "#app/data/moves/pokemon-move"; +import type { AbAttrMap, AbAttrString } from "#app/@types/ability-types"; /** Base typeclass for damage parameter methods, used for DRY */ type damageParams = { @@ -1403,7 +1366,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { applyMoveAttrs("HighCritAttr", source, this, move, critStage); globalScene.applyModifiers(CritBoosterModifier, source.isPlayer(), source, critStage); globalScene.applyModifiers(TempCritBoosterModifier, source.isPlayer(), critStage); - applyAbAttrs(BonusCritAbAttr, source, null, false, critStage); + applyAbAttrs("BonusCritAbAttr", source, null, false, critStage); const critBoostTag = source.getTag(CritBoostTag); if (critBoostTag) { if (critBoostTag instanceof DragonCheerTag) { @@ -1464,19 +1427,27 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // The Ruin abilities here are never ignored, but they reveal themselves on summon anyway const fieldApplied = new BooleanHolder(false); for (const pokemon of globalScene.getField(true)) { - applyFieldStatMultiplierAbAttrs(FieldMultiplyStatAbAttr, pokemon, stat, statValue, this, fieldApplied, simulated); + applyFieldStatMultiplierAbAttrs( + "FieldMultiplyStatAbAttr", + pokemon, + stat, + statValue, + this, + fieldApplied, + simulated, + ); if (fieldApplied.value) { break; } } if (!ignoreAbility) { - applyStatMultiplierAbAttrs(StatMultiplierAbAttr, this, stat, statValue, simulated); + applyStatMultiplierAbAttrs("StatMultiplierAbAttr", this, stat, statValue, simulated); } const ally = this.getAlly(); if (!isNullOrUndefined(ally)) { applyAllyStatMultiplierAbAttrs( - AllyStatMultiplierAbAttr, + "AllyStatMultiplierAbAttr", ally, stat, statValue, @@ -2059,15 +2030,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreOverride - Whether to ignore ability changing effects; Default `false` * @returns An array of all the ability attributes on this ability. */ - public getAbilityAttrs( - attrType: { new (...args: any[]): T }, - canApply = true, - ignoreOverride = false, - ): T[] { - const abilityAttrs: T[] = []; + public getAbilityAttrs(attrType: T, canApply = true, ignoreOverride = false): AbAttrMap[T][] { + const abilityAttrs: AbAttrMap[T][] = []; if (!canApply || this.canApplyAbility()) { - abilityAttrs.push(...this.getAbility(ignoreOverride).getAttrs(attrType)); + abilityAttrs.push(...this.getAbility(ignoreOverride).getAttrs(attrType)); } if (!canApply || this.canApplyAbility(true)) { @@ -2152,7 +2119,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return false; } const ability = !passive ? this.getAbility() : this.getPassiveAbility(); - if (this.isFusion() && ability.hasAttr(NoFusionAbilityAbAttr)) { + if (this.isFusion() && ability.hasAttr("NoFusionAbilityAbAttr")) { return false; } const arena = globalScene?.arena; @@ -2163,10 +2130,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return false; } const suppressAbilitiesTag = arena.getTag(ArenaTagType.NEUTRALIZING_GAS) as SuppressAbilitiesTag; - const suppressOffField = ability.hasAttr(PreSummonAbAttr); + const suppressOffField = ability.hasAttr("PreSummonAbAttr"); if ((this.isOnField() || suppressOffField) && suppressAbilitiesTag && !suppressAbilitiesTag.isBeingRemoved()) { - const thisAbilitySuppressing = ability.hasAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr); - const hasSuppressingAbility = this.hasAbilityWithAttr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr, false); + const thisAbilitySuppressing = ability.hasAttr("PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr"); + const hasSuppressingAbility = this.hasAbilityWithAttr("PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr", false); // Neutralizing gas is up - suppress abilities unless they are unsuppressable or this pokemon is responsible for the gas // (Balance decided that the other ability of a neutralizing gas pokemon should not be neutralized) // If the ability itself is neutralizing gas, don't suppress it (handled through arena tag) @@ -2207,7 +2174,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param ignoreOverride Whether to ignore ability changing effects; default `false` * @returns `true` if an ability with the given {@linkcode AbAttr} is present and active */ - public hasAbilityWithAttr(attrType: Constructor, canApply = true, ignoreOverride = false): boolean { + public hasAbilityWithAttr(attrType: AbAttrString, canApply = true, ignoreOverride = false): boolean { if ((!canApply || this.canApplyAbility()) && this.getAbility(ignoreOverride).hasAttr(attrType)) { return true; } @@ -2229,7 +2196,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const weight = new NumberHolder(this.species.weight - weightRemoved); // This will trigger the ability overlay so only call this function when necessary - applyAbAttrs(WeightMultiplierAbAttr, this, null, false, weight); + applyAbAttrs("WeightMultiplierAbAttr", this, null, false, weight); return Math.max(minWeight, weight.value); } @@ -2300,7 +2267,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const opposingField = opposingFieldUnfiltered.filter(enemyPkm => enemyPkm.switchOutStatus === false); for (const opponent of opposingField) { - applyCheckTrappedAbAttrs(CheckTrappedAbAttr, opponent, trappedByAbility, this, trappedAbMessages, simulated); + applyCheckTrappedAbAttrs("CheckTrappedAbAttr", opponent, trappedByAbility, this, trappedAbMessages, simulated); } const side = this.isPlayer() ? ArenaTagSide.PLAYER : ArenaTagSide.ENEMY; @@ -2322,7 +2289,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const moveTypeHolder = new NumberHolder(move.type); applyMoveAttrs("VariableMoveTypeAttr", this, null, move, moveTypeHolder); - applyPreAttackAbAttrs(MoveTypeChangeAbAttr, this, null, move, simulated, moveTypeHolder); + applyPreAttackAbAttrs("MoveTypeChangeAbAttr", this, null, move, simulated, moveTypeHolder); // If the user is terastallized and the move is tera blast, or tera starstorm that is stellar type, // then bypass the check for ion deluge and electrify @@ -2387,16 +2354,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const cancelledHolder = cancelled ?? new BooleanHolder(false); if (!ignoreAbility) { - applyPreDefendAbAttrs(TypeImmunityAbAttr, this, source, move, cancelledHolder, simulated, typeMultiplier); + applyPreDefendAbAttrs("TypeImmunityAbAttr", this, source, move, cancelledHolder, simulated, typeMultiplier); if (!cancelledHolder.value) { - applyPreDefendAbAttrs(MoveImmunityAbAttr, this, source, move, cancelledHolder, simulated, typeMultiplier); + applyPreDefendAbAttrs("MoveImmunityAbAttr", this, source, move, cancelledHolder, simulated, typeMultiplier); } if (!cancelledHolder.value) { const defendingSidePlayField = this.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); defendingSidePlayField.forEach(p => - applyPreDefendAbAttrs(FieldPriorityMoveImmunityAbAttr, p, source, move, cancelledHolder), + applyPreDefendAbAttrs("FieldPriorityMoveImmunityAbAttr", p, source, move, cancelledHolder), ); } } @@ -2411,7 +2378,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Apply Tera Shell's effect to attacks after all immunities are accounted for if (!ignoreAbility && move.category !== MoveCategory.STATUS) { - applyPreDefendAbAttrs(FullHpResistTypeAbAttr, this, source, move, cancelledHolder, simulated, typeMultiplier); + applyPreDefendAbAttrs("FullHpResistTypeAbAttr", this, source, move, cancelledHolder, simulated, typeMultiplier); } if (move.category === MoveCategory.STATUS && move.hitsSubstitute(source, this)) { @@ -2463,8 +2430,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } if (source) { const ignoreImmunity = new BooleanHolder(false); - if (source.isActive(true) && source.hasAbilityWithAttr(IgnoreTypeImmunityAbAttr)) { - applyAbAttrs(IgnoreTypeImmunityAbAttr, source, ignoreImmunity, simulated, moveType, defType); + if (source.isActive(true) && source.hasAbilityWithAttr("IgnoreTypeImmunityAbAttr")) { + applyAbAttrs("IgnoreTypeImmunityAbAttr", source, ignoreImmunity, simulated, moveType, defType); } if (ignoreImmunity.value) { if (multiplier.value === 0) { @@ -3415,7 +3382,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } if (!ignoreOppAbility) { - applyAbAttrs(IgnoreOpponentStatStagesAbAttr, opponent, null, simulated, stat, ignoreStatStage); + applyAbAttrs("IgnoreOpponentStatStagesAbAttr", opponent, null, simulated, stat, ignoreStatStage); } if (move) { applyMoveAttrs("IgnoreOpponentStatStagesAttr", this, opponent, move, ignoreStatStage); @@ -3454,8 +3421,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const ignoreAccStatStage = new BooleanHolder(false); const ignoreEvaStatStage = new BooleanHolder(false); - applyAbAttrs(IgnoreOpponentStatStagesAbAttr, target, null, false, Stat.ACC, ignoreAccStatStage); - applyAbAttrs(IgnoreOpponentStatStagesAbAttr, this, null, false, Stat.EVA, ignoreEvaStatStage); + applyAbAttrs("IgnoreOpponentStatStagesAbAttr", target, null, false, Stat.ACC, ignoreAccStatStage); + applyAbAttrs("IgnoreOpponentStatStagesAbAttr", this, null, false, Stat.EVA, ignoreEvaStatStage); applyMoveAttrs("IgnoreOpponentStatStagesAttr", this, target, sourceMove, ignoreEvaStatStage); globalScene.applyModifiers(TempStatStageBoosterModifier, this.isPlayer(), Stat.ACC, userAccStage); @@ -3475,16 +3442,33 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { : 3 / (3 + Math.min(targetEvaStage.value - userAccStage.value, 6)); } - applyStatMultiplierAbAttrs(StatMultiplierAbAttr, this, Stat.ACC, accuracyMultiplier, false, sourceMove); + applyStatMultiplierAbAttrs("StatMultiplierAbAttr", this, Stat.ACC, accuracyMultiplier, false, sourceMove); const evasionMultiplier = new NumberHolder(1); - applyStatMultiplierAbAttrs(StatMultiplierAbAttr, target, Stat.EVA, evasionMultiplier); + applyStatMultiplierAbAttrs("StatMultiplierAbAttr", target, Stat.EVA, evasionMultiplier); const ally = this.getAlly(); if (!isNullOrUndefined(ally)) { - const ignore = this.hasAbilityWithAttr(MoveAbilityBypassAbAttr) || sourceMove.hasFlag(MoveFlags.IGNORE_ABILITIES); - applyAllyStatMultiplierAbAttrs(AllyStatMultiplierAbAttr, ally, Stat.ACC, accuracyMultiplier, false, this, ignore); - applyAllyStatMultiplierAbAttrs(AllyStatMultiplierAbAttr, ally, Stat.EVA, evasionMultiplier, false, this, ignore); + const ignore = + this.hasAbilityWithAttr("MoveAbilityBypassAbAttr") || sourceMove.hasFlag(MoveFlags.IGNORE_ABILITIES); + applyAllyStatMultiplierAbAttrs( + "AllyStatMultiplierAbAttr", + ally, + Stat.ACC, + accuracyMultiplier, + false, + this, + ignore, + ); + applyAllyStatMultiplierAbAttrs( + "AllyStatMultiplierAbAttr", + ally, + Stat.EVA, + evasionMultiplier, + false, + this, + ignore, + ); } return accuracyMultiplier.value / evasionMultiplier.value; @@ -3599,7 +3583,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { applyMoveAttrs("CombinedPledgeStabBoostAttr", source, this, move, stabMultiplier); if (!ignoreSourceAbility) { - applyAbAttrs(StabBoostAbAttr, source, null, simulated, stabMultiplier); + applyAbAttrs("StabBoostAbAttr", source, null, simulated, stabMultiplier); } if (source.isTerastallized && sourceTeraType === moveType && moveType !== PokemonType.STELLAR) { @@ -3748,7 +3732,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ); if (!ignoreSourceAbility) { applyPreAttackAbAttrs( - AddSecondStrikeAbAttr, + "AddSecondStrikeAbAttr", source, this, move, @@ -3766,7 +3750,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { /** The damage multiplier when the given move critically hits */ const criticalMultiplier = new NumberHolder(isCritical ? 1.5 : 1); - applyAbAttrs(MultCritAbAttr, source, null, simulated, criticalMultiplier); + applyAbAttrs("MultCritAbAttr", source, null, simulated, criticalMultiplier); /** * A multiplier for random damage spread in the range [0.85, 1] @@ -3787,7 +3771,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { ) { const burnDamageReductionCancelled = new BooleanHolder(false); if (!ignoreSourceAbility) { - applyAbAttrs(BypassBurnDamageReductionAbAttr, source, burnDamageReductionCancelled, simulated); + applyAbAttrs("BypassBurnDamageReductionAbAttr", source, burnDamageReductionCancelled, simulated); } if (!burnDamageReductionCancelled.value) { burnMultiplier = 0.5; @@ -3851,7 +3835,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { /** Doubles damage if the attacker has Tinted Lens and is using a resisted move */ if (!ignoreSourceAbility) { - applyPreAttackAbAttrs(DamageBoostAbAttr, source, this, move, simulated, damage); + applyPreAttackAbAttrs("DamageBoostAbAttr", source, this, move, simulated, damage); } /** Apply the enemy's Damage and Resistance tokens */ @@ -3864,12 +3848,12 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { /** Apply this Pokemon's post-calc defensive modifiers (e.g. Fur Coat) */ if (!ignoreAbility) { - applyPreDefendAbAttrs(ReceivedMoveDamageMultiplierAbAttr, this, source, move, cancelled, simulated, damage); + applyPreDefendAbAttrs("ReceivedMoveDamageMultiplierAbAttr", this, source, move, cancelled, simulated, damage); const ally = this.getAlly(); /** Additionally apply friend guard damage reduction if ally has it. */ if (globalScene.currentBattle.double && !isNullOrUndefined(ally) && ally.isActive(true)) { - applyPreDefendAbAttrs(AlliedFieldDamageReductionAbAttr, ally, source, move, cancelled, simulated, damage); + applyPreDefendAbAttrs("AlliedFieldDamageReductionAbAttr", ally, source, move, cancelled, simulated, damage); } } @@ -3877,7 +3861,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { applyMoveAttrs("ModifiedDamageAttr", source, this, move, damage); if (this.isFullHp() && !ignoreAbility) { - applyPreDefendAbAttrs(PreDefendFullHpEndureAbAttr, this, source, move, cancelled, false, damage); + applyPreDefendAbAttrs("PreDefendFullHpEndureAbAttr", this, source, move, cancelled, false, damage); } // debug message for when damage is applied (i.e. not simulated) @@ -3919,13 +3903,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { isCritical.value = true; } applyMoveAttrs("CritOnlyAttr", source, this, move, isCritical); - applyAbAttrs(ConditionalCritAbAttr, source, null, simulated, isCritical, this, move); + applyAbAttrs("ConditionalCritAbAttr", source, null, simulated, isCritical, this, move); if (!isCritical.value) { const critChance = [24, 8, 2, 1][Math.max(0, Math.min(this.getCritStage(source, move), 3))]; isCritical.value = critChance === 1 || !globalScene.randBattleSeedInt(critChance); } - applyAbAttrs(BlockCritAbAttr, this, null, simulated, isCritical); + applyAbAttrs("BlockCritAbAttr", this, null, simulated, isCritical); return isCritical.value; } @@ -4032,7 +4016,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * Multi-hits are handled in move-effect-phase.ts for PostDamageAbAttr */ if (!source || source.turnData.hitCount <= 1) { - applyPostDamageAbAttrs(PostDamageAbAttr, this, damage, this.hasPassive(), false, [], source); + applyPostDamageAbAttrs("PostDamageAbAttr", this, damage, this.hasPassive(), false, [], source); } return damage; } @@ -4080,11 +4064,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const stubTag = new BattlerTag(tagType, 0, 0); const cancelled = new BooleanHolder(false); - applyPreApplyBattlerTagAbAttrs(BattlerTagImmunityAbAttr, this, stubTag, cancelled, true); + applyPreApplyBattlerTagAbAttrs("BattlerTagImmunityAbAttr", this, stubTag, cancelled, true); const userField = this.getAlliedField(); userField.forEach(pokemon => - applyPreApplyBattlerTagAbAttrs(UserFieldBattlerTagImmunityAbAttr, pokemon, stubTag, cancelled, true, this), + applyPreApplyBattlerTagAbAttrs("UserFieldBattlerTagImmunityAbAttr", pokemon, stubTag, cancelled, true, this), ); return !cancelled.value; @@ -4100,13 +4084,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const newTag = getBattlerTag(tagType, turnCount, sourceMove!, sourceId!); // TODO: are the bangs correct? const cancelled = new BooleanHolder(false); - applyPreApplyBattlerTagAbAttrs(BattlerTagImmunityAbAttr, this, newTag, cancelled); + applyPreApplyBattlerTagAbAttrs("BattlerTagImmunityAbAttr", this, newTag, cancelled); if (cancelled.value) { return false; } for (const pokemon of this.getAlliedField()) { - applyPreApplyBattlerTagAbAttrs(UserFieldBattlerTagImmunityAbAttr, pokemon, newTag, cancelled, false, this); + applyPreApplyBattlerTagAbAttrs("UserFieldBattlerTagImmunityAbAttr", pokemon, newTag, cancelled, false, this); if (cancelled.value) { return false; } @@ -4124,6 +4108,9 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { /**@overload */ getTag(tagType: BattlerTagType.GRUDGE): GrudgeTag | nil; + /** @overload */ + getTag(tagType: BattlerTagType.SUBSTITUTE): SubstituteTag | undefined; + /** @overload */ getTag(tagType: BattlerTagType): BattlerTag | undefined; @@ -4626,7 +4613,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Check if the source Pokemon has an ability that cancels the Poison/Toxic immunity const cancelImmunity = new BooleanHolder(false); if (sourcePokemon) { - applyAbAttrs(IgnoreTypeStatusEffectImmunityAbAttr, sourcePokemon, cancelImmunity, false, effect, defType); + applyAbAttrs("IgnoreTypeStatusEffectImmunityAbAttr", sourcePokemon, cancelImmunity, false, effect, defType); if (cancelImmunity.value) { return false; } @@ -4675,14 +4662,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } const cancelled = new BooleanHolder(false); - applyPreSetStatusAbAttrs(StatusEffectImmunityAbAttr, this, effect, cancelled, quiet); + applyPreSetStatusAbAttrs("StatusEffectImmunityAbAttr", this, effect, cancelled, quiet); if (cancelled.value) { return false; } for (const pokemon of this.getAlliedField()) { applyPreSetStatusAbAttrs( - UserFieldStatusEffectImmunityAbAttr, + "UserFieldStatusEffectImmunityAbAttr", pokemon, effect, cancelled, @@ -4839,7 +4826,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { if (globalScene.arena.getTagOnSide(ArenaTagType.SAFEGUARD, defendingSide)) { const bypassed = new BooleanHolder(false); if (attacker) { - applyAbAttrs(InfiltratorAbAttr, attacker, null, false, bypassed); + applyAbAttrs("InfiltratorAbAttr", attacker, null, false, bypassed); } return !bypassed.value; } @@ -4863,7 +4850,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // If this Pokemon has Commander and Dondozo as an active ally, hide this Pokemon's sprite. if ( - this.hasAbilityWithAttr(CommanderAbAttr) && + this.hasAbilityWithAttr("CommanderAbAttr") && globalScene.currentBattle.double && this.getAlly()?.species.speciesId === SpeciesId.DONDOZO ) { @@ -5388,7 +5375,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.hideInfo(); } // Trigger abilities that activate upon leaving the field - applyPreLeaveFieldAbAttrs(PreLeaveFieldAbAttr, this); + applyPreLeaveFieldAbAttrs("PreLeaveFieldAbAttr", this); this.setSwitchOutStatus(true); globalScene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true); globalScene.field.remove(this, destroy); @@ -5448,7 +5435,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { globalScene.removeModifier(heldItem, this.isEnemy()); } if (forBattle) { - applyPostItemLostAbAttrs(PostItemLostAbAttr, this, false); + applyPostItemLostAbAttrs("PostItemLostAbAttr", this, false); } return true; diff --git a/src/loading-scene.ts b/src/loading-scene.ts index 67ca9a28bc5..f67d19e1027 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -21,6 +21,8 @@ import { initVouchers } from "#app/system/voucher"; import { BiomeId } from "#enums/biome-id"; import { initMysteryEncounters } from "#app/data/mystery-encounters/mystery-encounters"; import { timedEventManager } from "./global-event-manager"; +import { initModifierPools } from "./modifier/init-modifier-pools"; +import { initModifierTypes } from "./modifier/modifier-type"; export class LoadingScene extends SceneBase { public static readonly KEY = "loading"; @@ -363,6 +365,9 @@ export class LoadingScene extends SceneBase { this.loadLoadingScreen(); + initModifierTypes(); + initModifierPools(); + initAchievements(); initVouchers(); initStatsKeys(); diff --git a/src/modifier/init-modifier-pools.ts b/src/modifier/init-modifier-pools.ts new file mode 100644 index 00000000000..60697333600 --- /dev/null +++ b/src/modifier/init-modifier-pools.ts @@ -0,0 +1,854 @@ +import type Pokemon from "#app/field/pokemon"; +import { + dailyStarterModifierPool, + enemyBuffModifierPool, + modifierPool, + trainerModifierPool, + wildModifierPool, +} from "#app/modifier/modifier-pools"; +import { globalScene } from "#app/global-scene"; +import { DoubleBattleChanceBoosterModifier, SpeciesCritBoosterModifier, TurnStatusEffectModifier } from "./modifier"; +import { WeightedModifierType } from "./modifier-type"; +import { ModifierTier } from "../enums/modifier-tier"; +import type { WeightedModifierTypeWeightFunc } from "#app/@types/modifier-types"; +import { modifierTypes } from "#app/data/data-lists"; +import { PokeballType } from "#enums/pokeball"; +import { BerryModifier } from "./modifier"; +import { BerryType } from "#enums/berry-type"; +import { SpeciesId } from "#enums/species-id"; +import { timedEventManager } from "#app/global-event-manager"; +import { pokemonEvolutions } from "#app/data/balance/pokemon-evolutions"; +import { Unlockables } from "#enums/unlockables"; +import { isNullOrUndefined } from "#app/utils/common"; +import { MoveId } from "#enums/move-id"; +import { StatusEffect } from "#enums/status-effect"; +import { AbilityId } from "#enums/ability-id"; +import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball"; +// biome-ignore lint/correctness/noUnusedImports: This is used in a tsdoc comment +import type { initModifierTypes } from "./modifier-type"; + +/** + * Initialize the wild modifier pool + */ +function initWildModifierPool() { + wildModifierPool[ModifierTier.COMMON] = [new WeightedModifierType(modifierTypes.BERRY, 1)].map(m => { + m.setTier(ModifierTier.COMMON); + return m; + }); + wildModifierPool[ModifierTier.GREAT] = [new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 1)].map(m => { + m.setTier(ModifierTier.GREAT); + return m; + }); + wildModifierPool[ModifierTier.ULTRA] = [ + new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 10), + new WeightedModifierType(modifierTypes.WHITE_HERB, 0), + ].map(m => { + m.setTier(ModifierTier.ULTRA); + return m; + }); + wildModifierPool[ModifierTier.ROGUE] = [new WeightedModifierType(modifierTypes.LUCKY_EGG, 4)].map(m => { + m.setTier(ModifierTier.ROGUE); + return m; + }); + wildModifierPool[ModifierTier.MASTER] = [new WeightedModifierType(modifierTypes.GOLDEN_EGG, 1)].map(m => { + m.setTier(ModifierTier.MASTER); + return m; + }); +} + +/** + * Initialize the common modifier pool + */ +function initCommonModifierPool() { + modifierPool[ModifierTier.COMMON] = [ + new WeightedModifierType(modifierTypes.POKEBALL, () => (hasMaximumBalls(PokeballType.POKEBALL) ? 0 : 6), 6), + new WeightedModifierType(modifierTypes.RARE_CANDY, 2), + new WeightedModifierType( + modifierTypes.POTION, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter(p => p.getInverseHp() >= 10 && p.getHpRatio() <= 0.875 && !p.isFainted()).length, + 3, + ); + return thresholdPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.SUPER_POTION, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter(p => p.getInverseHp() >= 25 && p.getHpRatio() <= 0.75 && !p.isFainted()).length, + 3, + ); + return thresholdPartyMemberCount; + }, + 3, + ), + new WeightedModifierType( + modifierTypes.ETHER, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && + p + .getMoveset() + .filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) + .length, + ).length, + 3, + ); + return thresholdPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.MAX_ETHER, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && + p + .getMoveset() + .filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) + .length, + ).length, + 3, + ); + return thresholdPartyMemberCount; + }, + 3, + ), + new WeightedModifierType(modifierTypes.LURE, lureWeightFunc(10, 2)), + new WeightedModifierType(modifierTypes.TEMP_STAT_STAGE_BOOSTER, 4), + new WeightedModifierType(modifierTypes.BERRY, 2), + new WeightedModifierType(modifierTypes.TM_COMMON, 2), + ].map(m => { + m.setTier(ModifierTier.COMMON); + return m; + }); +} + +/** + * Initialize the Great modifier pool + */ +function initGreatModifierPool() { + modifierPool[ModifierTier.GREAT] = [ + new WeightedModifierType(modifierTypes.GREAT_BALL, () => (hasMaximumBalls(PokeballType.GREAT_BALL) ? 0 : 6), 6), + new WeightedModifierType(modifierTypes.PP_UP, 2), + new WeightedModifierType( + modifierTypes.FULL_HEAL, + (party: Pokemon[]) => { + const statusEffectPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !!p.status && + !p.getHeldItems().some(i => { + if (i instanceof TurnStatusEffectModifier) { + return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect; + } + return false; + }), + ).length, + 3, + ); + return statusEffectPartyMemberCount * 6; + }, + 18, + ), + new WeightedModifierType( + modifierTypes.REVIVE, + (party: Pokemon[]) => { + const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3); + return faintedPartyMemberCount * 9; + }, + 27, + ), + new WeightedModifierType( + modifierTypes.MAX_REVIVE, + (party: Pokemon[]) => { + const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3); + return faintedPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.SACRED_ASH, + (party: Pokemon[]) => { + return party.filter(p => p.isFainted()).length >= Math.ceil(party.length / 2) ? 1 : 0; + }, + 1, + ), + new WeightedModifierType( + modifierTypes.HYPER_POTION, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.625 && !p.isFainted()).length, + 3, + ); + return thresholdPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.MAX_POTION, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5 && !p.isFainted()).length, + 3, + ); + return thresholdPartyMemberCount; + }, + 3, + ), + new WeightedModifierType( + modifierTypes.FULL_RESTORE, + (party: Pokemon[]) => { + const statusEffectPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !!p.status && + !p.getHeldItems().some(i => { + if (i instanceof TurnStatusEffectModifier) { + return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect; + } + return false; + }), + ).length, + 3, + ); + const thresholdPartyMemberCount = Math.floor( + (Math.min(party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5 && !p.isFainted()).length, 3) + + statusEffectPartyMemberCount) / + 2, + ); + return thresholdPartyMemberCount; + }, + 3, + ), + new WeightedModifierType( + modifierTypes.ELIXIR, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && + p + .getMoveset() + .filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) + .length, + ).length, + 3, + ); + return thresholdPartyMemberCount * 3; + }, + 9, + ), + new WeightedModifierType( + modifierTypes.MAX_ELIXIR, + (party: Pokemon[]) => { + const thresholdPartyMemberCount = Math.min( + party.filter( + p => + p.hp && + !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && + p + .getMoveset() + .filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) + .length, + ).length, + 3, + ); + return thresholdPartyMemberCount; + }, + 3, + ), + new WeightedModifierType(modifierTypes.DIRE_HIT, 4), + new WeightedModifierType(modifierTypes.SUPER_LURE, lureWeightFunc(15, 4)), + new WeightedModifierType(modifierTypes.NUGGET, skipInLastClassicWaveOrDefault(5)), + new WeightedModifierType(modifierTypes.SPECIES_STAT_BOOSTER, 4), + new WeightedModifierType( + modifierTypes.EVOLUTION_ITEM, + () => { + return Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 15), 8); + }, + 8, + ), + new WeightedModifierType( + modifierTypes.MAP, + () => (globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex < 180 ? 2 : 0), + 2, + ), + new WeightedModifierType(modifierTypes.SOOTHE_BELL, 2), + new WeightedModifierType(modifierTypes.TM_GREAT, 3), + new WeightedModifierType( + modifierTypes.MEMORY_MUSHROOM, + (party: Pokemon[]) => { + if (!party.find(p => p.getLearnableLevelMoves().length)) { + return 0; + } + const highestPartyLevel = party + .map(p => p.level) + .reduce((highestLevel: number, level: number) => Math.max(highestLevel, level), 1); + return Math.min(Math.ceil(highestPartyLevel / 20), 4); + }, + 4, + ), + new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), + new WeightedModifierType(modifierTypes.TERA_SHARD, (party: Pokemon[]) => + party.filter( + p => + !(p.hasSpecies(SpeciesId.TERAPAGOS) || p.hasSpecies(SpeciesId.OGERPON) || p.hasSpecies(SpeciesId.SHEDINJA)), + ).length > 0 + ? 1 + : 0, + ), + new WeightedModifierType( + modifierTypes.DNA_SPLICERS, + (party: Pokemon[]) => { + if (party.filter(p => !p.fusionSpecies).length > 1) { + if (globalScene.gameMode.isSplicedOnly) { + return 4; + } + if (globalScene.gameMode.isClassic && timedEventManager.areFusionsBoosted()) { + return 2; + } + } + return 0; + }, + 4, + ), + new WeightedModifierType( + modifierTypes.VOUCHER, + (_party: Pokemon[], rerollCount: number) => (!globalScene.gameMode.isDaily ? Math.max(1 - rerollCount, 0) : 0), + 1, + ), + ].map(m => { + m.setTier(ModifierTier.GREAT); + return m; + }); +} + +/** + * Initialize the Ultra modifier pool + */ +function initUltraModifierPool() { + modifierPool[ModifierTier.ULTRA] = [ + new WeightedModifierType(modifierTypes.ULTRA_BALL, () => (hasMaximumBalls(PokeballType.ULTRA_BALL) ? 0 : 15), 15), + new WeightedModifierType(modifierTypes.MAX_LURE, lureWeightFunc(30, 4)), + new WeightedModifierType(modifierTypes.BIG_NUGGET, skipInLastClassicWaveOrDefault(12)), + new WeightedModifierType(modifierTypes.PP_MAX, 3), + new WeightedModifierType(modifierTypes.MINT, 4), + new WeightedModifierType( + modifierTypes.RARE_EVOLUTION_ITEM, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 15) * 4, 32), + 32, + ), + new WeightedModifierType( + modifierTypes.FORM_CHANGE_ITEM, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 6, + 24, + ), + new WeightedModifierType(modifierTypes.AMULET_COIN, skipInLastClassicWaveOrDefault(3)), + new WeightedModifierType(modifierTypes.EVIOLITE, (party: Pokemon[]) => { + const { gameMode, gameData } = globalScene; + if (gameMode.isDaily || (!gameMode.isFreshStartChallenge() && gameData.isUnlocked(Unlockables.EVIOLITE))) { + return party.some(p => { + // Check if Pokemon's species (or fusion species, if applicable) can evolve or if they're G-Max'd + if ( + !p.isMax() && + (p.getSpeciesForm(true).speciesId in pokemonEvolutions || + (p.isFusion() && p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions)) + ) { + // Check if Pokemon is already holding an Eviolite + return !p.getHeldItems().some(i => i.type.id === "EVIOLITE"); + } + return false; + }) + ? 10 + : 0; + } + return 0; + }), + new WeightedModifierType(modifierTypes.RARE_SPECIES_STAT_BOOSTER, 12), + new WeightedModifierType( + modifierTypes.LEEK, + (party: Pokemon[]) => { + const checkedSpecies = [SpeciesId.FARFETCHD, SpeciesId.GALAR_FARFETCHD, SpeciesId.SIRFETCHD]; + // If a party member doesn't already have a Leek and is one of the relevant species, Leek can appear + return party.some( + p => + !p.getHeldItems().some(i => i instanceof SpeciesCritBoosterModifier) && + (checkedSpecies.includes(p.getSpeciesForm(true).speciesId) || + (p.isFusion() && checkedSpecies.includes(p.getFusionSpeciesForm(true).speciesId))), + ) + ? 12 + : 0; + }, + 12, + ), + new WeightedModifierType( + modifierTypes.TOXIC_ORB, + (party: Pokemon[]) => { + return party.some(p => { + const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB"); + + if (!isHoldingOrb) { + const moveset = p + .getMoveset(true) + .filter(m => !isNullOrUndefined(m)) + .map(m => m.moveId); + const canSetStatus = p.canSetStatus(StatusEffect.TOXIC, true, true, null, true); + + // Moves that take advantage of obtaining the actual status effect + const hasStatusMoves = [MoveId.FACADE, MoveId.PSYCHO_SHIFT].some(m => moveset.includes(m)); + // Moves that take advantage of being able to give the target a status orb + // TODO: Take moves (Trick, Fling, Switcheroo) from comment when they are implemented + const hasItemMoves = [ + /* MoveId.TRICK, MoveId.FLING, MoveId.SWITCHEROO */ + ].some(m => moveset.includes(m)); + + if (canSetStatus) { + // Abilities that take advantage of obtaining the actual status effect, separated based on specificity to the orb + const hasGeneralAbility = [ + AbilityId.QUICK_FEET, + AbilityId.GUTS, + AbilityId.MARVEL_SCALE, + AbilityId.MAGIC_GUARD, + ].some(a => p.hasAbility(a, false, true)); + const hasSpecificAbility = [AbilityId.TOXIC_BOOST, AbilityId.POISON_HEAL].some(a => + p.hasAbility(a, false, true), + ); + const hasOppositeAbility = [AbilityId.FLARE_BOOST].some(a => p.hasAbility(a, false, true)); + + return hasSpecificAbility || (hasGeneralAbility && !hasOppositeAbility) || hasStatusMoves; + } + return hasItemMoves; + } + + return false; + }) + ? 10 + : 0; + }, + 10, + ), + new WeightedModifierType( + modifierTypes.FLAME_ORB, + (party: Pokemon[]) => { + return party.some(p => { + const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB"); + + if (!isHoldingOrb) { + const moveset = p + .getMoveset(true) + .filter(m => !isNullOrUndefined(m)) + .map(m => m.moveId); + const canSetStatus = p.canSetStatus(StatusEffect.BURN, true, true, null, true); + + // Moves that take advantage of obtaining the actual status effect + const hasStatusMoves = [MoveId.FACADE, MoveId.PSYCHO_SHIFT].some(m => moveset.includes(m)); + // Moves that take advantage of being able to give the target a status orb + // TODO: Take moves (Trick, Fling, Switcheroo) from comment when they are implemented + const hasItemMoves = [ + /* MoveId.TRICK, MoveId.FLING, MoveId.SWITCHEROO */ + ].some(m => moveset.includes(m)); + + if (canSetStatus) { + // Abilities that take advantage of obtaining the actual status effect, separated based on specificity to the orb + const hasGeneralAbility = [ + AbilityId.QUICK_FEET, + AbilityId.GUTS, + AbilityId.MARVEL_SCALE, + AbilityId.MAGIC_GUARD, + ].some(a => p.hasAbility(a, false, true)); + const hasSpecificAbility = [AbilityId.FLARE_BOOST].some(a => p.hasAbility(a, false, true)); + const hasOppositeAbility = [AbilityId.TOXIC_BOOST, AbilityId.POISON_HEAL].some(a => + p.hasAbility(a, false, true), + ); + + return hasSpecificAbility || (hasGeneralAbility && !hasOppositeAbility) || hasStatusMoves; + } + return hasItemMoves; + } + + return false; + }) + ? 10 + : 0; + }, + 10, + ), + new WeightedModifierType( + modifierTypes.MYSTICAL_ROCK, + (party: Pokemon[]) => { + return party.some(p => { + let isHoldingMax = false; + for (const i of p.getHeldItems()) { + if (i.type.id === "MYSTICAL_ROCK") { + isHoldingMax = i.getStackCount() === i.getMaxStackCount(); + break; + } + } + + if (!isHoldingMax) { + const moveset = p.getMoveset(true).map(m => m.moveId); + + const hasAbility = [ + AbilityId.DROUGHT, + AbilityId.ORICHALCUM_PULSE, + AbilityId.DRIZZLE, + AbilityId.SAND_STREAM, + AbilityId.SAND_SPIT, + AbilityId.SNOW_WARNING, + AbilityId.ELECTRIC_SURGE, + AbilityId.HADRON_ENGINE, + AbilityId.PSYCHIC_SURGE, + AbilityId.GRASSY_SURGE, + AbilityId.SEED_SOWER, + AbilityId.MISTY_SURGE, + ].some(a => p.hasAbility(a, false, true)); + + const hasMoves = [ + MoveId.SUNNY_DAY, + MoveId.RAIN_DANCE, + MoveId.SANDSTORM, + MoveId.SNOWSCAPE, + MoveId.HAIL, + MoveId.CHILLY_RECEPTION, + MoveId.ELECTRIC_TERRAIN, + MoveId.PSYCHIC_TERRAIN, + MoveId.GRASSY_TERRAIN, + MoveId.MISTY_TERRAIN, + ].some(m => moveset.includes(m)); + + return hasAbility || hasMoves; + } + return false; + }) + ? 10 + : 0; + }, + 10, + ), + new WeightedModifierType(modifierTypes.REVIVER_SEED, 4), + new WeightedModifierType(modifierTypes.CANDY_JAR, skipInLastClassicWaveOrDefault(5)), + new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 9), + new WeightedModifierType(modifierTypes.TM_ULTRA, 11), + new WeightedModifierType(modifierTypes.RARER_CANDY, 4), + new WeightedModifierType(modifierTypes.GOLDEN_PUNCH, skipInLastClassicWaveOrDefault(2)), + new WeightedModifierType(modifierTypes.IV_SCANNER, skipInLastClassicWaveOrDefault(4)), + new WeightedModifierType(modifierTypes.EXP_CHARM, skipInLastClassicWaveOrDefault(8)), + new WeightedModifierType(modifierTypes.EXP_SHARE, skipInLastClassicWaveOrDefault(10)), + new WeightedModifierType( + modifierTypes.TERA_ORB, + () => + !globalScene.gameMode.isClassic + ? Math.min(Math.max(Math.floor(globalScene.currentBattle.waveIndex / 50) * 2, 1), 4) + : 0, + 4, + ), + new WeightedModifierType(modifierTypes.QUICK_CLAW, 3), + new WeightedModifierType(modifierTypes.WIDE_LENS, 7), + ].map(m => { + m.setTier(ModifierTier.ULTRA); + return m; + }); +} + +function initRogueModifierPool() { + modifierPool[ModifierTier.ROGUE] = [ + new WeightedModifierType(modifierTypes.ROGUE_BALL, () => (hasMaximumBalls(PokeballType.ROGUE_BALL) ? 0 : 16), 16), + new WeightedModifierType(modifierTypes.RELIC_GOLD, skipInLastClassicWaveOrDefault(2)), + new WeightedModifierType(modifierTypes.LEFTOVERS, 3), + new WeightedModifierType(modifierTypes.SHELL_BELL, 3), + new WeightedModifierType(modifierTypes.BERRY_POUCH, 4), + new WeightedModifierType(modifierTypes.GRIP_CLAW, 5), + new WeightedModifierType(modifierTypes.SCOPE_LENS, 4), + new WeightedModifierType(modifierTypes.BATON, 2), + new WeightedModifierType(modifierTypes.SOUL_DEW, 7), + new WeightedModifierType(modifierTypes.CATCHING_CHARM, () => (!globalScene.gameMode.isClassic ? 4 : 0), 4), + new WeightedModifierType(modifierTypes.ABILITY_CHARM, skipInClassicAfterWave(189, 6)), + new WeightedModifierType(modifierTypes.FOCUS_BAND, 5), + new WeightedModifierType(modifierTypes.KINGS_ROCK, 3), + new WeightedModifierType(modifierTypes.LOCK_CAPSULE, () => (globalScene.gameMode.isClassic ? 0 : 3)), + new WeightedModifierType(modifierTypes.SUPER_EXP_CHARM, skipInLastClassicWaveOrDefault(8)), + new WeightedModifierType( + modifierTypes.RARE_FORM_CHANGE_ITEM, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 6, + 24, + ), + new WeightedModifierType( + modifierTypes.MEGA_BRACELET, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 9, + 36, + ), + new WeightedModifierType( + modifierTypes.DYNAMAX_BAND, + () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 9, + 36, + ), + new WeightedModifierType( + modifierTypes.VOUCHER_PLUS, + (_party: Pokemon[], rerollCount: number) => + !globalScene.gameMode.isDaily ? Math.max(3 - rerollCount * 1, 0) : 0, + 3, + ), + ].map(m => { + m.setTier(ModifierTier.ROGUE); + return m; + }); +} + +/** + * Initialize the Master modifier pool + */ +function initMasterModifierPool() { + modifierPool[ModifierTier.MASTER] = [ + new WeightedModifierType(modifierTypes.MASTER_BALL, () => (hasMaximumBalls(PokeballType.MASTER_BALL) ? 0 : 24), 24), + new WeightedModifierType(modifierTypes.SHINY_CHARM, 14), + new WeightedModifierType(modifierTypes.HEALING_CHARM, 18), + new WeightedModifierType(modifierTypes.MULTI_LENS, 18), + new WeightedModifierType( + modifierTypes.VOUCHER_PREMIUM, + (_party: Pokemon[], rerollCount: number) => + !globalScene.gameMode.isDaily && !globalScene.gameMode.isEndless && !globalScene.gameMode.isSplicedOnly + ? Math.max(5 - rerollCount * 2, 0) + : 0, + 5, + ), + new WeightedModifierType( + modifierTypes.DNA_SPLICERS, + (party: Pokemon[]) => + !(globalScene.gameMode.isClassic && timedEventManager.areFusionsBoosted()) && + !globalScene.gameMode.isSplicedOnly && + party.filter(p => !p.fusionSpecies).length > 1 + ? 24 + : 0, + 24, + ), + new WeightedModifierType( + modifierTypes.MINI_BLACK_HOLE, + () => + globalScene.gameMode.isDaily || + (!globalScene.gameMode.isFreshStartChallenge() && globalScene.gameData.isUnlocked(Unlockables.MINI_BLACK_HOLE)) + ? 1 + : 0, + 1, + ), + ].map(m => { + m.setTier(ModifierTier.MASTER); + return m; + }); +} + +function initTrainerModifierPool() { + trainerModifierPool[ModifierTier.COMMON] = [ + new WeightedModifierType(modifierTypes.BERRY, 8), + new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), + ].map(m => { + m.setTier(ModifierTier.COMMON); + return m; + }); + trainerModifierPool[ModifierTier.GREAT] = [new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3)].map(m => { + m.setTier(ModifierTier.GREAT); + return m; + }); + trainerModifierPool[ModifierTier.ULTRA] = [ + new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 10), + new WeightedModifierType(modifierTypes.WHITE_HERB, 0), + ].map(m => { + m.setTier(ModifierTier.ULTRA); + return m; + }); + trainerModifierPool[ModifierTier.ROGUE] = [ + new WeightedModifierType(modifierTypes.FOCUS_BAND, 2), + new WeightedModifierType(modifierTypes.LUCKY_EGG, 4), + new WeightedModifierType(modifierTypes.QUICK_CLAW, 1), + new WeightedModifierType(modifierTypes.GRIP_CLAW, 1), + new WeightedModifierType(modifierTypes.WIDE_LENS, 1), + ].map(m => { + m.setTier(ModifierTier.ROGUE); + return m; + }); + trainerModifierPool[ModifierTier.MASTER] = [ + new WeightedModifierType(modifierTypes.KINGS_ROCK, 1), + new WeightedModifierType(modifierTypes.LEFTOVERS, 1), + new WeightedModifierType(modifierTypes.SHELL_BELL, 1), + new WeightedModifierType(modifierTypes.SCOPE_LENS, 1), + ].map(m => { + m.setTier(ModifierTier.MASTER); + return m; + }); +} + +/** + * Initialize the enemy buff modifier pool + */ +function initEnemyBuffModifierPool() { + enemyBuffModifierPool[ModifierTier.COMMON] = [ + new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_BOOSTER, 9), + new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_REDUCTION, 9), + new WeightedModifierType(modifierTypes.ENEMY_ATTACK_POISON_CHANCE, 3), + new WeightedModifierType(modifierTypes.ENEMY_ATTACK_PARALYZE_CHANCE, 3), + new WeightedModifierType(modifierTypes.ENEMY_ATTACK_BURN_CHANCE, 3), + new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 9), + new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 4), + new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 1), + ].map(m => { + m.setTier(ModifierTier.COMMON); + return m; + }); + enemyBuffModifierPool[ModifierTier.GREAT] = [ + new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_BOOSTER, 5), + new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_REDUCTION, 5), + new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 5), + new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 5), + new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 1), + ].map(m => { + m.setTier(ModifierTier.GREAT); + return m; + }); + enemyBuffModifierPool[ModifierTier.ULTRA] = [ + new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_BOOSTER, 10), + new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_REDUCTION, 10), + new WeightedModifierType(modifierTypes.ENEMY_HEAL, 10), + new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 10), + new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 10), + new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 5), + ].map(m => { + m.setTier(ModifierTier.ULTRA); + return m; + }); + enemyBuffModifierPool[ModifierTier.ROGUE] = [].map((m: WeightedModifierType) => { + m.setTier(ModifierTier.ROGUE); + return m; + }); + enemyBuffModifierPool[ModifierTier.MASTER] = [].map((m: WeightedModifierType) => { + m.setTier(ModifierTier.MASTER); + return m; + }); +} + +/** + * Initialize the daily starter modifier pool + */ +function initDailyStarterModifierPool() { + dailyStarterModifierPool[ModifierTier.COMMON] = [ + new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 1), + new WeightedModifierType(modifierTypes.BERRY, 3), + ].map(m => { + m.setTier(ModifierTier.COMMON); + return m; + }); + dailyStarterModifierPool[ModifierTier.GREAT] = [new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5)].map( + m => { + m.setTier(ModifierTier.GREAT); + return m; + }, + ); + dailyStarterModifierPool[ModifierTier.ULTRA] = [ + new WeightedModifierType(modifierTypes.REVIVER_SEED, 4), + new WeightedModifierType(modifierTypes.SOOTHE_BELL, 1), + new WeightedModifierType(modifierTypes.SOUL_DEW, 1), + new WeightedModifierType(modifierTypes.GOLDEN_PUNCH, 1), + ].map(m => { + m.setTier(ModifierTier.ULTRA); + return m; + }); + dailyStarterModifierPool[ModifierTier.ROGUE] = [ + new WeightedModifierType(modifierTypes.GRIP_CLAW, 5), + new WeightedModifierType(modifierTypes.BATON, 2), + new WeightedModifierType(modifierTypes.FOCUS_BAND, 5), + new WeightedModifierType(modifierTypes.QUICK_CLAW, 3), + new WeightedModifierType(modifierTypes.KINGS_ROCK, 3), + ].map(m => { + m.setTier(ModifierTier.ROGUE); + return m; + }); + dailyStarterModifierPool[ModifierTier.MASTER] = [ + new WeightedModifierType(modifierTypes.LEFTOVERS, 1), + new WeightedModifierType(modifierTypes.SHELL_BELL, 1), + ].map(m => { + m.setTier(ModifierTier.MASTER); + return m; + }); +} + +/** + * Initialize {@linkcode modifierPool} with the initial set of modifier types. + * {@linkcode initModifierTypes} MUST be called before this function. + */ +export function initModifierPools() { + // The modifier pools the player chooses from during modifier selection + initCommonModifierPool(); + initGreatModifierPool(); + initUltraModifierPool(); + initRogueModifierPool(); + initMasterModifierPool(); + + // Modifier pools for specific scenarios + initWildModifierPool(); + initTrainerModifierPool(); + initEnemyBuffModifierPool(); + initDailyStarterModifierPool(); +} + +/** + * High order function that returns a WeightedModifierTypeWeightFunc that will only be applied on + * classic and skip an ModifierType if current wave is greater or equal to the one passed down + * @param wave - Wave where we should stop showing the modifier + * @param defaultWeight - ModifierType default weight + * @returns A WeightedModifierTypeWeightFunc + */ +function skipInClassicAfterWave(wave: number, defaultWeight: number): WeightedModifierTypeWeightFunc { + return () => { + const gameMode = globalScene.gameMode; + const currentWave = globalScene.currentBattle.waveIndex; + return gameMode.isClassic && currentWave >= wave ? 0 : defaultWeight; + }; +} + +/** + * High order function that returns a WeightedModifierTypeWeightFunc that will only be applied on + * classic and it will skip a ModifierType if it is the last wave pull. + * @param defaultWeight ModifierType default weight + * @returns A WeightedModifierTypeWeightFunc + */ +function skipInLastClassicWaveOrDefault(defaultWeight: number): WeightedModifierTypeWeightFunc { + return skipInClassicAfterWave(199, defaultWeight); +} + +/** + * High order function that returns a WeightedModifierTypeWeightFunc to ensure Lures don't spawn on Classic 199 + * or if the lure still has over 60% of its duration left + * @param maxBattles The max battles the lure type in question lasts. 10 for green, 15 for Super, 30 for Max + * @param weight The desired weight for the lure when it does spawn + * @returns A WeightedModifierTypeWeightFunc + */ +function lureWeightFunc(maxBattles: number, weight: number): WeightedModifierTypeWeightFunc { + return () => { + const lures = globalScene.getModifiers(DoubleBattleChanceBoosterModifier); + return !(globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex === 199) && + (lures.length === 0 || + lures.filter(m => m.getMaxBattles() === maxBattles && m.getBattleCount() >= maxBattles * 0.6).length === 0) + ? weight + : 0; + }; +} + +/** + * 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 + */ +function hasMaximumBalls(ballType: PokeballType): boolean { + return globalScene.gameMode.isClassic && globalScene.pokeballCounts[ballType] >= MAX_PER_TYPE_POKEBALLS; +} diff --git a/src/modifier/modifier-pools.ts b/src/modifier/modifier-pools.ts new file mode 100644 index 00000000000..3396dca1f93 --- /dev/null +++ b/src/modifier/modifier-pools.ts @@ -0,0 +1,16 @@ +/** + * Contains modifier pools for different contexts in the game. + * Can be safely imported without worrying about circular dependencies. + */ + +import type { ModifierPool } from "#app/@types/modifier-types"; + +export const modifierPool: ModifierPool = {}; + +export const wildModifierPool: ModifierPool = {}; + +export const trainerModifierPool: ModifierPool = {}; + +export const enemyBuffModifierPool: ModifierPool = {}; + +export const dailyStarterModifierPool: ModifierPool = {}; diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index b37ed7dea3b..2c848c69e18 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -2,9 +2,9 @@ import { globalScene } from "#app/global-scene"; import { EvolutionItem, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions"; import { tmPoolTiers, tmSpecies } from "#app/data/balance/tms"; import { getBerryEffectDescription, getBerryName } from "#app/data/berry"; -import { allMoves } from "#app/data/data-lists"; +import { allMoves, modifierTypes } from "#app/data/data-lists"; import { getNatureName, getNatureStatMultiplier } from "#app/data/nature"; -import { getPokeballCatchMultiplier, getPokeballName, MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball"; +import { getPokeballCatchMultiplier, getPokeballName } from "#app/data/pokeball"; import { pokemonFormChanges, SpeciesFormChangeCondition } from "#app/data/pokemon-forms"; import { SpeciesFormChangeItemTrigger } from "#app/data/pokemon-forms/form-change-triggers"; import { FormChangeItem } from "#enums/form-change-item"; @@ -97,9 +97,8 @@ import { CriticalCatchChanceBoosterModifier, FieldEffectModifier, } from "#app/modifier/modifier"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import Overrides from "#app/overrides"; -import { Unlockables } from "#app/system/unlockables"; import { getVoucherTypeIcon, getVoucherTypeName, VoucherType } from "#app/system/voucher"; import type { PokemonMoveSelectFilter, PokemonSelectFilter } from "#app/ui/party-ui-handler"; import PartyUiHandler from "#app/ui/party-ui-handler"; @@ -113,7 +112,6 @@ import { padInt, randSeedInt, } from "#app/utils/common"; -import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { BerryType } from "#enums/berry-type"; import { MoveId } from "#enums/move-id"; @@ -127,18 +125,13 @@ import { StatusEffect } from "#enums/status-effect"; import i18next from "i18next"; import { timedEventManager } from "#app/global-event-manager"; import { TYPE_BOOST_ITEM_BOOST_PERCENT } from "#app/constants"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; +import { getModifierPoolForType, getModifierType } from "#app/utils/modifier-utils"; +import type { ModifierTypeFunc, WeightedModifierTypeWeightFunc } from "#app/@types/modifier-types"; const outputModifierData = false; const useMaxWeightForOutput = false; -export enum ModifierPoolType { - PLAYER, - WILD, - TRAINER, - ENEMY_BUFF, - DAILY_STARTER, -} - type NewModifierFunc = (type: ModifierType, args: any[]) => Modifier; export class ModifierType { @@ -150,6 +143,19 @@ export class ModifierType { public tier: ModifierTier; protected newModifierFunc: NewModifierFunc | null; + /** + * Checks if the modifier type is of a specific type + * @param modifierType - The type to check against + * @return Whether the modifier type is of the specified type + */ + public is(modifierType: K): this is ModifierTypeInstanceMap[K] { + const targetType = ModifierTypeConstructorMap[modifierType]; + if (!targetType) { + return false; + } + return this instanceof targetType; + } + constructor( localeKey: string | null, iconImage: string | null, @@ -218,7 +224,7 @@ export class ModifierType { * @param func */ withIdFromFunc(func: ModifierTypeFunc): ModifierType { - this.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === func)!; // TODO: is this bang correct? + this.id = Object.keys(modifierTypeInitObj).find(k => modifierTypeInitObj[k] === func)!; // TODO: is this bang correct? return this; } @@ -299,7 +305,7 @@ export interface GeneratedPersistentModifierType { getPregenArgs(): any[]; } -class AddPokeballModifierType extends ModifierType { +export class AddPokeballModifierType extends ModifierType { private pokeballType: PokeballType; private count: number; @@ -329,7 +335,7 @@ class AddPokeballModifierType extends ModifierType { } } -class AddVoucherModifierType extends ModifierType { +export class AddVoucherModifierType extends ModifierType { private voucherType: VoucherType; private count: number; @@ -1631,7 +1637,7 @@ class EvolutionItemModifierTypeGenerator extends ModifierTypeGenerator { } } -class FormChangeItemModifierTypeGenerator extends ModifierTypeGenerator { +export class FormChangeItemModifierTypeGenerator extends ModifierTypeGenerator { constructor(isRareFormChangeItem: boolean) { super((party: Pokemon[], pregenArgs?: any[]) => { if (pregenArgs && pregenArgs.length === 1 && pregenArgs[0] in FormChangeItem) { @@ -1794,52 +1800,7 @@ export class EnemyEndureChanceModifierType extends ModifierType { } } -export type ModifierTypeFunc = () => ModifierType; -type WeightedModifierTypeWeightFunc = (party: Pokemon[], rerollCount?: number) => number; - -/** - * High order function that returns a WeightedModifierTypeWeightFunc that will only be applied on - * classic and skip an ModifierType if current wave is greater or equal to the one passed down - * @param wave - Wave where we should stop showing the modifier - * @param defaultWeight - ModifierType default weight - * @returns A WeightedModifierTypeWeightFunc - */ -function skipInClassicAfterWave(wave: number, defaultWeight: number): WeightedModifierTypeWeightFunc { - return () => { - const gameMode = globalScene.gameMode; - const currentWave = globalScene.currentBattle.waveIndex; - return gameMode.isClassic && currentWave >= wave ? 0 : defaultWeight; - }; -} - -/** - * High order function that returns a WeightedModifierTypeWeightFunc that will only be applied on - * classic and it will skip a ModifierType if it is the last wave pull. - * @param defaultWeight ModifierType default weight - * @returns A WeightedModifierTypeWeightFunc - */ -function skipInLastClassicWaveOrDefault(defaultWeight: number): WeightedModifierTypeWeightFunc { - return skipInClassicAfterWave(199, defaultWeight); -} - -/** - * High order function that returns a WeightedModifierTypeWeightFunc to ensure Lures don't spawn on Classic 199 - * or if the lure still has over 60% of its duration left - * @param maxBattles The max battles the lure type in question lasts. 10 for green, 15 for Super, 30 for Max - * @param weight The desired weight for the lure when it does spawn - * @returns A WeightedModifierTypeWeightFunc - */ -function lureWeightFunc(maxBattles: number, weight: number): WeightedModifierTypeWeightFunc { - return () => { - const lures = globalScene.getModifiers(DoubleBattleChanceBoosterModifier); - return !(globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex === 199) && - (lures.length === 0 || - lures.filter(m => m.getMaxBattles() === maxBattles && m.getBattleCount() >= maxBattles * 0.6).length === 0) - ? weight - : 0; - }; -} -class WeightedModifierType { +export class WeightedModifierType { public modifierType: ModifierType; public weight: number | WeightedModifierTypeWeightFunc; public maxWeight: number | WeightedModifierTypeWeightFunc; @@ -1850,7 +1811,7 @@ class WeightedModifierType { maxWeight?: number | WeightedModifierTypeWeightFunc, ) { this.modifierType = modifierTypeFunc(); - this.modifierType.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === modifierTypeFunc)!; // TODO: is this bang correct? + this.modifierType.id = Object.keys(modifierTypeInitObj).find(k => modifierTypeInitObj[k] === modifierTypeFunc)!; // TODO: is this bang correct? this.weight = weight; this.maxWeight = maxWeight || (!(weight instanceof Function) ? weight : 0); } @@ -1870,39 +1831,39 @@ export type GeneratorModifierOverride = { count?: number; } & ( | { - name: keyof Pick; + name: keyof Pick; type?: SpeciesStatBoosterItem; } | { - name: keyof Pick; + name: keyof Pick; type?: TempBattleStat; } | { - name: keyof Pick; + name: keyof Pick; type?: Stat; } | { - name: keyof Pick; + name: keyof Pick; type?: Nature; } | { - name: keyof Pick; + name: keyof Pick; type?: PokemonType; } | { - name: keyof Pick; + name: keyof Pick; type?: BerryType; } | { - name: keyof Pick; + name: keyof Pick; type?: EvolutionItem; } | { - name: keyof Pick; + name: keyof Pick; type?: FormChangeItem; } | { - name: keyof Pick; + name: keyof Pick; type?: MoveId; } ); @@ -1910,9 +1871,9 @@ export type GeneratorModifierOverride = { /** Type used to construct modifiers and held items for overriding purposes. */ export type ModifierOverride = GeneratorModifierOverride | BaseModifierOverride; -export type ModifierTypeKeys = keyof typeof modifierTypes; +export type ModifierTypeKeys = keyof typeof modifierTypeInitObj; -export const modifierTypes = { +const modifierTypeInitObj = Object.freeze({ POKEBALL: () => new AddPokeballModifierType("pb", PokeballType.POKEBALL, 5), GREAT_BALL: () => new AddPokeballModifierType("gb", PokeballType.GREAT_BALL, 5), ULTRA_BALL: () => new AddPokeballModifierType("ub", PokeballType.ULTRA_BALL, 5), @@ -2421,748 +2382,18 @@ export const modifierTypes = { "golden_net", (type, _args) => new BoostBugSpawnModifier(type), ), -}; +}); -interface ModifierPool { +/** + * The initial set of modifier types, used to generate the modifier pool. + */ +export type ModifierTypes = typeof modifierTypeInitObj; + +export interface ModifierPool { [tier: string]: WeightedModifierType[]; } -/** - * 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 - */ -function hasMaximumBalls(ballType: PokeballType): boolean { - return globalScene.gameMode.isClassic && globalScene.pokeballCounts[ballType] >= MAX_PER_TYPE_POKEBALLS; -} - -const modifierPool: ModifierPool = { - [ModifierTier.COMMON]: [ - new WeightedModifierType(modifierTypes.POKEBALL, () => (hasMaximumBalls(PokeballType.POKEBALL) ? 0 : 6), 6), - new WeightedModifierType(modifierTypes.RARE_CANDY, 2), - new WeightedModifierType( - modifierTypes.POTION, - (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min( - party.filter(p => p.getInverseHp() >= 10 && p.getHpRatio() <= 0.875 && !p.isFainted()).length, - 3, - ); - return thresholdPartyMemberCount * 3; - }, - 9, - ), - new WeightedModifierType( - modifierTypes.SUPER_POTION, - (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min( - party.filter(p => p.getInverseHp() >= 25 && p.getHpRatio() <= 0.75 && !p.isFainted()).length, - 3, - ); - return thresholdPartyMemberCount; - }, - 3, - ), - new WeightedModifierType( - modifierTypes.ETHER, - (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min( - party.filter( - p => - p.hp && - !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && - p - .getMoveset() - .filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) - .length, - ).length, - 3, - ); - return thresholdPartyMemberCount * 3; - }, - 9, - ), - new WeightedModifierType( - modifierTypes.MAX_ETHER, - (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min( - party.filter( - p => - p.hp && - !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && - p - .getMoveset() - .filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) - .length, - ).length, - 3, - ); - return thresholdPartyMemberCount; - }, - 3, - ), - new WeightedModifierType(modifierTypes.LURE, lureWeightFunc(10, 2)), - new WeightedModifierType(modifierTypes.TEMP_STAT_STAGE_BOOSTER, 4), - new WeightedModifierType(modifierTypes.BERRY, 2), - new WeightedModifierType(modifierTypes.TM_COMMON, 2), - ].map(m => { - m.setTier(ModifierTier.COMMON); - return m; - }), - [ModifierTier.GREAT]: [ - new WeightedModifierType(modifierTypes.GREAT_BALL, () => (hasMaximumBalls(PokeballType.GREAT_BALL) ? 0 : 6), 6), - new WeightedModifierType(modifierTypes.PP_UP, 2), - new WeightedModifierType( - modifierTypes.FULL_HEAL, - (party: Pokemon[]) => { - const statusEffectPartyMemberCount = Math.min( - party.filter( - p => - p.hp && - !!p.status && - !p.getHeldItems().some(i => { - if (i instanceof TurnStatusEffectModifier) { - return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect; - } - return false; - }), - ).length, - 3, - ); - return statusEffectPartyMemberCount * 6; - }, - 18, - ), - new WeightedModifierType( - modifierTypes.REVIVE, - (party: Pokemon[]) => { - const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3); - return faintedPartyMemberCount * 9; - }, - 27, - ), - new WeightedModifierType( - modifierTypes.MAX_REVIVE, - (party: Pokemon[]) => { - const faintedPartyMemberCount = Math.min(party.filter(p => p.isFainted()).length, 3); - return faintedPartyMemberCount * 3; - }, - 9, - ), - new WeightedModifierType( - modifierTypes.SACRED_ASH, - (party: Pokemon[]) => { - return party.filter(p => p.isFainted()).length >= Math.ceil(party.length / 2) ? 1 : 0; - }, - 1, - ), - new WeightedModifierType( - modifierTypes.HYPER_POTION, - (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min( - party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.625 && !p.isFainted()).length, - 3, - ); - return thresholdPartyMemberCount * 3; - }, - 9, - ), - new WeightedModifierType( - modifierTypes.MAX_POTION, - (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min( - party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5 && !p.isFainted()).length, - 3, - ); - return thresholdPartyMemberCount; - }, - 3, - ), - new WeightedModifierType( - modifierTypes.FULL_RESTORE, - (party: Pokemon[]) => { - const statusEffectPartyMemberCount = Math.min( - party.filter( - p => - p.hp && - !!p.status && - !p.getHeldItems().some(i => { - if (i instanceof TurnStatusEffectModifier) { - return (i as TurnStatusEffectModifier).getStatusEffect() === p.status?.effect; - } - return false; - }), - ).length, - 3, - ); - const thresholdPartyMemberCount = Math.floor( - (Math.min(party.filter(p => p.getInverseHp() >= 100 && p.getHpRatio() <= 0.5 && !p.isFainted()).length, 3) + - statusEffectPartyMemberCount) / - 2, - ); - return thresholdPartyMemberCount; - }, - 3, - ), - new WeightedModifierType( - modifierTypes.ELIXIR, - (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min( - party.filter( - p => - p.hp && - !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && - p - .getMoveset() - .filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) - .length, - ).length, - 3, - ); - return thresholdPartyMemberCount * 3; - }, - 9, - ), - new WeightedModifierType( - modifierTypes.MAX_ELIXIR, - (party: Pokemon[]) => { - const thresholdPartyMemberCount = Math.min( - party.filter( - p => - p.hp && - !p.getHeldItems().some(m => m instanceof BerryModifier && m.berryType === BerryType.LEPPA) && - p - .getMoveset() - .filter(m => m.ppUsed && m.getMovePp() - m.ppUsed <= 5 && m.ppUsed > Math.floor(m.getMovePp() / 2)) - .length, - ).length, - 3, - ); - return thresholdPartyMemberCount; - }, - 3, - ), - new WeightedModifierType(modifierTypes.DIRE_HIT, 4), - new WeightedModifierType(modifierTypes.SUPER_LURE, lureWeightFunc(15, 4)), - new WeightedModifierType(modifierTypes.NUGGET, skipInLastClassicWaveOrDefault(5)), - new WeightedModifierType(modifierTypes.SPECIES_STAT_BOOSTER, 4), - new WeightedModifierType( - modifierTypes.EVOLUTION_ITEM, - () => { - return Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 15), 8); - }, - 8, - ), - new WeightedModifierType( - modifierTypes.MAP, - () => (globalScene.gameMode.isClassic && globalScene.currentBattle.waveIndex < 180 ? 2 : 0), - 2, - ), - new WeightedModifierType(modifierTypes.SOOTHE_BELL, 2), - new WeightedModifierType(modifierTypes.TM_GREAT, 3), - new WeightedModifierType( - modifierTypes.MEMORY_MUSHROOM, - (party: Pokemon[]) => { - if (!party.find(p => p.getLearnableLevelMoves().length)) { - return 0; - } - const highestPartyLevel = party - .map(p => p.level) - .reduce((highestLevel: number, level: number) => Math.max(highestLevel, level), 1); - return Math.min(Math.ceil(highestPartyLevel / 20), 4); - }, - 4, - ), - new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), - new WeightedModifierType(modifierTypes.TERA_SHARD, (party: Pokemon[]) => - party.filter( - p => - !(p.hasSpecies(SpeciesId.TERAPAGOS) || p.hasSpecies(SpeciesId.OGERPON) || p.hasSpecies(SpeciesId.SHEDINJA)), - ).length > 0 - ? 1 - : 0, - ), - new WeightedModifierType( - modifierTypes.DNA_SPLICERS, - (party: Pokemon[]) => { - if (party.filter(p => !p.fusionSpecies).length > 1) { - if (globalScene.gameMode.isSplicedOnly) { - return 4; - } - if (globalScene.gameMode.isClassic && timedEventManager.areFusionsBoosted()) { - return 2; - } - } - return 0; - }, - 4, - ), - new WeightedModifierType( - modifierTypes.VOUCHER, - (_party: Pokemon[], rerollCount: number) => (!globalScene.gameMode.isDaily ? Math.max(1 - rerollCount, 0) : 0), - 1, - ), - ].map(m => { - m.setTier(ModifierTier.GREAT); - return m; - }), - [ModifierTier.ULTRA]: [ - new WeightedModifierType(modifierTypes.ULTRA_BALL, () => (hasMaximumBalls(PokeballType.ULTRA_BALL) ? 0 : 15), 15), - new WeightedModifierType(modifierTypes.MAX_LURE, lureWeightFunc(30, 4)), - new WeightedModifierType(modifierTypes.BIG_NUGGET, skipInLastClassicWaveOrDefault(12)), - new WeightedModifierType(modifierTypes.PP_MAX, 3), - new WeightedModifierType(modifierTypes.MINT, 4), - new WeightedModifierType( - modifierTypes.RARE_EVOLUTION_ITEM, - () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 15) * 4, 32), - 32, - ), - new WeightedModifierType( - modifierTypes.FORM_CHANGE_ITEM, - () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 6, - 24, - ), - new WeightedModifierType(modifierTypes.AMULET_COIN, skipInLastClassicWaveOrDefault(3)), - new WeightedModifierType(modifierTypes.EVIOLITE, (party: Pokemon[]) => { - const { gameMode, gameData } = globalScene; - if (gameMode.isDaily || (!gameMode.isFreshStartChallenge() && gameData.isUnlocked(Unlockables.EVIOLITE))) { - return party.some(p => { - // Check if Pokemon's species (or fusion species, if applicable) can evolve or if they're G-Max'd - if ( - !p.isMax() && - (p.getSpeciesForm(true).speciesId in pokemonEvolutions || - (p.isFusion() && p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions)) - ) { - // Check if Pokemon is already holding an Eviolite - return !p.getHeldItems().some(i => i.type.id === "EVIOLITE"); - } - return false; - }) - ? 10 - : 0; - } - return 0; - }), - new WeightedModifierType(modifierTypes.RARE_SPECIES_STAT_BOOSTER, 12), - new WeightedModifierType( - modifierTypes.LEEK, - (party: Pokemon[]) => { - const checkedSpecies = [SpeciesId.FARFETCHD, SpeciesId.GALAR_FARFETCHD, SpeciesId.SIRFETCHD]; - // If a party member doesn't already have a Leek and is one of the relevant species, Leek can appear - return party.some( - p => - !p.getHeldItems().some(i => i instanceof SpeciesCritBoosterModifier) && - (checkedSpecies.includes(p.getSpeciesForm(true).speciesId) || - (p.isFusion() && checkedSpecies.includes(p.getFusionSpeciesForm(true).speciesId))), - ) - ? 12 - : 0; - }, - 12, - ), - new WeightedModifierType( - modifierTypes.TOXIC_ORB, - (party: Pokemon[]) => { - return party.some(p => { - const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB"); - - if (!isHoldingOrb) { - const moveset = p - .getMoveset(true) - .filter(m => !isNullOrUndefined(m)) - .map(m => m.moveId); - const canSetStatus = p.canSetStatus(StatusEffect.TOXIC, true, true, null, true); - - // Moves that take advantage of obtaining the actual status effect - const hasStatusMoves = [MoveId.FACADE, MoveId.PSYCHO_SHIFT].some(m => moveset.includes(m)); - // Moves that take advantage of being able to give the target a status orb - // TODO: Take moves (Trick, Fling, Switcheroo) from comment when they are implemented - const hasItemMoves = [ - /* MoveId.TRICK, MoveId.FLING, MoveId.SWITCHEROO */ - ].some(m => moveset.includes(m)); - - if (canSetStatus) { - // Abilities that take advantage of obtaining the actual status effect, separated based on specificity to the orb - const hasGeneralAbility = [ - AbilityId.QUICK_FEET, - AbilityId.GUTS, - AbilityId.MARVEL_SCALE, - AbilityId.MAGIC_GUARD, - ].some(a => p.hasAbility(a, false, true)); - const hasSpecificAbility = [AbilityId.TOXIC_BOOST, AbilityId.POISON_HEAL].some(a => - p.hasAbility(a, false, true), - ); - const hasOppositeAbility = [AbilityId.FLARE_BOOST].some(a => p.hasAbility(a, false, true)); - - return hasSpecificAbility || (hasGeneralAbility && !hasOppositeAbility) || hasStatusMoves; - } - return hasItemMoves; - } - - return false; - }) - ? 10 - : 0; - }, - 10, - ), - new WeightedModifierType( - modifierTypes.FLAME_ORB, - (party: Pokemon[]) => { - return party.some(p => { - const isHoldingOrb = p.getHeldItems().some(i => i.type.id === "FLAME_ORB" || i.type.id === "TOXIC_ORB"); - - if (!isHoldingOrb) { - const moveset = p - .getMoveset(true) - .filter(m => !isNullOrUndefined(m)) - .map(m => m.moveId); - const canSetStatus = p.canSetStatus(StatusEffect.BURN, true, true, null, true); - - // Moves that take advantage of obtaining the actual status effect - const hasStatusMoves = [MoveId.FACADE, MoveId.PSYCHO_SHIFT].some(m => moveset.includes(m)); - // Moves that take advantage of being able to give the target a status orb - // TODO: Take moves (Trick, Fling, Switcheroo) from comment when they are implemented - const hasItemMoves = [ - /* MoveId.TRICK, MoveId.FLING, MoveId.SWITCHEROO */ - ].some(m => moveset.includes(m)); - - if (canSetStatus) { - // Abilities that take advantage of obtaining the actual status effect, separated based on specificity to the orb - const hasGeneralAbility = [ - AbilityId.QUICK_FEET, - AbilityId.GUTS, - AbilityId.MARVEL_SCALE, - AbilityId.MAGIC_GUARD, - ].some(a => p.hasAbility(a, false, true)); - const hasSpecificAbility = [AbilityId.FLARE_BOOST].some(a => p.hasAbility(a, false, true)); - const hasOppositeAbility = [AbilityId.TOXIC_BOOST, AbilityId.POISON_HEAL].some(a => - p.hasAbility(a, false, true), - ); - - return hasSpecificAbility || (hasGeneralAbility && !hasOppositeAbility) || hasStatusMoves; - } - return hasItemMoves; - } - - return false; - }) - ? 10 - : 0; - }, - 10, - ), - new WeightedModifierType( - modifierTypes.MYSTICAL_ROCK, - (party: Pokemon[]) => { - return party.some(p => { - let isHoldingMax = false; - for (const i of p.getHeldItems()) { - if (i.type.id === "MYSTICAL_ROCK") { - isHoldingMax = i.getStackCount() === i.getMaxStackCount(); - break; - } - } - - if (!isHoldingMax) { - const moveset = p.getMoveset(true).map(m => m.moveId); - - const hasAbility = [ - AbilityId.DROUGHT, - AbilityId.ORICHALCUM_PULSE, - AbilityId.DRIZZLE, - AbilityId.SAND_STREAM, - AbilityId.SAND_SPIT, - AbilityId.SNOW_WARNING, - AbilityId.ELECTRIC_SURGE, - AbilityId.HADRON_ENGINE, - AbilityId.PSYCHIC_SURGE, - AbilityId.GRASSY_SURGE, - AbilityId.SEED_SOWER, - AbilityId.MISTY_SURGE, - ].some(a => p.hasAbility(a, false, true)); - - const hasMoves = [ - MoveId.SUNNY_DAY, - MoveId.RAIN_DANCE, - MoveId.SANDSTORM, - MoveId.SNOWSCAPE, - MoveId.HAIL, - MoveId.CHILLY_RECEPTION, - MoveId.ELECTRIC_TERRAIN, - MoveId.PSYCHIC_TERRAIN, - MoveId.GRASSY_TERRAIN, - MoveId.MISTY_TERRAIN, - ].some(m => moveset.includes(m)); - - return hasAbility || hasMoves; - } - return false; - }) - ? 10 - : 0; - }, - 10, - ), - new WeightedModifierType(modifierTypes.REVIVER_SEED, 4), - new WeightedModifierType(modifierTypes.CANDY_JAR, skipInLastClassicWaveOrDefault(5)), - new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 9), - new WeightedModifierType(modifierTypes.TM_ULTRA, 11), - new WeightedModifierType(modifierTypes.RARER_CANDY, 4), - new WeightedModifierType(modifierTypes.GOLDEN_PUNCH, skipInLastClassicWaveOrDefault(2)), - new WeightedModifierType(modifierTypes.IV_SCANNER, skipInLastClassicWaveOrDefault(4)), - new WeightedModifierType(modifierTypes.EXP_CHARM, skipInLastClassicWaveOrDefault(8)), - new WeightedModifierType(modifierTypes.EXP_SHARE, skipInLastClassicWaveOrDefault(10)), - new WeightedModifierType( - modifierTypes.TERA_ORB, - () => - !globalScene.gameMode.isClassic - ? Math.min(Math.max(Math.floor(globalScene.currentBattle.waveIndex / 50) * 2, 1), 4) - : 0, - 4, - ), - new WeightedModifierType(modifierTypes.QUICK_CLAW, 3), - new WeightedModifierType(modifierTypes.WIDE_LENS, 7), - ].map(m => { - m.setTier(ModifierTier.ULTRA); - return m; - }), - [ModifierTier.ROGUE]: [ - new WeightedModifierType(modifierTypes.ROGUE_BALL, () => (hasMaximumBalls(PokeballType.ROGUE_BALL) ? 0 : 16), 16), - new WeightedModifierType(modifierTypes.RELIC_GOLD, skipInLastClassicWaveOrDefault(2)), - new WeightedModifierType(modifierTypes.LEFTOVERS, 3), - new WeightedModifierType(modifierTypes.SHELL_BELL, 3), - new WeightedModifierType(modifierTypes.BERRY_POUCH, 4), - new WeightedModifierType(modifierTypes.GRIP_CLAW, 5), - new WeightedModifierType(modifierTypes.SCOPE_LENS, 4), - new WeightedModifierType(modifierTypes.BATON, 2), - new WeightedModifierType(modifierTypes.SOUL_DEW, 7), - new WeightedModifierType(modifierTypes.CATCHING_CHARM, () => (!globalScene.gameMode.isClassic ? 4 : 0), 4), - new WeightedModifierType(modifierTypes.ABILITY_CHARM, skipInClassicAfterWave(189, 6)), - new WeightedModifierType(modifierTypes.FOCUS_BAND, 5), - new WeightedModifierType(modifierTypes.KINGS_ROCK, 3), - new WeightedModifierType(modifierTypes.LOCK_CAPSULE, () => (globalScene.gameMode.isClassic ? 0 : 3)), - new WeightedModifierType(modifierTypes.SUPER_EXP_CHARM, skipInLastClassicWaveOrDefault(8)), - new WeightedModifierType( - modifierTypes.RARE_FORM_CHANGE_ITEM, - () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 6, - 24, - ), - new WeightedModifierType( - modifierTypes.MEGA_BRACELET, - () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 9, - 36, - ), - new WeightedModifierType( - modifierTypes.DYNAMAX_BAND, - () => Math.min(Math.ceil(globalScene.currentBattle.waveIndex / 50), 4) * 9, - 36, - ), - new WeightedModifierType( - modifierTypes.VOUCHER_PLUS, - (_party: Pokemon[], rerollCount: number) => - !globalScene.gameMode.isDaily ? Math.max(3 - rerollCount * 1, 0) : 0, - 3, - ), - ].map(m => { - m.setTier(ModifierTier.ROGUE); - return m; - }), - [ModifierTier.MASTER]: [ - new WeightedModifierType(modifierTypes.MASTER_BALL, () => (hasMaximumBalls(PokeballType.MASTER_BALL) ? 0 : 24), 24), - new WeightedModifierType(modifierTypes.SHINY_CHARM, 14), - new WeightedModifierType(modifierTypes.HEALING_CHARM, 18), - new WeightedModifierType(modifierTypes.MULTI_LENS, 18), - new WeightedModifierType( - modifierTypes.VOUCHER_PREMIUM, - (_party: Pokemon[], rerollCount: number) => - !globalScene.gameMode.isDaily && !globalScene.gameMode.isEndless && !globalScene.gameMode.isSplicedOnly - ? Math.max(5 - rerollCount * 2, 0) - : 0, - 5, - ), - new WeightedModifierType( - modifierTypes.DNA_SPLICERS, - (party: Pokemon[]) => - !(globalScene.gameMode.isClassic && timedEventManager.areFusionsBoosted()) && - !globalScene.gameMode.isSplicedOnly && - party.filter(p => !p.fusionSpecies).length > 1 - ? 24 - : 0, - 24, - ), - new WeightedModifierType( - modifierTypes.MINI_BLACK_HOLE, - () => - globalScene.gameMode.isDaily || - (!globalScene.gameMode.isFreshStartChallenge() && globalScene.gameData.isUnlocked(Unlockables.MINI_BLACK_HOLE)) - ? 1 - : 0, - 1, - ), - ].map(m => { - m.setTier(ModifierTier.MASTER); - return m; - }), -}; - -const wildModifierPool: ModifierPool = { - [ModifierTier.COMMON]: [new WeightedModifierType(modifierTypes.BERRY, 1)].map(m => { - m.setTier(ModifierTier.COMMON); - return m; - }), - [ModifierTier.GREAT]: [new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 1)].map(m => { - m.setTier(ModifierTier.GREAT); - return m; - }), - [ModifierTier.ULTRA]: [ - new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 10), - new WeightedModifierType(modifierTypes.WHITE_HERB, 0), - ].map(m => { - m.setTier(ModifierTier.ULTRA); - return m; - }), - [ModifierTier.ROGUE]: [new WeightedModifierType(modifierTypes.LUCKY_EGG, 4)].map(m => { - m.setTier(ModifierTier.ROGUE); - return m; - }), - [ModifierTier.MASTER]: [new WeightedModifierType(modifierTypes.GOLDEN_EGG, 1)].map(m => { - m.setTier(ModifierTier.MASTER); - return m; - }), -}; - -const trainerModifierPool: ModifierPool = { - [ModifierTier.COMMON]: [ - new WeightedModifierType(modifierTypes.BERRY, 8), - new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3), - ].map(m => { - m.setTier(ModifierTier.COMMON); - return m; - }), - [ModifierTier.GREAT]: [new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 3)].map(m => { - m.setTier(ModifierTier.GREAT); - return m; - }), - [ModifierTier.ULTRA]: [ - new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 10), - new WeightedModifierType(modifierTypes.WHITE_HERB, 0), - ].map(m => { - m.setTier(ModifierTier.ULTRA); - return m; - }), - [ModifierTier.ROGUE]: [ - new WeightedModifierType(modifierTypes.FOCUS_BAND, 2), - new WeightedModifierType(modifierTypes.LUCKY_EGG, 4), - new WeightedModifierType(modifierTypes.QUICK_CLAW, 1), - new WeightedModifierType(modifierTypes.GRIP_CLAW, 1), - new WeightedModifierType(modifierTypes.WIDE_LENS, 1), - ].map(m => { - m.setTier(ModifierTier.ROGUE); - return m; - }), - [ModifierTier.MASTER]: [ - new WeightedModifierType(modifierTypes.KINGS_ROCK, 1), - new WeightedModifierType(modifierTypes.LEFTOVERS, 1), - new WeightedModifierType(modifierTypes.SHELL_BELL, 1), - new WeightedModifierType(modifierTypes.SCOPE_LENS, 1), - ].map(m => { - m.setTier(ModifierTier.MASTER); - return m; - }), -}; - -const enemyBuffModifierPool: ModifierPool = { - [ModifierTier.COMMON]: [ - new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_BOOSTER, 9), - new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_REDUCTION, 9), - new WeightedModifierType(modifierTypes.ENEMY_ATTACK_POISON_CHANCE, 3), - new WeightedModifierType(modifierTypes.ENEMY_ATTACK_PARALYZE_CHANCE, 3), - new WeightedModifierType(modifierTypes.ENEMY_ATTACK_BURN_CHANCE, 3), - new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 9), - new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 4), - new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 1), - ].map(m => { - m.setTier(ModifierTier.COMMON); - return m; - }), - [ModifierTier.GREAT]: [ - new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_BOOSTER, 5), - new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_REDUCTION, 5), - new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 5), - new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 5), - new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 1), - ].map(m => { - m.setTier(ModifierTier.GREAT); - return m; - }), - [ModifierTier.ULTRA]: [ - new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_BOOSTER, 10), - new WeightedModifierType(modifierTypes.ENEMY_DAMAGE_REDUCTION, 10), - new WeightedModifierType(modifierTypes.ENEMY_HEAL, 10), - new WeightedModifierType(modifierTypes.ENEMY_STATUS_EFFECT_HEAL_CHANCE, 10), - new WeightedModifierType(modifierTypes.ENEMY_ENDURE_CHANCE, 10), - new WeightedModifierType(modifierTypes.ENEMY_FUSED_CHANCE, 5), - ].map(m => { - m.setTier(ModifierTier.ULTRA); - return m; - }), - [ModifierTier.ROGUE]: [].map((m: WeightedModifierType) => { - m.setTier(ModifierTier.ROGUE); - return m; - }), - [ModifierTier.MASTER]: [].map((m: WeightedModifierType) => { - m.setTier(ModifierTier.MASTER); - return m; - }), -}; - -const dailyStarterModifierPool: ModifierPool = { - [ModifierTier.COMMON]: [ - new WeightedModifierType(modifierTypes.BASE_STAT_BOOSTER, 1), - new WeightedModifierType(modifierTypes.BERRY, 3), - ].map(m => { - m.setTier(ModifierTier.COMMON); - return m; - }), - [ModifierTier.GREAT]: [new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5)].map(m => { - m.setTier(ModifierTier.GREAT); - return m; - }), - [ModifierTier.ULTRA]: [ - new WeightedModifierType(modifierTypes.REVIVER_SEED, 4), - new WeightedModifierType(modifierTypes.SOOTHE_BELL, 1), - new WeightedModifierType(modifierTypes.SOUL_DEW, 1), - new WeightedModifierType(modifierTypes.GOLDEN_PUNCH, 1), - ].map(m => { - m.setTier(ModifierTier.ULTRA); - return m; - }), - [ModifierTier.ROGUE]: [ - new WeightedModifierType(modifierTypes.GRIP_CLAW, 5), - new WeightedModifierType(modifierTypes.BATON, 2), - new WeightedModifierType(modifierTypes.FOCUS_BAND, 5), - new WeightedModifierType(modifierTypes.QUICK_CLAW, 3), - new WeightedModifierType(modifierTypes.KINGS_ROCK, 3), - ].map(m => { - m.setTier(ModifierTier.ROGUE); - return m; - }), - [ModifierTier.MASTER]: [ - new WeightedModifierType(modifierTypes.LEFTOVERS, 1), - new WeightedModifierType(modifierTypes.SHELL_BELL, 1), - ].map(m => { - m.setTier(ModifierTier.MASTER); - return m; - }), -}; - -export function getModifierType(modifierTypeFunc: ModifierTypeFunc): ModifierType { - const modifierType = modifierTypeFunc(); - if (!modifierType.id) { - modifierType.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === modifierTypeFunc)!; // TODO: is this bang correct? - } - return modifierType; -} +const modifierPool: ModifierPool = {}; let modifierPoolThresholds = {}; let ignoredPoolIndexes = {}; @@ -3179,28 +2410,6 @@ let enemyBuffModifierPoolThresholds = {}; // biome-ignore lint/correctness/noUnusedVariables: TODO explain why this is marked as OK let enemyBuffIgnoredPoolIndexes = {}; -export function getModifierPoolForType(poolType: ModifierPoolType): ModifierPool { - let pool: ModifierPool; - switch (poolType) { - case ModifierPoolType.PLAYER: - pool = modifierPool; - break; - case ModifierPoolType.WILD: - pool = wildModifierPool; - break; - case ModifierPoolType.TRAINER: - pool = trainerModifierPool; - break; - case ModifierPoolType.ENEMY_BUFF: - pool = enemyBuffModifierPool; - break; - case ModifierPoolType.DAILY_STARTER: - pool = dailyStarterModifierPool; - break; - } - return pool; -} - const tierWeights = [768 / 1024, 195 / 1024, 48 / 1024, 12 / 1024, 1 / 1024]; /** * Allows a unit test to check if an item exists in the Modifier Pool. Checks the pool directly, rather than attempting to reroll for the item. @@ -3314,7 +2523,7 @@ export interface CustomModifierSettings { } export function getModifierTypeFuncById(id: string): ModifierTypeFunc { - return modifierTypes[id]; + return modifierTypeInitObj[id]; } /** @@ -3367,12 +2576,12 @@ export function getPlayerModifierTypeOptions( customModifierSettings.guaranteedModifierTypeFuncs.length > 0 ) { customModifierSettings.guaranteedModifierTypeFuncs!.forEach((mod, _i) => { - const modifierId = Object.keys(modifierTypes).find(k => modifierTypes[k] === mod) as string; - let guaranteedMod: ModifierType = modifierTypes[modifierId]?.(); + const modifierId = Object.keys(modifierTypeInitObj).find(k => modifierTypeInitObj[k] === mod) as string; + let guaranteedMod: ModifierType = modifierTypeInitObj[modifierId]?.(); // Populates item id and tier guaranteedMod = guaranteedMod - .withIdFromFunc(modifierTypes[modifierId]) + .withIdFromFunc(modifierTypeInitObj[modifierId]) .withTierFromPool(ModifierPoolType.PLAYER, party); const modType = @@ -3451,7 +2660,7 @@ export function overridePlayerModifierTypeOptions(options: ModifierTypeOption[], const minLength = Math.min(options.length, Overrides.ITEM_REWARD_OVERRIDE.length); for (let i = 0; i < minLength; i++) { const override: ModifierOverride = Overrides.ITEM_REWARD_OVERRIDE[i]; - const modifierFunc = modifierTypes[override.name]; + const modifierFunc = modifierTypeInitObj[override.name]; let modifierType: ModifierType | null = modifierFunc(); if (modifierType instanceof ModifierTypeGenerator) { @@ -3472,29 +2681,29 @@ export function getPlayerShopModifierTypeOptionsForWave(waveIndex: number, baseC const options = [ [ - new ModifierTypeOption(modifierTypes.POTION(), 0, baseCost * 0.2), - new ModifierTypeOption(modifierTypes.ETHER(), 0, baseCost * 0.4), - new ModifierTypeOption(modifierTypes.REVIVE(), 0, baseCost * 2), + new ModifierTypeOption(modifierTypeInitObj.POTION(), 0, baseCost * 0.2), + new ModifierTypeOption(modifierTypeInitObj.ETHER(), 0, baseCost * 0.4), + new ModifierTypeOption(modifierTypeInitObj.REVIVE(), 0, baseCost * 2), ], [ - new ModifierTypeOption(modifierTypes.SUPER_POTION(), 0, baseCost * 0.45), - new ModifierTypeOption(modifierTypes.FULL_HEAL(), 0, baseCost), + new ModifierTypeOption(modifierTypeInitObj.SUPER_POTION(), 0, baseCost * 0.45), + new ModifierTypeOption(modifierTypeInitObj.FULL_HEAL(), 0, baseCost), ], [ - new ModifierTypeOption(modifierTypes.ELIXIR(), 0, baseCost), - new ModifierTypeOption(modifierTypes.MAX_ETHER(), 0, baseCost), + new ModifierTypeOption(modifierTypeInitObj.ELIXIR(), 0, baseCost), + new ModifierTypeOption(modifierTypeInitObj.MAX_ETHER(), 0, baseCost), ], [ - new ModifierTypeOption(modifierTypes.HYPER_POTION(), 0, baseCost * 0.8), - new ModifierTypeOption(modifierTypes.MAX_REVIVE(), 0, baseCost * 2.75), - new ModifierTypeOption(modifierTypes.MEMORY_MUSHROOM(), 0, baseCost * 4), + new ModifierTypeOption(modifierTypeInitObj.HYPER_POTION(), 0, baseCost * 0.8), + new ModifierTypeOption(modifierTypeInitObj.MAX_REVIVE(), 0, baseCost * 2.75), + new ModifierTypeOption(modifierTypeInitObj.MEMORY_MUSHROOM(), 0, baseCost * 4), ], [ - new ModifierTypeOption(modifierTypes.MAX_POTION(), 0, baseCost * 1.5), - new ModifierTypeOption(modifierTypes.MAX_ELIXIR(), 0, baseCost * 2.5), + new ModifierTypeOption(modifierTypeInitObj.MAX_POTION(), 0, baseCost * 1.5), + new ModifierTypeOption(modifierTypeInitObj.MAX_ELIXIR(), 0, baseCost * 2.5), ], - [new ModifierTypeOption(modifierTypes.FULL_RESTORE(), 0, baseCost * 2.25)], - [new ModifierTypeOption(modifierTypes.SACRED_ASH(), 0, baseCost * 10)], + [new ModifierTypeOption(modifierTypeInitObj.FULL_RESTORE(), 0, baseCost * 2.25)], + [new ModifierTypeOption(modifierTypeInitObj.SACRED_ASH(), 0, baseCost * 10)], ]; return options.slice(0, Math.ceil(Math.max(waveIndex + 10, 0) / 30)).flat(); } @@ -3549,7 +2758,7 @@ export function getEnemyModifierTypesForWave( ?.type as PokemonHeldItemModifierType, ); if (!(waveIndex % 1000)) { - ret.push(getModifierType(modifierTypes.MINI_BLACK_HOLE) as PokemonHeldItemModifierType); + ret.push(getModifierType(modifierTypeInitObj.MINI_BLACK_HOLE) as PokemonHeldItemModifierType); } return ret; } @@ -3779,3 +2988,30 @@ export function getLuckTextTint(luckValue: number): number { } return getModifierTierTextTint(modifierTier); } + +export function initModifierTypes() { + for (const [key, value] of Object.entries(modifierTypeInitObj)) { + modifierTypes[key] = value; + } +} + +// TODO: If necessary, add the rest of the modifier types here. +// For now, doing the minimal work until the modifier rework lands. +const ModifierTypeConstructorMap = Object.freeze({ + ModifierTypeGenerator, + PokemonHeldItemModifierType, +}); + +/** + * Map of of modifier type strings to their constructor type + */ +export type ModifierTypeConstructorMap = typeof ModifierTypeConstructorMap; + +/** + * Map of modifier type strings to their instance type + */ +export type ModifierTypeInstanceMap = { + [K in keyof ModifierTypeConstructorMap]: InstanceType; +}; + +export type ModifierTypeString = keyof ModifierTypeConstructorMap; diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index bfea061b1e8..e11f2c07ce8 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -1,12 +1,13 @@ import { FusionSpeciesFormEvolution, pokemonEvolutions } from "#app/data/balance/pokemon-evolutions"; import { getBerryEffectFunc, getBerryPredicate } from "#app/data/berry"; import { getLevelTotalExp } from "#app/data/exp"; -import { allMoves } from "#app/data/data-lists"; +import { allMoves, modifierTypes } from "#app/data/data-lists"; import { MAX_PER_TYPE_POKEBALLS } from "#app/data/pokeball"; import { SpeciesFormChangeItemTrigger } from "#app/data/pokemon-forms/form-change-triggers"; import type { FormChangeItem } from "#enums/form-change-item"; import { getStatusEffectHealText } from "#app/data/status-effect"; -import Pokemon, { type PlayerPokemon } from "#app/field/pokemon"; +import type { PlayerPokemon } from "#app/field/pokemon"; +import type Pokemon from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; import Overrides from "#app/overrides"; import { LearnMoveType } from "#enums/learn-move-type"; @@ -24,33 +25,26 @@ import { type PermanentStat, type TempBattleStat, BATTLE_STATS, Stat, TEMP_BATTL import { StatusEffect } from "#enums/status-effect"; import type { PokemonType } from "#enums/pokemon-type"; import i18next from "i18next"; -import { - type DoubleBattleChanceBoosterModifierType, - type EvolutionItemModifierType, - type FormChangeItemModifierType, - type ModifierOverride, - type ModifierType, - type PokemonBaseStatTotalModifierType, - type PokemonExpBoosterModifierType, - type PokemonFriendshipBoosterModifierType, - type PokemonMoveAccuracyBoosterModifierType, - type PokemonMultiHitModifierType, - type TerastallizeModifierType, - type TmModifierType, - getModifierType, - ModifierTypeGenerator, - modifierTypes, - PokemonHeldItemModifierType, +import type { + DoubleBattleChanceBoosterModifierType, + EvolutionItemModifierType, + FormChangeItemModifierType, + ModifierOverride, + ModifierType, + PokemonBaseStatTotalModifierType, + PokemonExpBoosterModifierType, + PokemonFriendshipBoosterModifierType, + PokemonMoveAccuracyBoosterModifierType, + PokemonMultiHitModifierType, + TerastallizeModifierType, + TmModifierType, } from "./modifier-type"; +import { getModifierType } from "#app/utils/modifier-utils"; import { Color, ShadowColor } from "#enums/color"; import { FRIENDSHIP_GAIN_FROM_RARE_CANDY } from "#app/data/balance/starters"; -import { - applyAbAttrs, - applyPostItemLostAbAttrs, - CommanderAbAttr, - PostItemLostAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs, applyPostItemLostAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { globalScene } from "#app/global-scene"; +import type { ModifierInstanceMap, ModifierString } from "#app/@types/modifier-types"; export type ModifierPredicate = (modifier: Modifier) => boolean; @@ -164,6 +158,23 @@ export abstract class Modifier { this.type = type; } + /** + * 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(modifier: T): this is ModifierInstanceMap[T] { + const targetModifier = ModifierClassMap[modifier]; + if (!targetModifier) { + return false; + } + return this instanceof targetModifier; + } + match(_modifier: Modifier): boolean { return false; } @@ -188,6 +199,11 @@ export abstract class PersistentModifier extends Modifier { public stackCount: number; public virtualStackCount: number; + /** This field does not exist at runtime and must not be used. + * Its sole purpose is to ensure that typescript is able to properly narrow when the `is` method is called. + */ + private declare _: never; + constructor(type: ModifierType, stackCount = 1) { super(type); this.stackCount = stackCount; @@ -1593,7 +1609,7 @@ export class BypassSpeedChanceModifier extends PokemonHeldItemModifier { doBypassSpeed.value = true; const isCommandFight = globalScene.currentBattle.turnCommands[pokemon.getBattlerIndex()]?.command === Command.FIGHT; - const hasQuickClaw = this.type instanceof PokemonHeldItemModifierType && this.type.id === "QUICK_CLAW"; + const hasQuickClaw = this.type.is("PokemonHeldItemModifierType") && this.type.id === "QUICK_CLAW"; if (isCommandFight && hasQuickClaw) { globalScene.phaseManager.queueMessage( @@ -1877,7 +1893,7 @@ export class BerryModifier extends PokemonHeldItemModifier { // munch the berry and trigger unburden-like effects getBerryEffectFunc(this.berryType)(pokemon); - applyPostItemLostAbAttrs(PostItemLostAbAttr, pokemon, false); + applyPostItemLostAbAttrs("PostItemLostAbAttr", pokemon, false); // Update berry eaten trackers for Belch, Harvest, Cud Chew, etc. // Don't recover it if we proc berry pouch (no item duplication) @@ -1965,7 +1981,7 @@ export class PokemonInstantReviveModifier extends PokemonHeldItemModifier { // Reapply Commander on the Pokemon's side of the field, if applicable const field = pokemon.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); for (const p of field) { - applyAbAttrs(CommanderAbAttr, p, null, false); + applyAbAttrs("CommanderAbAttr", p, null, false); } return true; } @@ -3215,7 +3231,7 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier { * @returns the opponents of the source {@linkcode Pokemon} */ getTargets(pokemon?: Pokemon, ..._args: unknown[]): Pokemon[] { - return pokemon instanceof Pokemon ? pokemon.getOpponents() : []; + return pokemon?.getOpponents?.() ?? []; } /** @@ -3787,7 +3803,7 @@ export function overrideModifiers(isPlayer = true): void { const modifierFunc = modifierTypes[item.name]; let modifierType: ModifierType | null = modifierFunc(); - if (modifierType instanceof ModifierTypeGenerator) { + if (modifierType.is("ModifierTypeGenerator")) { const pregenArgs = "type" in item && item.type !== null ? [item.type] : undefined; modifierType = modifierType.generateType([], pregenArgs); } @@ -3829,7 +3845,7 @@ export function overrideHeldItems(pokemon: Pokemon, isPlayer = true): void { let modifierType: ModifierType | null = modifierFunc(); const qty = item.count || 1; - if (modifierType instanceof ModifierTypeGenerator) { + if (modifierType.is("ModifierTypeGenerator")) { const pregenArgs = "type" in item && item.type !== null ? [item.type] : undefined; modifierType = modifierType.generateType([], pregenArgs); } @@ -3847,3 +3863,102 @@ export function overrideHeldItems(pokemon: Pokemon, isPlayer = true): void { } } } + +/** + * Private map from modifier strings to their constructors. + * + * @remarks + * Used for {@linkcode Modifier.is} to check if a modifier is of a certain type without + * requiring modifier types to be imported in every file. + */ +const ModifierClassMap = Object.freeze({ + PersistentModifier, + ConsumableModifier, + AddPokeballModifier, + AddVoucherModifier, + LapsingPersistentModifier, + DoubleBattleChanceBoosterModifier, + TempStatStageBoosterModifier, + TempCritBoosterModifier, + MapModifier, + MegaEvolutionAccessModifier, + GigantamaxAccessModifier, + TerastallizeAccessModifier, + PokemonHeldItemModifier, + LapsingPokemonHeldItemModifier, + BaseStatModifier, + EvoTrackerModifier, + PokemonBaseStatTotalModifier, + PokemonBaseStatFlatModifier, + PokemonIncrementingStatModifier, + StatBoosterModifier, + SpeciesStatBoosterModifier, + CritBoosterModifier, + SpeciesCritBoosterModifier, + AttackTypeBoosterModifier, + SurviveDamageModifier, + BypassSpeedChanceModifier, + FlinchChanceModifier, + TurnHealModifier, + TurnStatusEffectModifier, + HitHealModifier, + LevelIncrementBoosterModifier, + BerryModifier, + PreserveBerryModifier, + PokemonInstantReviveModifier, + ResetNegativeStatStageModifier, + FieldEffectModifier, + ConsumablePokemonModifier, + TerrastalizeModifier, + PokemonHpRestoreModifier, + PokemonStatusHealModifier, + ConsumablePokemonMoveModifier, + PokemonPpRestoreModifier, + PokemonAllMovePpRestoreModifier, + PokemonPpUpModifier, + PokemonNatureChangeModifier, + PokemonLevelIncrementModifier, + TmModifier, + RememberMoveModifier, + EvolutionItemModifier, + FusePokemonModifier, + MultipleParticipantExpBonusModifier, + HealingBoosterModifier, + ExpBoosterModifier, + PokemonExpBoosterModifier, + ExpShareModifier, + ExpBalanceModifier, + PokemonFriendshipBoosterModifier, + PokemonNatureWeightModifier, + PokemonMoveAccuracyBoosterModifier, + PokemonMultiHitModifier, + PokemonFormChangeItemModifier, + MoneyRewardModifier, + DamageMoneyRewardModifier, + MoneyInterestModifier, + HiddenAbilityRateBoosterModifier, + ShinyRateBoosterModifier, + CriticalCatchChanceBoosterModifier, + LockModifierTiersModifier, + HealShopCostModifier, + BoostBugSpawnModifier, + SwitchEffectTransferModifier, + HeldItemTransferModifier, + TurnHeldItemTransferModifier, + ContactHeldItemTransferChanceModifier, + IvScannerModifier, + ExtraModifierModifier, + TempExtraModifierModifier, + EnemyPersistentModifier, + EnemyDamageMultiplierModifier, + EnemyDamageBoosterModifier, + EnemyDamageReducerModifier, + EnemyTurnHealModifier, + EnemyAttackStatusEffectChanceModifier, + EnemyStatusEffectHealChanceModifier, + EnemyEndureChanceModifier, + EnemyFusionChanceModifier, + MoneyMultiplierModifier, +}); + +export type ModifierConstructorMap = typeof ModifierClassMap; diff --git a/src/overrides.ts b/src/overrides.ts index 1fbca8e8de1..b5df1073c28 100644 --- a/src/overrides.ts +++ b/src/overrides.ts @@ -4,7 +4,7 @@ import { Gender } from "#app/data/gender"; import { FormChangeItem } from "#enums/form-change-item"; import { type ModifierOverride } from "#app/modifier/modifier-type"; import { Variant } from "#app/sprites/variant"; -import { Unlockables } from "#app/system/unlockables"; +import { Unlockables } from "#enums/unlockables"; import { AbilityId } from "#enums/ability-id"; import { BattleType } from "#enums/battle-type"; import { BerryType } from "#enums/berry-type"; diff --git a/src/phases/add-enemy-buff-modifier-phase.ts b/src/phases/add-enemy-buff-modifier-phase.ts index 28eaf0dc4df..185464670d3 100644 --- a/src/phases/add-enemy-buff-modifier-phase.ts +++ b/src/phases/add-enemy-buff-modifier-phase.ts @@ -1,9 +1,9 @@ -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { regenerateModifierPoolThresholds, - ModifierPoolType, getEnemyBuffModifierForWave, } from "#app/modifier/modifier-type"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import { EnemyPersistentModifier } from "#app/modifier/modifier"; import { Phase } from "#app/phase"; import { globalScene } from "#app/global-scene"; diff --git a/src/phases/attempt-run-phase.ts b/src/phases/attempt-run-phase.ts index 525be8c21ab..5e24f3474a6 100644 --- a/src/phases/attempt-run-phase.ts +++ b/src/phases/attempt-run-phase.ts @@ -1,9 +1,4 @@ -import { - applyAbAttrs, - applyPreLeaveFieldAbAttrs, - PreLeaveFieldAbAttr, - RunSuccessAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs, applyPreLeaveFieldAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { Stat } from "#enums/stat"; import { StatusEffect } from "#enums/status-effect"; import type { PlayerPokemon, EnemyPokemon } from "#app/field/pokemon"; @@ -30,10 +25,10 @@ export class AttemptRunPhase extends PokemonPhase { this.attemptRunAway(playerField, enemyField, escapeChance); - applyAbAttrs(RunSuccessAbAttr, playerPokemon, null, false, escapeChance); + applyAbAttrs("RunSuccessAbAttr", playerPokemon, null, false, escapeChance); if (playerPokemon.randBattleSeedInt(100) < escapeChance.value && !this.forceFailEscape) { - enemyField.forEach(enemyPokemon => applyPreLeaveFieldAbAttrs(PreLeaveFieldAbAttr, enemyPokemon)); + enemyField.forEach(enemyPokemon => applyPreLeaveFieldAbAttrs("PreLeaveFieldAbAttr", enemyPokemon)); globalScene.playSound("se/flee"); globalScene.phaseManager.queueMessage(i18next.t("battle:runAwaySuccess"), null, true, 500); diff --git a/src/phases/battle-end-phase.ts b/src/phases/battle-end-phase.ts index e169de58cb3..e1bf4c2296c 100644 --- a/src/phases/battle-end-phase.ts +++ b/src/phases/battle-end-phase.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { applyPostBattleAbAttrs, PostBattleAbAttr } from "#app/data/abilities/ability"; +import { applyPostBattleAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { LapsingPersistentModifier, LapsingPokemonHeldItemModifier } from "#app/modifier/modifier"; import { BattlePhase } from "./battle-phase"; @@ -65,7 +65,7 @@ export class BattleEndPhase extends BattlePhase { } for (const pokemon of globalScene.getPokemonAllowedInBattle()) { - applyPostBattleAbAttrs(PostBattleAbAttr, pokemon, false, this.isVictory); + applyPostBattleAbAttrs("PostBattleAbAttr", pokemon, false, this.isVictory); } if (globalScene.currentBattle.moneyScattered) { diff --git a/src/phases/berry-phase.ts b/src/phases/berry-phase.ts index cc990d1e2ae..c126f3306b9 100644 --- a/src/phases/berry-phase.ts +++ b/src/phases/berry-phase.ts @@ -1,9 +1,4 @@ -import { - applyAbAttrs, - PreventBerryUseAbAttr, - HealFromBerryUseAbAttr, - RepeatBerryNextTurnAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { CommonAnim } from "#enums/move-anims-common"; import { BerryUsedEvent } from "#app/events/battle-scene"; import { getPokemonNameWithAffix } from "#app/messages"; @@ -25,7 +20,7 @@ export class BerryPhase extends FieldPhase { this.executeForAll(pokemon => { this.eatBerries(pokemon); - applyAbAttrs(RepeatBerryNextTurnAbAttr, pokemon, null); + applyAbAttrs("RepeatBerryNextTurnAbAttr", pokemon, null); }); this.end(); @@ -47,7 +42,7 @@ export class BerryPhase extends FieldPhase { // TODO: If both opponents on field have unnerve, which one displays its message? const cancelled = new BooleanHolder(false); - pokemon.getOpponents().forEach(opp => applyAbAttrs(PreventBerryUseAbAttr, opp, cancelled)); + pokemon.getOpponents().forEach(opp => applyAbAttrs("PreventBerryUseAbAttr", opp, cancelled)); if (cancelled.value) { globalScene.phaseManager.queueMessage( i18next.t("abilityTriggers:preventBerryUse", { @@ -75,6 +70,6 @@ export class BerryPhase extends FieldPhase { globalScene.updateModifiers(pokemon.isPlayer()); // AbilityId.CHEEK_POUCH only works once per round of nom noms - applyAbAttrs(HealFromBerryUseAbAttr, pokemon, new BooleanHolder(false)); + applyAbAttrs("HealFromBerryUseAbAttr", pokemon, new BooleanHolder(false)); } } diff --git a/src/phases/encounter-phase.ts b/src/phases/encounter-phase.ts index 74623f947ee..f2c23384627 100644 --- a/src/phases/encounter-phase.ts +++ b/src/phases/encounter-phase.ts @@ -2,12 +2,7 @@ import { BattlerIndex } from "#enums/battler-index"; import { BattleType } from "#enums/battle-type"; import { globalScene } from "#app/global-scene"; import { PLAYER_PARTY_MAX_SIZE } from "#app/constants"; -import { - applyAbAttrs, - SyncEncounterNatureAbAttr, - applyPreSummonAbAttrs, - PreSummonAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs, applyPreSummonAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { initEncounterAnims, loadEncounterAnimAssets } from "#app/data/battle-anims"; import { getCharVariantFromDialogue } from "#app/data/dialogue"; import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils"; @@ -20,7 +15,8 @@ import type Pokemon from "#app/field/pokemon"; import { FieldPosition } from "#enums/field-position"; import { getPokemonNameWithAffix } from "#app/messages"; import { BoostBugSpawnModifier, IvScannerModifier, TurnHeldItemTransferModifier } from "#app/modifier/modifier"; -import { ModifierPoolType, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; +import { regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import Overrides from "#app/overrides"; import { BattlePhase } from "#app/phases/battle-phase"; import { achvs } from "#app/system/achv"; @@ -34,7 +30,7 @@ import { PlayerGender } from "#enums/player-gender"; import { SpeciesId } from "#enums/species-id"; import { overrideHeldItems, overrideModifiers } from "#app/modifier/modifier"; import i18next from "i18next"; -import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters"; +import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/constants"; import { getNatureName } from "#app/data/nature"; export class EncounterPhase extends BattlePhase { @@ -132,7 +128,7 @@ export class EncounterPhase extends BattlePhase { .slice(0, !battle.double ? 1 : 2) .reverse() .forEach(playerPokemon => { - applyAbAttrs(SyncEncounterNatureAbAttr, playerPokemon, null, false, battle.enemyParty[e]); + applyAbAttrs("SyncEncounterNatureAbAttr", playerPokemon, null, false, battle.enemyParty[e]); }); } } @@ -253,7 +249,7 @@ export class EncounterPhase extends BattlePhase { if (e < (battle.double ? 2 : 1)) { if (battle.battleType === BattleType.WILD) { for (const pokemon of globalScene.getField()) { - applyPreSummonAbAttrs(PreSummonAbAttr, pokemon, []); + applyPreSummonAbAttrs("PreSummonAbAttr", pokemon, []); } globalScene.field.add(enemyPokemon); battle.seenEnemyPartyMemberIds.add(enemyPokemon.id); diff --git a/src/phases/faint-phase.ts b/src/phases/faint-phase.ts index ca23b20be12..675a198d096 100644 --- a/src/phases/faint-phase.ts +++ b/src/phases/faint-phase.ts @@ -5,10 +5,7 @@ import { applyPostFaintAbAttrs, applyPostKnockOutAbAttrs, applyPostVictoryAbAttrs, - PostFaintAbAttr, - PostKnockOutAbAttr, - PostVictoryAbAttr, -} from "#app/data/abilities/ability"; +} from "#app/data/abilities/apply-ab-attrs"; import { BattlerTagLapseType } from "#enums/battler-tag-lapse-type"; import { battleSpecDialogue } from "#app/data/dialogue"; import { allMoves } from "#app/data/data-lists"; @@ -123,7 +120,7 @@ export class FaintPhase extends PokemonPhase { if (pokemon.turnData.attacksReceived?.length) { const lastAttack = pokemon.turnData.attacksReceived[0]; applyPostFaintAbAttrs( - PostFaintAbAttr, + "PostFaintAbAttr", pokemon, globalScene.getPokemonById(lastAttack.sourceId)!, new PokemonMove(lastAttack.move).getMove(), @@ -131,18 +128,18 @@ export class FaintPhase extends PokemonPhase { ); // TODO: is this bang correct? } else { //If killed by indirect damage, apply post-faint abilities without providing a last move - applyPostFaintAbAttrs(PostFaintAbAttr, pokemon); + applyPostFaintAbAttrs("PostFaintAbAttr", pokemon); } const alivePlayField = globalScene.getField(true); for (const p of alivePlayField) { - applyPostKnockOutAbAttrs(PostKnockOutAbAttr, p, pokemon); + applyPostKnockOutAbAttrs("PostKnockOutAbAttr", p, pokemon); } if (pokemon.turnData.attacksReceived?.length) { const defeatSource = this.source; if (defeatSource?.isOnField()) { - applyPostVictoryAbAttrs(PostVictoryAbAttr, defeatSource); + applyPostVictoryAbAttrs("PostVictoryAbAttr", defeatSource); const pvmove = allMoves[pokemon.turnData.attacksReceived[0].move]; const pvattrs = pvmove.getAttrs("PostVictoryStatStageChangeAttr"); if (pvattrs.length) { diff --git a/src/phases/game-over-phase.ts b/src/phases/game-over-phase.ts index 5fabc5cee81..2cd8bf120b5 100644 --- a/src/phases/game-over-phase.ts +++ b/src/phases/game-over-phase.ts @@ -7,11 +7,11 @@ import type PokemonSpecies from "#app/data/pokemon-species"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { trainerConfigs } from "#app/data/trainers/trainer-config"; import type Pokemon from "#app/field/pokemon"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { BattlePhase } from "#app/phases/battle-phase"; import type { EndCardPhase } from "#app/phases/end-card-phase"; import { achvs, ChallengeAchv } from "#app/system/achv"; -import { Unlockables } from "#app/system/unlockables"; +import { Unlockables } from "#enums/unlockables"; import { UiMode } from "#enums/ui-mode"; import { isLocal, isLocalServerConnected } from "#app/utils/common"; import { PlayerGender } from "#enums/player-gender"; diff --git a/src/phases/modifier-reward-phase.ts b/src/phases/modifier-reward-phase.ts index 83bd8704f59..29bbe215fc0 100644 --- a/src/phases/modifier-reward-phase.ts +++ b/src/phases/modifier-reward-phase.ts @@ -1,6 +1,7 @@ import { globalScene } from "#app/global-scene"; -import type { ModifierType, ModifierTypeFunc } from "#app/modifier/modifier-type"; -import { getModifierType } from "#app/modifier/modifier-type"; +import type { ModifierType } from "#app/modifier/modifier-type"; +import type { ModifierTypeFunc } from "#app/@types/modifier-types"; +import { getModifierType } from "#app/utils/modifier-utils"; import i18next from "i18next"; import { BattlePhase } from "./battle-phase"; diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index 68c96ddce1e..770d9c79a2a 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -1,21 +1,12 @@ import { BattlerIndex } from "#enums/battler-index"; import { globalScene } from "#app/global-scene"; import { - AddSecondStrikeAbAttr, - AlwaysHitAbAttr, applyExecutedMoveAbAttrs, applyPostAttackAbAttrs, applyPostDamageAbAttrs, applyPostDefendAbAttrs, applyPreAttackAbAttrs, - ExecutedMoveAbAttr, - IgnoreMoveEffectsAbAttr, - MaxMultiHitAbAttr, - PostAttackAbAttr, - PostDamageAbAttr, - PostDefendAbAttr, - ReflectStatusMoveAbAttr, -} from "#app/data/abilities/ability"; +} from "#app/data/abilities/apply-ab-attrs"; import { ConditionalProtectTag } from "#app/data/arena-tag"; import { ArenaTagSide } from "#enums/arena-tag-side"; import { MoveAnim } from "#app/data/battle-anims"; @@ -179,7 +170,7 @@ export class MoveEffectPhase extends PokemonPhase { globalScene.phaseManager.create( "ShowAbilityPhase", target.getBattlerIndex(), - target.getPassiveAbility().hasAttr(ReflectStatusMoveAbAttr), + target.getPassiveAbility().hasAttr("ReflectStatusMoveAbAttr"), ), ); this.queuedPhases.push(globalScene.phaseManager.create("HideAbilityPhase")); @@ -317,7 +308,7 @@ export class MoveEffectPhase extends PokemonPhase { // Assume single target for multi hit applyMoveAttrs("MultiHitAttr", user, this.getFirstTarget() ?? null, move, hitCount); // If Parental Bond is applicable, add another hit - applyPreAttackAbAttrs(AddSecondStrikeAbAttr, user, null, move, false, hitCount, null); + applyPreAttackAbAttrs("AddSecondStrikeAbAttr", user, null, move, false, hitCount, null); // If Multi-Lens is applicable, add hits equal to the number of held Multi-Lenses globalScene.applyModifiers(PokemonMultiHitModifier, user.isPlayer(), user, move.id, hitCount); // Set the user's relevant turnData fields to reflect the final hit count @@ -370,7 +361,7 @@ export class MoveEffectPhase extends PokemonPhase { // Add to the move history entry if (this.firstHit) { user.pushMoveHistory(this.moveHistoryEntry); - applyExecutedMoveAbAttrs(ExecutedMoveAbAttr, user); + applyExecutedMoveAbAttrs("ExecutedMoveAbAttr", user); } try { @@ -434,7 +425,7 @@ export class MoveEffectPhase extends PokemonPhase { * @returns a `Promise` intended to be passed into a `then()` call. */ protected applyOnGetHitAbEffects(user: Pokemon, target: Pokemon, hitResult: HitResult): void { - applyPostDefendAbAttrs(PostDefendAbAttr, target, user, this.move, hitResult); + applyPostDefendAbAttrs("PostDefendAbAttr", target, user, this.move, hitResult); target.lapseTags(BattlerTagLapseType.AFTER_HIT); } @@ -450,7 +441,11 @@ export class MoveEffectPhase extends PokemonPhase { return; } - if (dealsDamage && !target.hasAbilityWithAttr(IgnoreMoveEffectsAbAttr) && !this.move.hitsSubstitute(user, target)) { + if ( + dealsDamage && + !target.hasAbilityWithAttr("IgnoreMoveEffectsAbAttr") && + !this.move.hitsSubstitute(user, target) + ) { const flinched = new BooleanHolder(false); globalScene.applyModifiers(FlinchChanceModifier, user.isPlayer(), user, flinched); if (flinched.value) { @@ -580,7 +575,7 @@ export class MoveEffectPhase extends PokemonPhase { // Strikes after the first in a multi-strike move are guaranteed to hit, // unless the move is flagged to check all hits and the user does not have Skill Link. if (user.turnData.hitsLeft < user.turnData.hitCount) { - if (!move.hasFlag(MoveFlags.CHECK_ALL_HITS) || user.hasAbilityWithAttr(MaxMultiHitAbAttr)) { + if (!move.hasFlag(MoveFlags.CHECK_ALL_HITS) || user.hasAbilityWithAttr("MaxMultiHitAbAttr")) { return [HitCheckResult.HIT, effectiveness]; } } @@ -626,7 +621,7 @@ export class MoveEffectPhase extends PokemonPhase { if (!user) { return false; } - if (user.hasAbilityWithAttr(AlwaysHitAbAttr) || target.hasAbilityWithAttr(AlwaysHitAbAttr)) { + if (user.hasAbilityWithAttr("AlwaysHitAbAttr") || target.hasAbilityWithAttr("AlwaysHitAbAttr")) { return true; } if (this.move.hasAttr("ToxicAccuracyAttr") && user.isOfType(PokemonType.POISON)) { @@ -789,7 +784,7 @@ export class MoveEffectPhase extends PokemonPhase { // Multi-hit check for Wimp Out/Emergency Exit if (user.turnData.hitCount > 1) { - applyPostDamageAbAttrs(PostDamageAbAttr, target, 0, target.hasPassive(), false, [], user); + applyPostDamageAbAttrs("PostDamageAbAttr", target, 0, target.hasPassive(), false, [], user); } } } @@ -983,7 +978,7 @@ export class MoveEffectPhase extends PokemonPhase { this.triggerMoveEffects(MoveEffectTrigger.POST_APPLY, user, target, firstTarget, false); this.applyHeldItemFlinchCheck(user, target, dealsDamage); this.applyOnGetHitAbEffects(user, target, hitResult); - applyPostAttackAbAttrs(PostAttackAbAttr, user, target, this.move, hitResult); + applyPostAttackAbAttrs("PostAttackAbAttr", user, target, this.move, hitResult); // We assume only enemy Pokemon are able to have the EnemyAttackStatusEffectChanceModifier from tokens if (!user.isPlayer() && this.move.is("AttackMove")) { diff --git a/src/phases/move-end-phase.ts b/src/phases/move-end-phase.ts index e5f87089fae..953f8eae4ce 100644 --- a/src/phases/move-end-phase.ts +++ b/src/phases/move-end-phase.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { BattlerTagLapseType } from "#enums/battler-tag-lapse-type"; import { PokemonPhase } from "./pokemon-phase"; import type { BattlerIndex } from "#enums/battler-index"; -import { applyPostSummonAbAttrs, PostSummonRemoveEffectAbAttr } from "#app/data/abilities/ability"; +import { applyPostSummonAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import type Pokemon from "#app/field/pokemon"; export class MoveEndPhase extends PokemonPhase { @@ -30,7 +30,7 @@ export class MoveEndPhase extends PokemonPhase { // Remove effects which were set on a Pokemon which removes them on summon (i.e. via Mold Breaker) for (const target of this.targets) { if (target) { - applyPostSummonAbAttrs(PostSummonRemoveEffectAbAttr, target); + applyPostSummonAbAttrs("PostSummonRemoveEffectAbAttr", target); } } diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index ca66ca745e7..d72c7396f1f 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -1,16 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import { globalScene } from "#app/global-scene"; -import { - applyAbAttrs, - applyPostMoveUsedAbAttrs, - applyPreAttackAbAttrs, - BlockRedirectAbAttr, - IncreasePpAbAttr, - PokemonTypeChangeAbAttr, - PostMoveUsedAbAttr, - RedirectMoveAbAttr, - ReduceStatusEffectDurationAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs, applyPostMoveUsedAbAttrs, applyPreAttackAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import type { DelayedAttackTag } from "#app/data/arena-tag"; import { CommonAnim } from "#enums/move-anims-common"; import { CenterOfAttentionTag } from "#app/data/battler-tags"; @@ -228,7 +218,7 @@ export class MovePhase extends BattlePhase { applyMoveAttrs("BypassSleepAttr", this.pokemon, null, this.move.getMove()); const turnsRemaining = new NumberHolder(this.pokemon.status.sleepTurnsRemaining ?? 0); applyAbAttrs( - ReduceStatusEffectDurationAbAttr, + "ReduceStatusEffectDurationAbAttr", this.pokemon, null, false, @@ -396,7 +386,7 @@ export class MovePhase extends BattlePhase { */ if (success) { const move = this.move.getMove(); - applyPreAttackAbAttrs(PokemonTypeChangeAbAttr, this.pokemon, null, move); + applyPreAttackAbAttrs("PokemonTypeChangeAbAttr", this.pokemon, null, move); globalScene.phaseManager.unshiftNew( "MoveEffectPhase", this.pokemon.getBattlerIndex(), @@ -407,7 +397,7 @@ export class MovePhase extends BattlePhase { ); } else { if ([MoveId.ROAR, MoveId.WHIRLWIND, MoveId.TRICK_OR_TREAT, MoveId.FORESTS_CURSE].includes(this.move.moveId)) { - applyPreAttackAbAttrs(PokemonTypeChangeAbAttr, this.pokemon, null, this.move.getMove()); + applyPreAttackAbAttrs("PokemonTypeChangeAbAttr", this.pokemon, null, this.move.getMove()); } this.pokemon.pushMoveHistory({ @@ -437,7 +427,7 @@ export class MovePhase extends BattlePhase { // Note that the `!this.followUp` check here prevents an infinite Dancer loop. if (this.move.getMove().hasFlag(MoveFlags.DANCE_MOVE) && !this.followUp) { globalScene.getField(true).forEach(pokemon => { - applyPostMoveUsedAbAttrs(PostMoveUsedAbAttr, pokemon, this.move, this.pokemon, this.targets); + applyPostMoveUsedAbAttrs("PostMoveUsedAbAttr", pokemon, this.move, this.pokemon, this.targets); }); } } @@ -449,7 +439,7 @@ export class MovePhase extends BattlePhase { if (move.applyConditions(this.pokemon, targets[0], move)) { // Protean and Libero apply on the charging turn of charge moves - applyPreAttackAbAttrs(PokemonTypeChangeAbAttr, this.pokemon, null, this.move.getMove()); + applyPreAttackAbAttrs("PokemonTypeChangeAbAttr", this.pokemon, null, this.move.getMove()); this.showMoveText(); globalScene.phaseManager.unshiftNew( @@ -498,7 +488,7 @@ export class MovePhase extends BattlePhase { public getPpIncreaseFromPressure(targets: Pokemon[]): number { const foesWithPressure = this.pokemon .getOpponents() - .filter(o => targets.includes(o) && o.isActive(true) && o.hasAbilityWithAttr(IncreasePpAbAttr)); + .filter(o => targets.includes(o) && o.isActive(true) && o.hasAbilityWithAttr("IncreasePpAbAttr")); return foesWithPressure.length; } @@ -516,7 +506,9 @@ export class MovePhase extends BattlePhase { globalScene .getField(true) .filter(p => p !== this.pokemon) - .forEach(p => applyAbAttrs(RedirectMoveAbAttr, p, null, false, this.move.moveId, redirectTarget, this.pokemon)); + .forEach(p => + applyAbAttrs("RedirectMoveAbAttr", p, null, false, this.move.moveId, redirectTarget, this.pokemon), + ); /** `true` if an Ability is responsible for redirecting the move to another target; `false` otherwise */ let redirectedByAbility = currentTarget !== redirectTarget.value; @@ -545,17 +537,17 @@ export class MovePhase extends BattlePhase { } }); - if (this.pokemon.hasAbilityWithAttr(BlockRedirectAbAttr)) { + if (this.pokemon.hasAbilityWithAttr("BlockRedirectAbAttr")) { redirectTarget.value = currentTarget; // TODO: Ability displays should be handled by the ability globalScene.phaseManager.queueAbilityDisplay( this.pokemon, - this.pokemon.getPassiveAbility().hasAttr(BlockRedirectAbAttr), + this.pokemon.getPassiveAbility().hasAttr("BlockRedirectAbAttr"), true, ); globalScene.phaseManager.queueAbilityDisplay( this.pokemon, - this.pokemon.getPassiveAbility().hasAttr(BlockRedirectAbAttr), + this.pokemon.getPassiveAbility().hasAttr("BlockRedirectAbAttr"), false, ); } diff --git a/src/phases/new-biome-encounter-phase.ts b/src/phases/new-biome-encounter-phase.ts index 29ba67cb797..5aad607764f 100644 --- a/src/phases/new-biome-encounter-phase.ts +++ b/src/phases/new-biome-encounter-phase.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { applyAbAttrs, PostBiomeChangeAbAttr } from "#app/data/abilities/ability"; +import { applyAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { getRandomWeatherType } from "#app/data/weather"; import { NextEncounterPhase } from "./next-encounter-phase"; @@ -14,7 +14,7 @@ export class NewBiomeEncounterPhase extends NextEncounterPhase { if (pokemon) { pokemon.resetBattleAndWaveData(); if (pokemon.isOnField()) { - applyAbAttrs(PostBiomeChangeAbAttr, pokemon, null); + applyAbAttrs("PostBiomeChangeAbAttr", pokemon, null); } } } diff --git a/src/phases/obtain-status-effect-phase.ts b/src/phases/obtain-status-effect-phase.ts index bf172269d5f..dc26d070029 100644 --- a/src/phases/obtain-status-effect-phase.ts +++ b/src/phases/obtain-status-effect-phase.ts @@ -8,7 +8,7 @@ import type Pokemon from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; import { PokemonPhase } from "./pokemon-phase"; import { SpeciesFormChangeStatusEffectTrigger } from "#app/data/pokemon-forms/form-change-triggers"; -import { applyPostSetStatusAbAttrs, PostSetStatusAbAttr } from "#app/data/abilities/ability"; +import { applyPostSetStatusAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { isNullOrUndefined } from "#app/utils/common"; export class ObtainStatusEffectPhase extends PokemonPhase { @@ -53,7 +53,7 @@ export class ObtainStatusEffectPhase extends PokemonPhase { globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeStatusEffectTrigger, true); // If mold breaker etc was used to set this status, it shouldn't apply to abilities activated afterwards globalScene.arena.setIgnoreAbilities(false); - applyPostSetStatusAbAttrs(PostSetStatusAbAttr, pokemon, this.statusEffect, this.sourcePokemon); + applyPostSetStatusAbAttrs("PostSetStatusAbAttr", pokemon, this.statusEffect, this.sourcePokemon); } this.end(); }); diff --git a/src/phases/post-summon-phase.ts b/src/phases/post-summon-phase.ts index a7faf614292..3acd7ca24e9 100644 --- a/src/phases/post-summon-phase.ts +++ b/src/phases/post-summon-phase.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { applyAbAttrs, applyPostSummonAbAttrs, CommanderAbAttr, PostSummonAbAttr } from "#app/data/abilities/ability"; +import { applyAbAttrs, applyPostSummonAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { ArenaTrapTag } from "#app/data/arena-tag"; import { StatusEffect } from "#app/enums/status-effect"; import { PokemonPhase } from "./pokemon-phase"; @@ -26,10 +26,10 @@ export class PostSummonPhase extends PokemonPhase { pokemon.lapseTag(BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON); } - applyPostSummonAbAttrs(PostSummonAbAttr, pokemon); + applyPostSummonAbAttrs("PostSummonAbAttr", pokemon); const field = pokemon.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); for (const p of field) { - applyAbAttrs(CommanderAbAttr, p, null, false); + applyAbAttrs("CommanderAbAttr", p, null, false); } this.end(); diff --git a/src/phases/post-turn-status-effect-phase.ts b/src/phases/post-turn-status-effect-phase.ts index c868b963f39..e0a3bb5c00b 100644 --- a/src/phases/post-turn-status-effect-phase.ts +++ b/src/phases/post-turn-status-effect-phase.ts @@ -1,13 +1,6 @@ import { globalScene } from "#app/global-scene"; import type { BattlerIndex } from "#enums/battler-index"; -import { - applyAbAttrs, - applyPostDamageAbAttrs, - BlockNonDirectDamageAbAttr, - BlockStatusDamageAbAttr, - PostDamageAbAttr, - ReduceBurnDamageAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs, applyPostDamageAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { CommonBattleAnim } from "#app/data/battle-anims"; import { CommonAnim } from "#enums/move-anims-common"; import { getStatusEffectActivationText } from "#app/data/status-effect"; @@ -29,8 +22,8 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { if (pokemon?.isActive(true) && pokemon.status && pokemon.status.isPostTurn() && !pokemon.switchOutStatus) { pokemon.status.incrementTurn(); const cancelled = new BooleanHolder(false); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); - applyAbAttrs(BlockStatusDamageAbAttr, pokemon, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); + applyAbAttrs("BlockStatusDamageAbAttr", pokemon, cancelled); if (!cancelled.value) { globalScene.phaseManager.queueMessage( @@ -46,14 +39,14 @@ export class PostTurnStatusEffectPhase extends PokemonPhase { break; case StatusEffect.BURN: damage.value = Math.max(pokemon.getMaxHp() >> 4, 1); - applyAbAttrs(ReduceBurnDamageAbAttr, pokemon, null, false, damage); + applyAbAttrs("ReduceBurnDamageAbAttr", pokemon, null, false, damage); break; } if (damage.value) { // Set preventEndure flag to avoid pokemon surviving thanks to focus band, sturdy, endure ... globalScene.damageNumberHandler.add(this.getPokemon(), pokemon.damage(damage.value, false, true)); pokemon.updateInfo(); - applyPostDamageAbAttrs(PostDamageAbAttr, pokemon, damage.value, pokemon.hasPassive(), false, []); + applyPostDamageAbAttrs("PostDamageAbAttr", pokemon, damage.value, pokemon.hasPassive(), false, []); } new CommonBattleAnim(CommonAnim.POISON + (pokemon.status.effect - 1), pokemon).play(false, () => this.end()); } else { diff --git a/src/phases/quiet-form-change-phase.ts b/src/phases/quiet-form-change-phase.ts index cfd9c521e2b..e6a00c73756 100644 --- a/src/phases/quiet-form-change-phase.ts +++ b/src/phases/quiet-form-change-phase.ts @@ -12,12 +12,7 @@ import type Pokemon from "#app/field/pokemon"; import { getPokemonNameWithAffix } from "#app/messages"; import { BattlePhase } from "./battle-phase"; import type { MovePhase } from "./move-phase"; -import { - applyAbAttrs, - ClearTerrainAbAttr, - ClearWeatherAbAttr, - PostTeraFormChangeStatChangeAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs } from "#app/data/abilities/apply-ab-attrs"; export class QuietFormChangePhase extends BattlePhase { public readonly phaseName = "QuietFormChangePhase"; @@ -185,9 +180,9 @@ export class QuietFormChangePhase extends BattlePhase { } } if (this.formChange.trigger instanceof SpeciesFormChangeTeraTrigger) { - applyAbAttrs(PostTeraFormChangeStatChangeAbAttr, this.pokemon, null); - applyAbAttrs(ClearWeatherAbAttr, this.pokemon, null); - applyAbAttrs(ClearTerrainAbAttr, this.pokemon, null); + applyAbAttrs("PostTeraFormChangeStatChangeAbAttr", this.pokemon, null); + applyAbAttrs("ClearWeatherAbAttr", this.pokemon, null); + applyAbAttrs("ClearTerrainAbAttr", this.pokemon, null); } super.end(); diff --git a/src/phases/ribbon-modifier-reward-phase.ts b/src/phases/ribbon-modifier-reward-phase.ts index 949f7af0302..10d63ba707f 100644 --- a/src/phases/ribbon-modifier-reward-phase.ts +++ b/src/phases/ribbon-modifier-reward-phase.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import type PokemonSpecies from "#app/data/pokemon-species"; -import type { ModifierTypeFunc } from "#app/modifier/modifier-type"; +import type { ModifierTypeFunc } from "#app/@types/modifier-types"; import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; import { ModifierRewardPhase } from "./modifier-reward-phase"; diff --git a/src/phases/select-modifier-phase.ts b/src/phases/select-modifier-phase.ts index f99c921412f..34a905f64c6 100644 --- a/src/phases/select-modifier-phase.ts +++ b/src/phases/select-modifier-phase.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import type { ModifierTier } from "#app/modifier/modifier-tier"; +import type { ModifierTier } from "#enums/modifier-tier"; import type { ModifierTypeOption, ModifierType } from "#app/modifier/modifier-type"; import { regenerateModifierPoolThresholds, @@ -11,9 +11,9 @@ import { RememberMoveModifierType, PokemonPpRestoreModifierType, PokemonPpUpModifierType, - ModifierPoolType, getPlayerModifierTypeOptions, } from "#app/modifier/modifier-type"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import type { Modifier } from "#app/modifier/modifier"; import { ExtraModifierModifier, diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index 9c351096180..e73f72f7a63 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -4,13 +4,7 @@ import { applyAbAttrs, applyPostStatStageChangeAbAttrs, applyPreStatStageChangeAbAttrs, - ConditionalUserFieldProtectStatAbAttr, - PostStatStageChangeAbAttr, - ProtectStatAbAttr, - ReflectStatStageChangeAbAttr, - StatStageChangeCopyAbAttr, - StatStageChangeMultiplierAbAttr, -} from "#app/data/abilities/ability"; +} from "#app/data/abilities/apply-ab-attrs"; import { MistTag } from "#app/data/arena-tag"; import { ArenaTagSide } from "#enums/arena-tag-side"; import type { ArenaTag } from "#app/data/arena-tag"; @@ -132,7 +126,7 @@ export class StatStageChangePhase extends PokemonPhase { const stages = new NumberHolder(this.stages); if (!this.ignoreAbilities) { - applyAbAttrs(StatStageChangeMultiplierAbAttr, pokemon, null, false, stages); + applyAbAttrs("StatStageChangeMultiplierAbAttr", pokemon, null, false, stages); } let simulate = false; @@ -152,9 +146,9 @@ export class StatStageChangePhase extends PokemonPhase { } if (!cancelled.value && !this.selfTarget && stages.value < 0) { - applyPreStatStageChangeAbAttrs(ProtectStatAbAttr, pokemon, stat, cancelled, simulate); + applyPreStatStageChangeAbAttrs("ProtectStatAbAttr", pokemon, stat, cancelled, simulate); applyPreStatStageChangeAbAttrs( - ConditionalUserFieldProtectStatAbAttr, + "ConditionalUserFieldProtectStatAbAttr", pokemon, stat, cancelled, @@ -164,7 +158,7 @@ export class StatStageChangePhase extends PokemonPhase { const ally = pokemon.getAlly(); if (!isNullOrUndefined(ally)) { applyPreStatStageChangeAbAttrs( - ConditionalUserFieldProtectStatAbAttr, + "ConditionalUserFieldProtectStatAbAttr", ally, stat, cancelled, @@ -180,7 +174,7 @@ export class StatStageChangePhase extends PokemonPhase { !this.comingFromMirrorArmorUser ) { applyPreStatStageChangeAbAttrs( - ReflectStatStageChangeAbAttr, + "ReflectStatStageChangeAbAttr", pokemon, stat, cancelled, @@ -228,11 +222,17 @@ export class StatStageChangePhase extends PokemonPhase { if (stages.value > 0 && this.canBeCopied) { for (const opponent of pokemon.getOpponents()) { - applyAbAttrs(StatStageChangeCopyAbAttr, opponent, null, false, this.stats, stages.value); + applyAbAttrs("StatStageChangeCopyAbAttr", opponent, null, false, this.stats, stages.value); } } - applyPostStatStageChangeAbAttrs(PostStatStageChangeAbAttr, pokemon, filteredStats, this.stages, this.selfTarget); + applyPostStatStageChangeAbAttrs( + "PostStatStageChangeAbAttr", + pokemon, + filteredStats, + this.stages, + this.selfTarget, + ); // Look for any other stat change phases; if this is the last one, do White Herb check const existingPhase = globalScene.phaseManager.findPhase( diff --git a/src/phases/summon-phase.ts b/src/phases/summon-phase.ts index e902fd0183e..ad93452331f 100644 --- a/src/phases/summon-phase.ts +++ b/src/phases/summon-phase.ts @@ -10,7 +10,7 @@ import { getPokemonNameWithAffix } from "#app/messages"; import i18next from "i18next"; import { PartyMemberPokemonPhase } from "./party-member-pokemon-phase"; import { MysteryEncounterMode } from "#enums/mystery-encounter-mode"; -import { applyPreSummonAbAttrs, PreSummonAbAttr } from "#app/data/abilities/ability"; +import { applyPreSummonAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { globalScene } from "#app/global-scene"; export class SummonPhase extends PartyMemberPokemonPhase { @@ -27,7 +27,7 @@ export class SummonPhase extends PartyMemberPokemonPhase { start() { super.start(); - applyPreSummonAbAttrs(PreSummonAbAttr, this.getPokemon()); + applyPreSummonAbAttrs("PreSummonAbAttr", this.getPokemon()); this.preSummon(); } diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index 71136be0c93..6b76d4e8926 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -1,11 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { - applyPreSummonAbAttrs, - applyPreSwitchOutAbAttrs, - PostDamageForceSwitchAbAttr, - PreSummonAbAttr, - PreSwitchOutAbAttr, -} from "#app/data/abilities/ability"; +import { applyPreSummonAbAttrs, applyPreSwitchOutAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { allMoves } from "#app/data/data-lists"; import { getPokeballTintColor } from "#app/data/pokeball"; import { SpeciesFormChangeActiveTrigger } from "#app/data/pokemon-forms/form-change-triggers"; @@ -130,8 +124,8 @@ export class SwitchSummonPhase extends SummonPhase { switchedInPokemon.resetSummonData(); switchedInPokemon.loadAssets(true); - applyPreSummonAbAttrs(PreSummonAbAttr, switchedInPokemon); - applyPreSwitchOutAbAttrs(PreSwitchOutAbAttr, this.lastPokemon); + applyPreSummonAbAttrs("PreSummonAbAttr", switchedInPokemon); + applyPreSwitchOutAbAttrs("PreSwitchOutAbAttr", this.lastPokemon); if (!switchedInPokemon) { this.end(); return; @@ -215,7 +209,7 @@ export class SwitchSummonPhase extends SummonPhase { const lastPokemonIsForceSwitchedAndNotFainted = lastUsedMove?.hasAttr("ForceSwitchOutAttr") && !this.lastPokemon.isFainted(); const lastPokemonHasForceSwitchAbAttr = - this.lastPokemon.hasAbilityWithAttr(PostDamageForceSwitchAbAttr) && !this.lastPokemon.isFainted(); + this.lastPokemon.hasAbilityWithAttr("PostDamageForceSwitchAbAttr") && !this.lastPokemon.isFainted(); // Compensate for turn spent summoning/forced switch if switched out pokemon is not fainted. // Needed as we increment turn counters in `TurnEndPhase`. diff --git a/src/phases/title-phase.ts b/src/phases/title-phase.ts index 26311d52ab8..5e36081b899 100644 --- a/src/phases/title-phase.ts +++ b/src/phases/title-phase.ts @@ -6,15 +6,12 @@ import { getBiomeKey } from "#app/field/arena"; import { GameMode, getGameMode } from "#app/game-mode"; import { GameModes } from "#enums/game-modes"; import type { Modifier } from "#app/modifier/modifier"; -import { - getDailyRunStarterModifiers, - ModifierPoolType, - modifierTypes, - regenerateModifierPoolThresholds, -} from "#app/modifier/modifier-type"; +import { getDailyRunStarterModifiers, regenerateModifierPoolThresholds } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; +import { ModifierPoolType } from "#enums/modifier-pool-type"; import { Phase } from "#app/phase"; import type { SessionSaveData } from "#app/system/game-data"; -import { Unlockables } from "#app/system/unlockables"; +import { Unlockables } from "#enums/unlockables"; import { vouchers } from "#app/system/voucher"; import type { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler"; import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler"; diff --git a/src/phases/trainer-victory-phase.ts b/src/phases/trainer-victory-phase.ts index 5d35dd5d375..554b8109f02 100644 --- a/src/phases/trainer-victory-phase.ts +++ b/src/phases/trainer-victory-phase.ts @@ -1,6 +1,6 @@ import { getCharVariantFromDialogue } from "#app/data/dialogue"; import { TrainerType } from "#app/enums/trainer-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { vouchers } from "#app/system/voucher"; import i18next from "i18next"; import { randSeedItem } from "#app/utils/common"; diff --git a/src/phases/turn-end-phase.ts b/src/phases/turn-end-phase.ts index a539b234a18..ab46292c1d2 100644 --- a/src/phases/turn-end-phase.ts +++ b/src/phases/turn-end-phase.ts @@ -1,4 +1,4 @@ -import { applyPostTurnAbAttrs, PostTurnAbAttr } from "#app/data/abilities/ability"; +import { applyPostTurnAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { BattlerTagLapseType } from "#enums/battler-tag-lapse-type"; import { TerrainType } from "#app/data/terrain"; import { WeatherType } from "#app/enums/weather-type"; @@ -49,7 +49,7 @@ export class TurnEndPhase extends FieldPhase { globalScene.applyModifier(EnemyStatusEffectHealChanceModifier, false, pokemon); } - applyPostTurnAbAttrs(PostTurnAbAttr, pokemon); + applyPostTurnAbAttrs("PostTurnAbAttr", pokemon); } globalScene.applyModifiers(TurnStatusEffectModifier, pokemon.isPlayer(), pokemon); diff --git a/src/phases/turn-start-phase.ts b/src/phases/turn-start-phase.ts index e9a8a82afdc..6f062cb5fbe 100644 --- a/src/phases/turn-start-phase.ts +++ b/src/phases/turn-start-phase.ts @@ -1,4 +1,4 @@ -import { applyAbAttrs, BypassSpeedChanceAbAttr, PreventBypassSpeedChanceAbAttr } from "#app/data/abilities/ability"; +import { applyAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { allMoves } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { Stat } from "#app/enums/stat"; @@ -66,8 +66,8 @@ export class TurnStartPhase extends FieldPhase { globalScene.getField(true).map(p => { const bypassSpeed = new BooleanHolder(false); const canCheckHeldItems = new BooleanHolder(true); - applyAbAttrs(BypassSpeedChanceAbAttr, p, null, false, bypassSpeed); - applyAbAttrs(PreventBypassSpeedChanceAbAttr, p, null, false, bypassSpeed, canCheckHeldItems); + applyAbAttrs("BypassSpeedChanceAbAttr", p, null, false, bypassSpeed); + applyAbAttrs("PreventBypassSpeedChanceAbAttr", p, null, false, bypassSpeed, canCheckHeldItems); if (canCheckHeldItems.value) { globalScene.applyModifiers(BypassSpeedChanceModifier, p.isPlayer(), p, bypassSpeed); } diff --git a/src/phases/unlock-phase.ts b/src/phases/unlock-phase.ts index 839ac31dc5d..76719847f92 100644 --- a/src/phases/unlock-phase.ts +++ b/src/phases/unlock-phase.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import { Phase } from "#app/phase"; -import type { Unlockables } from "#app/system/unlockables"; +import type { Unlockables } from "#enums/unlockables"; import { getUnlockableName } from "#app/system/unlockables"; import { UiMode } from "#enums/ui-mode"; import i18next from "i18next"; diff --git a/src/phases/victory-phase.ts b/src/phases/victory-phase.ts index bf6ea6d4a43..ae5b727c2a6 100644 --- a/src/phases/victory-phase.ts +++ b/src/phases/victory-phase.ts @@ -2,7 +2,7 @@ import type { BattlerIndex } from "#enums/battler-index"; import { ClassicFixedBossWaves } from "#enums/fixed-boss-waves"; import { BattleType } from "#enums/battle-type"; import type { CustomModifierSettings } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { PokemonPhase } from "./pokemon-phase"; import { handleMysteryEncounterVictory } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; import { globalScene } from "#app/global-scene"; diff --git a/src/phases/weather-effect-phase.ts b/src/phases/weather-effect-phase.ts index 0873283652e..d9239220376 100644 --- a/src/phases/weather-effect-phase.ts +++ b/src/phases/weather-effect-phase.ts @@ -1,13 +1,9 @@ import { globalScene } from "#app/global-scene"; import { applyPreWeatherEffectAbAttrs, - SuppressWeatherEffectAbAttr, - PreWeatherDamageAbAttr, applyAbAttrs, - BlockNonDirectDamageAbAttr, applyPostWeatherLapseAbAttrs, - PostWeatherLapseAbAttr, -} from "#app/data/abilities/ability"; +} from "#app/data/abilities/apply-ab-attrs"; import { CommonAnim } from "#enums/move-anims-common"; import type { Weather } from "#app/data/weather"; import { getWeatherDamageMessage, getWeatherLapseMessage } from "#app/data/weather"; @@ -45,15 +41,15 @@ export class WeatherEffectPhase extends CommonAnimPhase { const cancelled = new BooleanHolder(false); this.executeForAll((pokemon: Pokemon) => - applyPreWeatherEffectAbAttrs(SuppressWeatherEffectAbAttr, pokemon, this.weather, cancelled), + applyPreWeatherEffectAbAttrs("SuppressWeatherEffectAbAttr", pokemon, this.weather, cancelled), ); if (!cancelled.value) { const inflictDamage = (pokemon: Pokemon) => { const cancelled = new BooleanHolder(false); - applyPreWeatherEffectAbAttrs(PreWeatherDamageAbAttr, pokemon, this.weather, cancelled); - applyAbAttrs(BlockNonDirectDamageAbAttr, pokemon, cancelled); + applyPreWeatherEffectAbAttrs("PreWeatherDamageAbAttr", pokemon, this.weather, cancelled); + applyAbAttrs("BlockNonDirectDamageAbAttr", pokemon, cancelled); if ( cancelled.value || @@ -84,7 +80,7 @@ export class WeatherEffectPhase extends CommonAnimPhase { globalScene.ui.showText(getWeatherLapseMessage(this.weather.weatherType) ?? "", null, () => { this.executeForAll((pokemon: Pokemon) => { if (!pokemon.switchOutStatus) { - applyPostWeatherLapseAbAttrs(PostWeatherLapseAbAttr, pokemon, this.weather); + applyPostWeatherLapseAbAttrs("PostWeatherLapseAbAttr", pokemon, this.weather); } }); diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 31c7ad7e41c..00b46b9e5f4 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -13,7 +13,7 @@ import Overrides from "#app/overrides"; import PokemonData from "#app/system/pokemon-data"; import PersistentModifierData from "#app/system/modifier-data"; import ArenaData from "#app/system/arena-data"; -import { Unlockables } from "#app/system/unlockables"; +import { Unlockables } from "#enums/unlockables"; import { getGameMode } from "#app/game-mode"; import { GameModes } from "#enums/game-modes"; import { BattleType } from "#enums/battle-type"; diff --git a/src/system/unlockables.ts b/src/system/unlockables.ts index f64d4d33966..72588858eae 100644 --- a/src/system/unlockables.ts +++ b/src/system/unlockables.ts @@ -1,13 +1,7 @@ import i18next from "i18next"; import { GameMode } from "../game-mode"; import { GameModes } from "#enums/game-modes"; - -export enum Unlockables { - ENDLESS_MODE, - MINI_BLACK_HOLE, - SPLICED_ENDLESS_MODE, - EVIOLITE, -} +import { Unlockables } from "#enums/unlockables"; export function getUnlockableName(unlockable: Unlockables) { switch (unlockable) { diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index f60bfa808ca..a2dfe83e996 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -7,11 +7,7 @@ import { Command } from "#enums/command"; import MessageUiHandler from "#app/ui/message-ui-handler"; import { UiMode } from "#enums/ui-mode"; import { BooleanHolder, toReadableString, randInt, getLocalizedSpriteKey } from "#app/utils/common"; -import { - PokemonFormChangeItemModifier, - PokemonHeldItemModifier, - SwitchEffectTransferModifier, -} from "#app/modifier/modifier"; +import type { PokemonFormChangeItemModifier, PokemonHeldItemModifier } from "#app/modifier/modifier"; import { allMoves } from "#app/data/data-lists"; import { Gender, getGenderColor, getGenderSymbol } from "#app/data/gender"; import { StatusEffect } from "#enums/status-effect"; @@ -226,7 +222,7 @@ export default class PartyUiHandler extends MessageUiHandler { public static FilterItemMaxStacks = (pokemon: PlayerPokemon, modifier: PokemonHeldItemModifier) => { const matchingModifier = globalScene.findModifier( - m => m instanceof PokemonHeldItemModifier && m.pokemonId === pokemon.id && m.matchType(modifier), + m => m.is("PokemonHeldItemModifier") && m.pokemonId === pokemon.id && m.matchType(modifier), ) as PokemonHeldItemModifier; if (matchingModifier && matchingModifier.stackCount === matchingModifier.getMaxStackCount()) { return i18next.t("partyUiHandler:tooManyItems", { pokemonName: getPokemonNameWithAffix(pokemon, false) }); @@ -554,7 +550,7 @@ export default class PartyUiHandler extends MessageUiHandler { // this returns `undefined` if the new pokemon doesn't have the item at all, otherwise it returns the `pokemonHeldItemModifier` for that item const matchingModifier = globalScene.findModifier( m => - m instanceof PokemonHeldItemModifier && + m.is("PokemonHeldItemModifier") && m.pokemonId === newPokemon.id && m.matchType(this.getTransferrableItemsFromPokemon(pokemon)[this.transferOptionCursor]), ) as PokemonHeldItemModifier; @@ -687,7 +683,7 @@ export default class PartyUiHandler extends MessageUiHandler { private getTransferrableItemsFromPokemon(pokemon: PlayerPokemon) { return globalScene.findModifiers( - m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === pokemon.id, + m => m.is("PokemonHeldItemModifier") && m.isTransferable && m.pokemonId === pokemon.id, ) as PokemonHeldItemModifier[]; } @@ -928,7 +924,7 @@ export default class PartyUiHandler extends MessageUiHandler { /** Initialize item quantities for the selected Pokemon */ const itemModifiers = globalScene.findModifiers( m => - m instanceof PokemonHeldItemModifier && + m.is("PokemonHeldItemModifier") && m.isTransferable && m.pokemonId === globalScene.getPlayerParty()[this.cursor].id, ) as PokemonHeldItemModifier[]; @@ -1165,8 +1161,7 @@ export default class PartyUiHandler extends MessageUiHandler { return !!( this.partyUiMode !== PartyUiMode.FAINT_SWITCH && globalScene.findModifier( - m => - m instanceof SwitchEffectTransferModifier && m.pokemonId === globalScene.getPlayerField()[this.fieldIndex].id, + m => m.is("SwitchEffectTransferModifier") && m.pokemonId === globalScene.getPlayerField()[this.fieldIndex].id, ) ); } @@ -1185,7 +1180,7 @@ export default class PartyUiHandler extends MessageUiHandler { private getItemModifiers(pokemon: Pokemon): PokemonHeldItemModifier[] { return ( (globalScene.findModifiers( - m => m instanceof PokemonHeldItemModifier && m.isTransferable && m.pokemonId === pokemon.id, + m => m.is("PokemonHeldItemModifier") && m.isTransferable && m.pokemonId === pokemon.id, ) as PokemonHeldItemModifier[]) ?? [] ); } @@ -1565,7 +1560,7 @@ export default class PartyUiHandler extends MessageUiHandler { getFormChangeItemsModifiers(pokemon: Pokemon) { let formChangeItemModifiers = globalScene.findModifiers( - m => m instanceof PokemonFormChangeItemModifier && m.pokemonId === pokemon.id, + m => m.is("PokemonFormChangeItemModifier") && m.pokemonId === pokemon.id, ) as PokemonFormChangeItemModifier[]; const ultraNecrozmaModifiers = formChangeItemModifiers.filter( m => m.active && m.formChangeItem === FormChangeItem.ULTRANECROZIUM_Z, diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 0b1e690a918..88f881746bb 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -8,7 +8,7 @@ import i18next from "i18next"; import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import { starterColors } from "#app/global-vars/starter-colors"; import { globalScene } from "#app/global-scene"; -import type { Ability } from "#app/data/abilities/ability-class"; +import type { Ability } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; import { speciesEggMoves } from "#app/data/balance/egg-moves"; import { GrowthRate, getGrowthRateColor } from "#app/data/exp"; diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index 05b0ea2097f..d30322de293 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -33,7 +33,7 @@ import { loggedInUser } from "#app/account"; import type { Variant } from "#app/sprites/variant"; import { getVariantTint } from "#app/sprites/variant"; import { Button } from "#enums/buttons"; -import type { Ability } from "#app/data/abilities/ability-class"; +import type { Ability } from "#app/data/abilities/ability"; import i18next from "i18next"; import { modifierSortFunc } from "#app/modifier/modifier"; import { PlayerGender } from "#enums/player-gender"; diff --git a/src/ui/text.ts b/src/ui/text.ts index d3afdef666f..8812d8ee4a8 100644 --- a/src/ui/text.ts +++ b/src/ui/text.ts @@ -4,7 +4,7 @@ import type Phaser from "phaser"; import BBCodeText from "phaser3-rex-plugins/plugins/gameobjects/tagtext/bbcodetext/BBCodeText"; import InputText from "phaser3-rex-plugins/plugins/inputtext"; import { globalScene } from "#app/global-scene"; -import { ModifierTier } from "../modifier/modifier-tier"; +import { ModifierTier } from "../enums/modifier-tier"; import i18next from "#app/plugins/i18n"; export enum TextStyle { diff --git a/src/utils/modifier-utils.ts b/src/utils/modifier-utils.ts new file mode 100644 index 00000000000..3be4af3730c --- /dev/null +++ b/src/utils/modifier-utils.ts @@ -0,0 +1,35 @@ +import { ModifierPoolType } from "#enums/modifier-pool-type"; +import { + dailyStarterModifierPool, + enemyBuffModifierPool, + modifierPool, + trainerModifierPool, + wildModifierPool, +} from "#app/modifier/modifier-pools"; +import type { ModifierPool, ModifierTypeFunc } from "#app/@types/modifier-types"; +import { modifierTypes } from "#app/data/data-lists"; +import type { ModifierType } from "#app/modifier/modifier-type"; + +export function getModifierPoolForType(poolType: ModifierPoolType): ModifierPool { + switch (poolType) { + case ModifierPoolType.PLAYER: + return modifierPool; + case ModifierPoolType.WILD: + return wildModifierPool; + case ModifierPoolType.TRAINER: + return trainerModifierPool; + case ModifierPoolType.ENEMY_BUFF: + return enemyBuffModifierPool; + case ModifierPoolType.DAILY_STARTER: + return dailyStarterModifierPool; + } +} + +// TODO: document this +export function getModifierType(modifierTypeFunc: ModifierTypeFunc): ModifierType { + const modifierType = modifierTypeFunc(); + if (!modifierType.id) { + modifierType.id = Object.keys(modifierTypes).find(k => modifierTypes[k] === modifierTypeFunc)!; // TODO: is this bang correct? + } + return modifierType; +} diff --git a/test/abilities/healer.test.ts b/test/abilities/healer.test.ts index 7f71be7b86e..9d252523cc8 100644 --- a/test/abilities/healer.test.ts +++ b/test/abilities/healer.test.ts @@ -6,9 +6,9 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest"; import { isNullOrUndefined } from "#app/utils/common"; -import { PostTurnResetStatusAbAttr } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; import type Pokemon from "#app/field/pokemon"; +import type { PostTurnResetStatusAbAttr } from "#app/@types/ability-types"; describe("Abilities - Healer", () => { let phaserGame: Phaser.Game; @@ -38,7 +38,7 @@ describe("Abilities - Healer", () => { .enemyAbility(AbilityId.BALL_FETCH) .enemyMoveset(MoveId.SPLASH); - healerAttr = allAbilities[AbilityId.HEALER].getAttrs(PostTurnResetStatusAbAttr)[0]; + healerAttr = allAbilities[AbilityId.HEALER].getAttrs("PostTurnResetStatusAbAttr")[0]; healerAttrSpy = vi .spyOn(healerAttr, "getCondition") .mockReturnValue((pokemon: Pokemon) => !isNullOrUndefined(pokemon.getAlly())); diff --git a/test/abilities/neutralizing_gas.test.ts b/test/abilities/neutralizing_gas.test.ts index 067d164e835..51d2bed3ff0 100644 --- a/test/abilities/neutralizing_gas.test.ts +++ b/test/abilities/neutralizing_gas.test.ts @@ -1,7 +1,6 @@ import { BattlerIndex } from "#enums/battler-index"; import type { CommandPhase } from "#app/phases/command-phase"; import { Command } from "#enums/command"; -import { PostSummonWeatherChangeAbAttr } from "#app/data/abilities/ability"; import { AbilityId } from "#enums/ability-id"; import { ArenaTagType } from "#enums/arena-tag-type"; import { MoveId } from "#enums/move-id"; @@ -178,7 +177,7 @@ describe("Abilities - Neutralizing Gas", () => { await game.classicMode.startBattle([SpeciesId.MAGIKARP]); const enemy = game.scene.getEnemyPokemon()!; - const weatherChangeAttr = enemy.getAbilityAttrs(PostSummonWeatherChangeAbAttr, false)[0]; + const weatherChangeAttr = enemy.getAbilityAttrs("PostSummonWeatherChangeAbAttr", false)[0]; vi.spyOn(weatherChangeAttr, "applyPostSummon"); expect(game.scene.arena.getTag(ArenaTagType.NEUTRALIZING_GAS)).toBeDefined(); diff --git a/test/abilities/normal-move-type-change.test.ts b/test/abilities/normal-move-type-change.test.ts index 03fb5b2e7be..d9e39b32a7c 100644 --- a/test/abilities/normal-move-type-change.test.ts +++ b/test/abilities/normal-move-type-change.test.ts @@ -9,7 +9,6 @@ import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { TYPE_BOOST_ITEM_BOOST_PERCENT } from "#app/constants"; import { allAbilities } from "#app/data/data-lists"; -import { MoveTypeChangeAbAttr } from "#app/data/abilities/ability"; import { toDmgValue } from "#app/utils/common"; /** @@ -160,7 +159,7 @@ describe.each([ // get the power boost from the ability so we can compare it to the item // @ts-expect-error power multiplier is private - const boost = allAbilities[ab]?.getAttrs(MoveTypeChangeAbAttr)[0]?.powerMultiplier; + const boost = allAbilities[ab]?.getAttrs("MoveTypeChangeAbAttr")[0]?.powerMultiplier; expect(boost, "power boost should be defined").toBeDefined(); const powerSpy = vi.spyOn(testMoveInstance, "calculateBattlePower"); @@ -177,7 +176,7 @@ describe.each([ // get the power boost from the ability so we can compare it to the item // @ts-expect-error power multiplier is private - const boost = allAbilities[ab]?.getAttrs(MoveTypeChangeAbAttr)[0]?.powerMultiplier; + const boost = allAbilities[ab]?.getAttrs("MoveTypeChangeAbAttr")[0]?.powerMultiplier; expect(boost, "power boost should be defined").toBeDefined(); const tackle = allMoves[MoveId.TACKLE]; diff --git a/test/abilities/quick_draw.test.ts b/test/abilities/quick_draw.test.ts index 70b8637aa37..5e5e57fb056 100644 --- a/test/abilities/quick_draw.test.ts +++ b/test/abilities/quick_draw.test.ts @@ -1,4 +1,3 @@ -import { BypassSpeedChanceAbAttr } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; import { FaintPhase } from "#app/phases/faint-phase"; import { AbilityId } from "#enums/ability-id"; @@ -35,9 +34,11 @@ describe("Abilities - Quick Draw", () => { game.override.enemyAbility(AbilityId.BALL_FETCH); game.override.enemyMoveset([MoveId.TACKLE]); - vi.spyOn(allAbilities[AbilityId.QUICK_DRAW].getAttrs(BypassSpeedChanceAbAttr)[0], "chance", "get").mockReturnValue( - 100, - ); + vi.spyOn( + allAbilities[AbilityId.QUICK_DRAW].getAttrs("BypassSpeedChanceAbAttr")[0], + "chance", + "get", + ).mockReturnValue(100); }); test("makes pokemon going first in its priority bracket", async () => { diff --git a/test/abilities/sand_veil.test.ts b/test/abilities/sand_veil.test.ts index f4b322dc2e9..35a0a3347ff 100644 --- a/test/abilities/sand_veil.test.ts +++ b/test/abilities/sand_veil.test.ts @@ -1,4 +1,3 @@ -import { StatMultiplierAbAttr } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; import { CommandPhase } from "#app/phases/command-phase"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; @@ -46,7 +45,7 @@ describe("Abilities - Sand Veil", () => { vi.spyOn(leadPokemon[0], "getAbility").mockReturnValue(allAbilities[AbilityId.SAND_VEIL]); - const sandVeilAttr = allAbilities[AbilityId.SAND_VEIL].getAttrs(StatMultiplierAbAttr)[0]; + const sandVeilAttr = allAbilities[AbilityId.SAND_VEIL].getAttrs("StatMultiplierAbAttr")[0]; vi.spyOn(sandVeilAttr, "applyStatStage").mockImplementation( (_pokemon, _passive, _simulated, stat, statValue, _args) => { if (stat === Stat.EVA && game.scene.arena.weather?.weatherType === WeatherType.SANDSTORM) { diff --git a/test/abilities/shield_dust.test.ts b/test/abilities/shield_dust.test.ts index e071cf7a245..db1266d3088 100644 --- a/test/abilities/shield_dust.test.ts +++ b/test/abilities/shield_dust.test.ts @@ -1,10 +1,5 @@ import { BattlerIndex } from "#enums/battler-index"; -import { - applyAbAttrs, - applyPreDefendAbAttrs, - IgnoreMoveEffectsAbAttr, - MoveEffectChanceMultiplierAbAttr, -} from "#app/data/abilities/ability"; +import { applyAbAttrs, applyPreDefendAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { MoveEffectPhase } from "#app/phases/move-effect-phase"; import { NumberHolder } from "#app/utils/common"; import { AbilityId } from "#enums/ability-id"; @@ -57,7 +52,7 @@ describe("Abilities - Shield Dust", () => { const chance = new NumberHolder(move.chance); await applyAbAttrs( - MoveEffectChanceMultiplierAbAttr, + "MoveEffectChanceMultiplierAbAttr", phase.getUserPokemon()!, null, false, @@ -67,7 +62,7 @@ describe("Abilities - Shield Dust", () => { false, ); await applyPreDefendAbAttrs( - IgnoreMoveEffectsAbAttr, + "IgnoreMoveEffectsAbAttr", phase.getFirstTarget()!, phase.getUserPokemon()!, null, diff --git a/test/abilities/unburden.test.ts b/test/abilities/unburden.test.ts index 9748b6340f0..6e24e10d168 100644 --- a/test/abilities/unburden.test.ts +++ b/test/abilities/unburden.test.ts @@ -1,5 +1,4 @@ import { BattlerIndex } from "#enums/battler-index"; -import { PostItemLostAbAttr } from "#app/data/abilities/ability"; import { StealHeldItemChanceAttr } from "#app/data/moves/move"; import { allMoves } from "#app/data/data-lists"; import type Pokemon from "#app/field/pokemon"; @@ -277,7 +276,7 @@ describe("Abilities - Unburden", () => { const [treecko, purrloin] = game.scene.getPlayerParty(); const initialTreeckoSpeed = treecko.getStat(Stat.SPD); const initialPurrloinSpeed = purrloin.getStat(Stat.SPD); - const unburdenAttr = treecko.getAbilityAttrs(PostItemLostAbAttr)[0]; + const unburdenAttr = treecko.getAbilityAttrs("PostItemLostAbAttr")[0]; vi.spyOn(unburdenAttr, "applyPostItemLost"); // Player uses Baton Pass, which also passes the Baton item diff --git a/test/battle/damage_calculation.test.ts b/test/battle/damage_calculation.test.ts index a054ad0f468..555b3a9c554 100644 --- a/test/battle/damage_calculation.test.ts +++ b/test/battle/damage_calculation.test.ts @@ -1,6 +1,6 @@ import { allMoves } from "#app/data/data-lists"; import type { EnemyPersistentModifier } from "#app/modifier/modifier"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { ArenaTagType } from "#enums/arena-tag-type"; import { MoveId } from "#enums/move-id"; diff --git a/test/items/light_ball.test.ts b/test/items/light_ball.test.ts index 84a1689260f..a0269506909 100644 --- a/test/items/light_ball.test.ts +++ b/test/items/light_ball.test.ts @@ -1,6 +1,6 @@ import { Stat } from "#enums/stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import i18next from "#app/plugins/i18n"; import { NumberHolder } from "#app/utils/common"; import { SpeciesId } from "#enums/species-id"; diff --git a/test/items/lock_capsule.test.ts b/test/items/lock_capsule.test.ts index 292031a2bf0..640da4a299e 100644 --- a/test/items/lock_capsule.test.ts +++ b/test/items/lock_capsule.test.ts @@ -1,6 +1,6 @@ import { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { UiMode } from "#enums/ui-mode"; import GameManager from "#test/testUtils/gameManager"; diff --git a/test/items/metal_powder.test.ts b/test/items/metal_powder.test.ts index 20b0b90a766..576b4923d6d 100644 --- a/test/items/metal_powder.test.ts +++ b/test/items/metal_powder.test.ts @@ -1,6 +1,6 @@ import { Stat } from "#enums/stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import i18next from "#app/plugins/i18n"; import { NumberHolder } from "#app/utils/common"; import { SpeciesId } from "#enums/species-id"; diff --git a/test/items/quick_powder.test.ts b/test/items/quick_powder.test.ts index 0192dec4635..af99f51273d 100644 --- a/test/items/quick_powder.test.ts +++ b/test/items/quick_powder.test.ts @@ -1,6 +1,6 @@ import { Stat } from "#enums/stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import i18next from "#app/plugins/i18n"; import { NumberHolder } from "#app/utils/common"; import { SpeciesId } from "#enums/species-id"; diff --git a/test/items/thick_club.test.ts b/test/items/thick_club.test.ts index cff080d0e42..bc019ee99f8 100644 --- a/test/items/thick_club.test.ts +++ b/test/items/thick_club.test.ts @@ -1,6 +1,6 @@ import { Stat } from "#enums/stat"; import { SpeciesStatBoosterModifier } from "#app/modifier/modifier"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import i18next from "#app/plugins/i18n"; import { NumberHolder, randInt } from "#app/utils/common"; import { SpeciesId } from "#enums/species-id"; diff --git a/test/moves/safeguard.test.ts b/test/moves/safeguard.test.ts index 2ba53016833..6cd90bf8ac6 100644 --- a/test/moves/safeguard.test.ts +++ b/test/moves/safeguard.test.ts @@ -1,5 +1,4 @@ import { BattlerIndex } from "#enums/battler-index"; -import { PostDefendContactApplyStatusEffectAbAttr } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; import { StatusEffect } from "#app/enums/status-effect"; @@ -139,7 +138,7 @@ describe("Moves - Safeguard", () => { it("protects from ability-inflicted status", async () => { game.override.ability(AbilityId.STATIC); vi.spyOn( - allAbilities[AbilityId.STATIC].getAttrs(PostDefendContactApplyStatusEffectAbAttr)[0], + allAbilities[AbilityId.STATIC].getAttrs("PostDefendContactApplyStatusEffectAbAttr")[0], "chance", "get", ).mockReturnValue(100); diff --git a/test/moves/secret_power.test.ts b/test/moves/secret_power.test.ts index d555431656f..39498782b58 100644 --- a/test/moves/secret_power.test.ts +++ b/test/moves/secret_power.test.ts @@ -11,7 +11,6 @@ import { StatusEffect } from "#enums/status-effect"; import { BattlerIndex } from "#enums/battler-index"; import { ArenaTagType } from "#enums/arena-tag-type"; import { ArenaTagSide } from "#enums/arena-tag-side"; -import { MoveEffectChanceMultiplierAbAttr } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; describe("Moves - Secret Power", () => { @@ -68,7 +67,7 @@ describe("Moves - Secret Power", () => { .battleStyle("double"); await game.classicMode.startBattle([SpeciesId.BLASTOISE, SpeciesId.CHARIZARD]); - const sereneGraceAttr = allAbilities[AbilityId.SERENE_GRACE].getAttrs(MoveEffectChanceMultiplierAbAttr)[0]; + const sereneGraceAttr = allAbilities[AbilityId.SERENE_GRACE].getAttrs("MoveEffectChanceMultiplierAbAttr")[0]; vi.spyOn(sereneGraceAttr, "canApply"); game.move.select(MoveId.WATER_PLEDGE, 0, BattlerIndex.ENEMY); diff --git a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts index 778f8397417..526a3a0ab67 100644 --- a/test/mystery-encounter/encounters/clowning-around-encounter.test.ts +++ b/test/mystery-encounter/encounters/clowning-around-encounter.test.ts @@ -20,7 +20,7 @@ import { UiMode } from "#enums/ui-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { ClowningAroundEncounter } from "#app/data/mystery-encounters/encounters/clowning-around-encounter"; import { TrainerType } from "#enums/trainer-type"; import { AbilityId } from "#enums/ability-id"; @@ -29,7 +29,7 @@ import { Button } from "#enums/buttons"; import type PartyUiHandler from "#app/ui/party-ui-handler"; import type OptionSelectUiHandler from "#app/ui/settings/option-select-ui-handler"; import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { BerryType } from "#enums/berry-type"; import type { PokemonHeldItemModifier } from "#app/modifier/modifier"; import { PokemonType } from "#enums/pokemon-type"; diff --git a/test/mystery-encounter/encounters/delibirdy-encounter.test.ts b/test/mystery-encounter/encounters/delibirdy-encounter.test.ts index 0d1094831bc..e569c1d7789 100644 --- a/test/mystery-encounter/encounters/delibirdy-encounter.test.ts +++ b/test/mystery-encounter/encounters/delibirdy-encounter.test.ts @@ -26,7 +26,7 @@ import { } from "#app/modifier/modifier"; import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases"; import { generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { BerryType } from "#enums/berry-type"; const namespace = "mysteryEncounters/delibirdy"; diff --git a/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts b/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts index 96c4adf67c2..0aa1886b8e1 100644 --- a/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts +++ b/test/mystery-encounter/encounters/global-trade-system-encounter.test.ts @@ -11,13 +11,13 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import * as MysteryEncounters from "#app/data/mystery-encounters/mystery-encounters"; import { PokemonNatureWeightModifier } from "#app/modifier/modifier"; import { generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { GlobalTradeSystemEncounter } from "#app/data/mystery-encounters/encounters/global-trade-system-encounter"; import { CIVILIZATION_ENCOUNTER_BIOMES } from "#app/data/mystery-encounters/mystery-encounters"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { UiMode } from "#enums/ui-mode"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import * as Utils from "#app/utils/common"; const namespace = "mysteryEncounters/globalTradeSystem"; diff --git a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts index 948e42547de..9c5660cb25c 100644 --- a/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts +++ b/test/mystery-encounter/encounters/mysterious-challengers-encounter.test.ts @@ -14,7 +14,7 @@ import { UiMode } from "#enums/ui-mode"; import { MysteryEncounterOptionMode } from "#enums/mystery-encounter-option-mode"; import { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import { MysteriousChallengersEncounter } from "#app/data/mystery-encounters/encounters/mysterious-challengers-encounter"; import { TrainerConfig } from "#app/data/trainers/trainer-config"; import { TrainerPartyCompoundTemplate } from "#app/data/trainers/TrainerPartyTemplate"; diff --git a/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts b/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts index 47c75eb19fc..2014cb215a4 100644 --- a/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts +++ b/test/mystery-encounter/encounters/trash-to-treasure-encounter.test.ts @@ -14,8 +14,9 @@ import { MysteryEncounterType } from "#app/enums/mystery-encounter-type"; import { SpeciesId } from "#enums/species-id"; import { PokemonMove } from "#app/data/moves/pokemon-move"; import { HealShopCostModifier, HitHealModifier, TurnHealModifier } from "#app/modifier/modifier"; -import { ModifierTier } from "#app/modifier/modifier-tier"; -import { modifierTypes, type PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; +import { ModifierTier } from "#enums/modifier-tier"; +import type { PokemonHeldItemModifierType } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { CommandPhase } from "#app/phases/command-phase"; import { MovePhase } from "#app/phases/move-phase"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; diff --git a/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts b/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts index 12545b8d70a..60ca87d3ae2 100644 --- a/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts +++ b/test/mystery-encounter/encounters/uncommon-breed-encounter.test.ts @@ -26,7 +26,7 @@ import { BerryType } from "#enums/berry-type"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { Stat } from "#enums/stat"; import type { BerryModifier } from "#app/modifier/modifier"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { AbilityId } from "#enums/ability-id"; const namespace = "mysteryEncounters/uncommonBreed"; diff --git a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts index 2ad74b48540..dc5c53a75e7 100644 --- a/test/mystery-encounter/encounters/weird-dream-encounter.test.ts +++ b/test/mystery-encounter/encounters/weird-dream-encounter.test.ts @@ -19,7 +19,7 @@ import { WeirdDreamEncounter } from "#app/data/mystery-encounters/encounters/wei import * as EncounterTransformationSequence from "#app/data/mystery-encounters/utils/encounter-transformation-sequence"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import { CommandPhase } from "#app/phases/command-phase"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; const namespace = "mysteryEncounters/weirdDream"; const defaultParty = [SpeciesId.MAGBY, SpeciesId.HAUNTER, SpeciesId.ABRA]; diff --git a/test/phases/form-change-phase.test.ts b/test/phases/form-change-phase.test.ts index 8531375a48b..99c072bdafe 100644 --- a/test/phases/form-change-phase.test.ts +++ b/test/phases/form-change-phase.test.ts @@ -6,7 +6,7 @@ import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { PokemonType } from "#enums/pokemon-type"; import { generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils"; -import { modifierTypes } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; describe("Form Change Phase", () => { let phaserGame: Phaser.Game; diff --git a/test/phases/game-over-phase.test.ts b/test/phases/game-over-phase.test.ts index c430223b774..d45330697fc 100644 --- a/test/phases/game-over-phase.test.ts +++ b/test/phases/game-over-phase.test.ts @@ -6,7 +6,7 @@ import GameManager from "#test/testUtils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { achvs } from "#app/system/achv"; -import { Unlockables } from "#app/system/unlockables"; +import { Unlockables } from "#enums/unlockables"; describe("Game Over Phase", () => { let phaserGame: Phaser.Game; diff --git a/test/phases/select-modifier-phase.test.ts b/test/phases/select-modifier-phase.test.ts index 083b7d16f10..3639d34d25e 100644 --- a/test/phases/select-modifier-phase.test.ts +++ b/test/phases/select-modifier-phase.test.ts @@ -1,9 +1,10 @@ import type BattleScene from "#app/battle-scene"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { PlayerPokemon } from "#app/field/pokemon"; -import { ModifierTier } from "#app/modifier/modifier-tier"; +import { ModifierTier } from "#enums/modifier-tier"; import type { CustomModifierSettings } from "#app/modifier/modifier-type"; -import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type"; +import { ModifierTypeOption } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import { UiMode } from "#enums/ui-mode"; diff --git a/test/testUtils/gameManager.ts b/test/testUtils/gameManager.ts index 128217a6472..5d3ed3b6c8c 100644 --- a/test/testUtils/gameManager.ts +++ b/test/testUtils/gameManager.ts @@ -6,7 +6,8 @@ import Trainer from "#app/field/trainer"; import { getGameMode } from "#app/game-mode"; import { GameModes } from "#enums/game-modes"; import { globalScene } from "#app/global-scene"; -import { ModifierTypeOption, modifierTypes } from "#app/modifier/modifier-type"; +import { ModifierTypeOption } from "#app/modifier/modifier-type"; +import { modifierTypes } from "#app/data/data-lists"; import overrides from "#app/overrides"; import { CheckSwitchPhase } from "#app/phases/check-switch-phase"; import { CommandPhase } from "#app/phases/command-phase"; diff --git a/test/testUtils/helpers/field-helper.ts b/test/testUtils/helpers/field-helper.ts index 72498fd8e16..2866c01209f 100644 --- a/test/testUtils/helpers/field-helper.ts +++ b/test/testUtils/helpers/field-helper.ts @@ -4,7 +4,7 @@ import type { globalScene } from "#app/global-scene"; // -- end tsdoc imports -- import type { BattlerIndex } from "#enums/battler-index"; -import type { Ability } from "#app/data/abilities/ability-class"; +import type { Ability } from "#app/data/abilities/ability"; import { allAbilities } from "#app/data/data-lists"; import type Pokemon from "#app/field/pokemon"; import type { EnemyPokemon, PlayerPokemon } from "#app/field/pokemon"; diff --git a/test/testUtils/helpers/overridesHelper.ts b/test/testUtils/helpers/overridesHelper.ts index 32219fa833c..c01acbe0f2e 100644 --- a/test/testUtils/helpers/overridesHelper.ts +++ b/test/testUtils/helpers/overridesHelper.ts @@ -4,7 +4,7 @@ import { AbilityId } from "#enums/ability-id"; import type { ModifierOverride } from "#app/modifier/modifier-type"; import type { BattleStyle } from "#app/overrides"; import Overrides, { defaultOverrides } from "#app/overrides"; -import type { Unlockables } from "#app/system/unlockables"; +import type { Unlockables } from "#enums/unlockables"; import { BiomeId } from "#enums/biome-id"; import { MoveId } from "#enums/move-id"; import type { MysteryEncounterTier } from "#enums/mystery-encounter-tier"; diff --git a/test/testUtils/testFileInitialization.ts b/test/testUtils/testFileInitialization.ts index ba90cba7d5b..da390870300 100644 --- a/test/testUtils/testFileInitialization.ts +++ b/test/testUtils/testFileInitialization.ts @@ -5,6 +5,7 @@ import { initBiomes } from "#app/data/balance/biomes"; import { initEggMoves } from "#app/data/balance/egg-moves"; import { initPokemonPrevolutions, initPokemonStarters } from "#app/data/balance/pokemon-evolutions"; import { initMoves } from "#app/data/moves/move"; +import { initModifierPools } from "#app/modifier/init-modifier-pools"; import { initMysteryEncounters } from "#app/data/mystery-encounters/mystery-encounters"; import { initPokemonForms } from "#app/data/pokemon-forms"; import { initSpecies } from "#app/data/pokemon-species"; @@ -22,6 +23,7 @@ import InputText from "phaser3-rex-plugins/plugins/inputtext"; import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import { manageListeners } from "./listenersManager"; import { initI18n } from "#app/plugins/i18n"; +import { initModifierTypes } from "#app/modifier/modifier-type"; let wasInitialized = false; /** @@ -88,6 +90,8 @@ export function initTestFile() { if (!wasInitialized) { wasInitialized = true; initI18n(); + initModifierTypes(); + initModifierPools(); initVouchers(); initAchievements(); initStatsKeys(); From ff9aefb0e549aa225ac7259cfd48888592665d06 Mon Sep 17 00:00:00 2001 From: Dean <69436131+emdeann@users.noreply.github.com> Date: Wed, 11 Jun 2025 22:28:27 -0700 Subject: [PATCH 05/10] [Bug] Activate `PostSummon` Abilities in Speed and Priority Order https://github.com/pagefaultgames/pokerogue/pull/5513 * Add prependToPhaseWithCondition and use it in SummonPhase to determine speed order * Move logic to PostSummonPhase * Add test base * Pivot to using sort strategy instead * Add and update tests * Support priority ability activations * Ensure priority abilities are still activated on switch in * Add test for priority * Update to use priority numbers instead of a boolean * Add ability priorities to constructors * Move sorting to BattleScene * Rename phase file * Update import * Move application to applyPostSummonAbAttrs and stop assuming no other phases in queue * Ensure all PostSummonPhases from encounters are added at the same time * Switch to priority queue approach * Ensure that zero/negative priority activations happen after postsummonphase * Revert 07646fe (not needed due to stable sort) * Always create separate ability phases for passive and use boolean instead of priority number when applying * Add test for dynamic updates * Add BattlerIndex import * Clear queues for testing * Benjie suggestion * Split files * Update import in battlescene * Remove extra spaces added by VSCode * Fix other conflicts * Update PhaseManager * Update to use PhaseManager * Immediately start postsummons * Fix test * Fix BattlerIndex import * Remove unused imports * Fix postsummon application * Make priority readonly --- src/data/abilities/ability.ts | 36 +++--- src/data/abilities/apply-ab-attrs.ts | 7 +- src/data/phase-priority-queue.ts | 97 ++++++++++++++++ src/enums/dynamic-phase-type.ts | 6 + src/field/pokemon.ts | 4 + src/phase-manager.ts | 108 ++++++++++++++++-- src/phases/activate-priority-queue-phase.ts | 23 ++++ .../post-summon-activate-ability-phase.ts | 27 +++++ src/phases/post-summon-phase.ts | 7 +- src/phases/switch-summon-phase.ts | 2 +- .../ability_activation_order.test.ts | 95 +++++++++++++++ 11 files changed, 382 insertions(+), 30 deletions(-) create mode 100644 src/data/phase-priority-queue.ts create mode 100644 src/enums/dynamic-phase-type.ts create mode 100644 src/phases/activate-priority-queue-phase.ts create mode 100644 src/phases/post-summon-activate-ability-phase.ts create mode 100644 test/abilities/ability_activation_order.test.ts diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index 2efe3607b4f..d8743a0effe 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -86,6 +86,7 @@ export class Ability implements Localizable { public name: string; public description: string; public generation: number; + public readonly postSummonPriority: number; public isBypassFaint: boolean; public isIgnorable: boolean; public isSuppressable = true; @@ -94,11 +95,12 @@ export class Ability implements Localizable { public attrs: AbAttr[]; public conditions: AbAttrCondition[]; - constructor(id: AbilityId, generation: number) { + constructor(id: AbilityId, generation: number, postSummonPriority = 0) { this.id = id; this.nameAppend = ""; this.generation = generation; + this.postSummonPriority = postSummonPriority; this.attrs = []; this.conditions = []; @@ -8104,7 +8106,7 @@ export function initAbilities() { .conditionalAttr(p => globalScene.currentBattle.double && [ AbilityId.PLUS, AbilityId.MINUS ].some(a => (p.getAlly()?.hasAbility(a) ?? false)), StatMultiplierAbAttr, Stat.SPATK, 1.5), new Ability(AbilityId.MINUS, 3) .conditionalAttr(p => globalScene.currentBattle.double && [ AbilityId.PLUS, AbilityId.MINUS ].some(a => (p.getAlly()?.hasAbility(a) ?? false)), StatMultiplierAbAttr, Stat.SPATK, 1.5), - new Ability(AbilityId.FORECAST, 3) + new Ability(AbilityId.FORECAST, 3, -2) .uncopiable() .unreplaceable() .attr(NoFusionAbilityAbAttr) @@ -8238,7 +8240,7 @@ export function initAbilities() { .attr(StatusEffectImmunityAbAttr) .condition(getWeatherCondition(WeatherType.SUNNY, WeatherType.HARSH_SUN)) .ignorable(), - new Ability(AbilityId.KLUTZ, 4) + new Ability(AbilityId.KLUTZ, 4, 1) .unimplemented(), new Ability(AbilityId.MOLD_BREAKER, 4) .attr(PostSummonMessageAbAttr, (pokemon: Pokemon) => i18next.t("abilityTriggers:postSummonMoldBreaker", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })) @@ -8290,7 +8292,7 @@ export function initAbilities() { .uncopiable() .unsuppressable() .unreplaceable(), - new Ability(AbilityId.FLOWER_GIFT, 4) + new Ability(AbilityId.FLOWER_GIFT, 4, -2) .conditionalAttr(getWeatherCondition(WeatherType.SUNNY || WeatherType.HARSH_SUN), StatMultiplierAbAttr, Stat.ATK, 1.5) .conditionalAttr(getWeatherCondition(WeatherType.SUNNY || WeatherType.HARSH_SUN), StatMultiplierAbAttr, Stat.SPDEF, 1.5) .conditionalAttr(getWeatherCondition(WeatherType.SUNNY || WeatherType.HARSH_SUN), AllyStatMultiplierAbAttr, Stat.ATK, 1.5) @@ -8312,7 +8314,7 @@ export function initAbilities() { new Ability(AbilityId.CONTRARY, 5) .attr(StatStageChangeMultiplierAbAttr, -1) .ignorable(), - new Ability(AbilityId.UNNERVE, 5) + new Ability(AbilityId.UNNERVE, 5, 1) .attr(PreventBerryUseAbAttr), new Ability(AbilityId.DEFIANT, 5) .attr(PostStatStageChangeStatStageChangeAbAttr, (_target, _statsChanged, stages) => stages < 0, [ Stat.ATK ], 2), @@ -8554,7 +8556,7 @@ export function initAbilities() { .attr(PostDefendStatStageChangeAbAttr, (_target, user, move) => user.getMoveType(move) === PokemonType.WATER && move.category !== MoveCategory.STATUS, Stat.DEF, 2), new Ability(AbilityId.MERCILESS, 7) .attr(ConditionalCritAbAttr, (_user, target, _move) => target?.status?.effect === StatusEffect.TOXIC || target?.status?.effect === StatusEffect.POISON), - new Ability(AbilityId.SHIELDS_DOWN, 7) + new Ability(AbilityId.SHIELDS_DOWN, 7, -1) .attr(PostBattleInitFormChangeAbAttr, () => 0) .attr(PostSummonFormChangeAbAttr, p => p.formIndex % 7 + (p.getHpRatio() <= 0.5 ? 7 : 0)) .attr(PostTurnFormChangeAbAttr, p => p.formIndex % 7 + (p.getHpRatio() <= 0.5 ? 7 : 0)) @@ -8592,7 +8594,7 @@ export function initAbilities() { .attr(MoveTypeChangeAbAttr, PokemonType.ELECTRIC, 1.2, (_user, _target, move) => move.type === PokemonType.NORMAL), new Ability(AbilityId.SURGE_SURFER, 7) .conditionalAttr(getTerrainCondition(TerrainType.ELECTRIC), StatMultiplierAbAttr, Stat.SPD, 2), - new Ability(AbilityId.SCHOOLING, 7) + new Ability(AbilityId.SCHOOLING, 7, -1) .attr(PostBattleInitFormChangeAbAttr, () => 0) .attr(PostSummonFormChangeAbAttr, p => p.level < 20 || p.getHpRatio() <= 0.25 ? 0 : 1) .attr(PostTurnFormChangeAbAttr, p => p.level < 20 || p.getHpRatio() <= 0.25 ? 0 : 1) @@ -8761,7 +8763,7 @@ export function initAbilities() { .ignorable(), new Ability(AbilityId.RIPEN, 8) .attr(DoubleBerryEffectAbAttr), - new Ability(AbilityId.ICE_FACE, 8) + new Ability(AbilityId.ICE_FACE, 8, -2) .attr(NoTransformAbilityAbAttr) .attr(NoFusionAbilityAbAttr) // Add BattlerTagType.ICE_FACE if the pokemon is in ice face form @@ -8781,7 +8783,7 @@ export function initAbilities() { .ignorable(), new Ability(AbilityId.POWER_SPOT, 8) .attr(AllyMoveCategoryPowerBoostAbAttr, [ MoveCategory.SPECIAL, MoveCategory.PHYSICAL ], 1.3), - new Ability(AbilityId.MIMICRY, 8) + new Ability(AbilityId.MIMICRY, 8, -1) .attr(TerrainEventTypeChangeAbAttr), new Ability(AbilityId.SCREEN_CLEANER, 8) .attr(PostSummonRemoveArenaTagAbAttr, [ ArenaTagType.AURORA_VEIL, ArenaTagType.LIGHT_SCREEN, ArenaTagType.REFLECT ]), @@ -8796,7 +8798,7 @@ export function initAbilities() { .edgeCase(), // interacts incorrectly with rock head. It's meant to switch abilities before recoil would apply so that a pokemon with rock head would lose rock head first and still take the recoil new Ability(AbilityId.GORILLA_TACTICS, 8) .attr(GorillaTacticsAbAttr), - new Ability(AbilityId.NEUTRALIZING_GAS, 8) + new Ability(AbilityId.NEUTRALIZING_GAS, 8, 2) .attr(PostSummonAddArenaTagAbAttr, true, ArenaTagType.NEUTRALIZING_GAS, 0) .attr(PreLeaveFieldRemoveSuppressAbilitiesSourceAbAttr) .uncopiable() @@ -8828,14 +8830,14 @@ export function initAbilities() { .attr(PostVictoryStatStageChangeAbAttr, Stat.ATK, 1), new Ability(AbilityId.GRIM_NEIGH, 8) .attr(PostVictoryStatStageChangeAbAttr, Stat.SPATK, 1), - new Ability(AbilityId.AS_ONE_GLASTRIER, 8) + new Ability(AbilityId.AS_ONE_GLASTRIER, 8, 1) .attr(PostSummonMessageAbAttr, (pokemon: Pokemon) => i18next.t("abilityTriggers:postSummonAsOneGlastrier", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })) .attr(PreventBerryUseAbAttr) .attr(PostVictoryStatStageChangeAbAttr, Stat.ATK, 1) .uncopiable() .unreplaceable() .unsuppressable(), - new Ability(AbilityId.AS_ONE_SPECTRIER, 8) + new Ability(AbilityId.AS_ONE_SPECTRIER, 8, 1) .attr(PostSummonMessageAbAttr, (pokemon: Pokemon) => i18next.t("abilityTriggers:postSummonAsOneSpectrier", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })) .attr(PreventBerryUseAbAttr) .attr(PostVictoryStatStageChangeAbAttr, Stat.SPATK, 1) @@ -8893,12 +8895,12 @@ export function initAbilities() { .edgeCase(), // Encore, Frenzy, and other non-`TURN_END` tags don't lapse correctly on the commanding Pokemon. new Ability(AbilityId.ELECTROMORPHOSIS, 9) .attr(PostDefendApplyBattlerTagAbAttr, (_target, _user, move) => move.category !== MoveCategory.STATUS, BattlerTagType.CHARGED), - new Ability(AbilityId.PROTOSYNTHESIS, 9) + new Ability(AbilityId.PROTOSYNTHESIS, 9, -2) .conditionalAttr(getWeatherCondition(WeatherType.SUNNY, WeatherType.HARSH_SUN), PostSummonAddBattlerTagAbAttr, BattlerTagType.PROTOSYNTHESIS, 0, true) .attr(PostWeatherChangeAddBattlerTagAttr, BattlerTagType.PROTOSYNTHESIS, 0, WeatherType.SUNNY, WeatherType.HARSH_SUN) .uncopiable() .attr(NoTransformAbilityAbAttr), - new Ability(AbilityId.QUARK_DRIVE, 9) + new Ability(AbilityId.QUARK_DRIVE, 9, -2) .conditionalAttr(getTerrainCondition(TerrainType.ELECTRIC), PostSummonAddBattlerTagAbAttr, BattlerTagType.QUARK_DRIVE, 0, true) .attr(PostTerrainChangeAddBattlerTagAttr, BattlerTagType.QUARK_DRIVE, 0, TerrainType.ELECTRIC) .uncopiable() @@ -8942,7 +8944,7 @@ export function initAbilities() { new Ability(AbilityId.SUPREME_OVERLORD, 9) .attr(VariableMovePowerBoostAbAttr, (user, _target, _move) => 1 + 0.1 * Math.min(user.isPlayer() ? globalScene.arena.playerFaints : globalScene.currentBattle.enemyFaints, 5)) .partial(), // Should only boost once, on summon - new Ability(AbilityId.COSTAR, 9) + new Ability(AbilityId.COSTAR, 9, -2) .attr(PostSummonCopyAllyStatsAbAttr), new Ability(AbilityId.TOXIC_DEBRIS, 9) .attr(PostDefendApplyArenaTrapTagAbAttr, (_target, _user, move) => move.category === MoveCategory.PHYSICAL, ArenaTagType.TOXIC_SPIKES) @@ -8964,7 +8966,7 @@ export function initAbilities() { .ignorable(), new Ability(AbilityId.SUPERSWEET_SYRUP, 9) .attr(PostSummonStatStageChangeAbAttr, [ Stat.EVA ], -1), - new Ability(AbilityId.HOSPITALITY, 9) + new Ability(AbilityId.HOSPITALITY, 9, -2) .attr(PostSummonAllyHealAbAttr, 4, true), new Ability(AbilityId.TOXIC_CHAIN, 9) .attr(PostAttackApplyStatusEffectAbAttr, false, 30, StatusEffect.TOXIC), @@ -8988,7 +8990,7 @@ export function initAbilities() { .uncopiable() .unreplaceable() .attr(NoTransformAbilityAbAttr), - new Ability(AbilityId.TERA_SHIFT, 9) + new Ability(AbilityId.TERA_SHIFT, 9, 2) .attr(PostSummonFormChangeAbAttr, p => p.getFormKey() ? 0 : 1) .uncopiable() .unreplaceable() diff --git a/src/data/abilities/apply-ab-attrs.ts b/src/data/abilities/apply-ab-attrs.ts index e2f8ec9c14c..fdbd2652698 100644 --- a/src/data/abilities/apply-ab-attrs.ts +++ b/src/data/abilities/apply-ab-attrs.ts @@ -470,15 +470,18 @@ export function applyPostVictoryAbAttrs( export function applyPostSummonAbAttrs( attrType: AbAttrMap[K] extends PostSummonAbAttr ? K : never, pokemon: Pokemon, + passive = false, simulated = false, ...args: any[] ): void { - applyAbAttrsInternal( - attrType, + applySingleAbAttrs( pokemon, + passive, + attrType, (attr, passive) => (attr as PostSummonAbAttr).applyPostSummon(pokemon, passive, simulated, args), (attr, passive) => (attr as PostSummonAbAttr).canApplyPostSummon(pokemon, passive, simulated, args), args, + false, simulated, ); } diff --git a/src/data/phase-priority-queue.ts b/src/data/phase-priority-queue.ts new file mode 100644 index 00000000000..b815a6ac34f --- /dev/null +++ b/src/data/phase-priority-queue.ts @@ -0,0 +1,97 @@ +import { globalScene } from "#app/global-scene"; +import type { Phase } from "#app/phase"; +import { ActivatePriorityQueuePhase } from "#app/phases/activate-priority-queue-phase"; +import type { PostSummonPhase } from "#app/phases/post-summon-phase"; +import { PostSummonActivateAbilityPhase } from "#app/phases/post-summon-activate-ability-phase"; +import { Stat } from "#enums/stat"; +import { BooleanHolder } from "#app/utils/common"; +import { TrickRoomTag } from "#app/data/arena-tag"; +import { DynamicPhaseType } from "#enums/dynamic-phase-type"; + +/** + * Stores a list of {@linkcode Phase}s + * + * Dynamically updates ordering to always pop the highest "priority", based on implementation of {@linkcode reorder} + */ +export abstract class PhasePriorityQueue { + protected abstract queue: Phase[]; + + /** + * Sorts the elements in the queue + */ + public abstract reorder(): void; + + /** + * Calls {@linkcode reorder} and shifts the queue + * @returns The front element of the queue after sorting + */ + public pop(): Phase | undefined { + this.reorder(); + return this.queue.shift(); + } + + /** + * Adds a phase to the queue + * @param phase The phase to add + */ + public push(phase: Phase): void { + this.queue.push(phase); + } + + /** + * Removes all phases from the queue + */ + public clear(): void { + this.queue.splice(0, this.queue.length); + } +} + +/** + * Priority Queue for {@linkcode PostSummonPhase} and {@linkcode PostSummonActivateAbilityPhase} + * + * Orders phases first by ability priority, then by the {@linkcode Pokemon}'s effective speed + */ +export class PostSummonPhasePriorityQueue extends PhasePriorityQueue { + protected override queue: PostSummonPhase[] = []; + + public override reorder(): void { + this.queue.sort((phaseA: PostSummonPhase, phaseB: PostSummonPhase) => { + if (phaseA.getPriority() === phaseB.getPriority()) { + return ( + (phaseB.getPokemon().getEffectiveStat(Stat.SPD) - phaseA.getPokemon().getEffectiveStat(Stat.SPD)) * + (isTrickRoom() ? -1 : 1) + ); + } + + return phaseB.getPriority() - phaseA.getPriority(); + }); + } + + public override push(phase: PostSummonPhase): void { + super.push(phase); + this.queueAbilityPhase(phase); + } + + /** + * Queues all necessary {@linkcode PostSummonActivateAbilityPhase}s for each pushed {@linkcode PostSummonPhase} + * @param phase The {@linkcode PostSummonPhase} that was pushed onto the queue + */ + private queueAbilityPhase(phase: PostSummonPhase): void { + const phasePokemon = phase.getPokemon(); + + phasePokemon.getAbilityPriorities().forEach((priority, idx) => { + this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority, !!idx)); + globalScene.phaseManager.appendToPhase( + new ActivatePriorityQueuePhase(DynamicPhaseType.POST_SUMMON), + "ActivatePriorityQueuePhase", + (p: ActivatePriorityQueuePhase) => p.getType() === DynamicPhaseType.POST_SUMMON, + ); + }); + } +} + +function isTrickRoom(): boolean { + const speedReversed = new BooleanHolder(false); + globalScene.arena.applyTags(TrickRoomTag, false, speedReversed); + return speedReversed.value; +} diff --git a/src/enums/dynamic-phase-type.ts b/src/enums/dynamic-phase-type.ts new file mode 100644 index 00000000000..a34ac371668 --- /dev/null +++ b/src/enums/dynamic-phase-type.ts @@ -0,0 +1,6 @@ +/** + * Enum representation of the phase types held by implementations of {@linkcode PhasePriorityQueue} + */ +export enum DynamicPhaseType { + POST_SUMMON +} diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 6a34d936a51..964d66d352e 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2181,6 +2181,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return this.hasPassive() && (!canApply || this.canApplyAbility(true)) && this.getPassiveAbility().hasAttr(attrType); } + public getAbilityPriorities(): [number, number] { + return [this.getAbility().postSummonPriority, this.getPassiveAbility().postSummonPriority]; + } + /** * Gets the weight of the Pokemon with subtractive modifiers (Autotomize) happening first * and then multiplicative modifiers happening after (Heavy Metal and Light Metal) diff --git a/src/phase-manager.ts b/src/phase-manager.ts index 230e0331caf..b4fefe3f2d6 100644 --- a/src/phase-manager.ts +++ b/src/phase-manager.ts @@ -2,6 +2,7 @@ import type { Phase } from "#app/phase"; import type { default as Pokemon } from "#app/field/pokemon"; import type { PhaseMap, PhaseString } from "./@types/phase-types"; import { globalScene } from "#app/global-scene"; +import { ActivatePriorityQueuePhase } from "#app/phases/activate-priority-queue-phase"; import { AddEnemyBuffModifierPhase } from "#app/phases/add-enemy-buff-modifier-phase"; import { AttemptCapturePhase } from "#app/phases/attempt-capture-phase"; import { AttemptRunPhase } from "#app/phases/attempt-run-phase"; @@ -11,7 +12,9 @@ import { CheckStatusEffectPhase } from "#app/phases/check-status-effect-phase"; import { CheckSwitchPhase } from "#app/phases/check-switch-phase"; import { CommandPhase } from "#app/phases/command-phase"; import { CommonAnimPhase } from "#app/phases/common-anim-phase"; +import type { Constructor } from "#app/utils/common"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; +import type { DynamicPhaseType } from "#enums/dynamic-phase-type"; import { EggHatchPhase } from "#app/phases/egg-hatch-phase"; import { EggLapsePhase } from "#app/phases/egg-lapse-phase"; import { EggSummaryPhase } from "#app/phases/egg-summary-phase"; @@ -55,6 +58,7 @@ import { NextEncounterPhase } from "#app/phases/next-encounter-phase"; import { ObtainStatusEffectPhase } from "#app/phases/obtain-status-effect-phase"; import { PartyExpPhase } from "#app/phases/party-exp-phase"; import { PartyHealPhase } from "#app/phases/party-heal-phase"; +import { type PhasePriorityQueue, PostSummonPhasePriorityQueue } from "#app/data/phase-priority-queue"; import { PokemonAnimPhase } from "#app/phases/pokemon-anim-phase"; import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; import { PokemonTransformPhase } from "#app/phases/pokemon-transform-phase"; @@ -111,6 +115,7 @@ import { WeatherEffectPhase } from "#app/phases/weather-effect-phase"; * This allows for easy creation of new phases without needing to import each phase individually. */ const PHASES = Object.freeze({ + ActivatePriorityQueuePhase, AddEnemyBuffModifierPhase, AttemptCapturePhase, AttemptRunPhase, @@ -222,9 +227,19 @@ export class PhaseManager { private phaseQueuePrependSpliceIndex = -1; private nextCommandPhaseQueue: Phase[] = []; + /** Storage for {@linkcode PhasePriorityQueue}s which hold phases whose order dynamically changes */ + private dynamicPhaseQueues: PhasePriorityQueue[]; + /** Parallel array to {@linkcode dynamicPhaseQueues} - matches phase types to their queues */ + private dynamicPhaseTypes: Constructor[]; + private currentPhase: Phase | null = null; private standbyPhase: Phase | null = null; + constructor() { + this.dynamicPhaseQueues = [new PostSummonPhasePriorityQueue()]; + this.dynamicPhaseTypes = [PostSummonPhase]; + } + /* Phase Functions */ getCurrentPhase(): Phase | null { return this.currentPhase; @@ -254,7 +269,11 @@ export class PhaseManager { * @param defer boolean on which queue to add to, defaults to false, and adds to phaseQueue */ pushPhase(phase: Phase, defer = false): void { - (!defer ? this.phaseQueue : this.nextCommandPhaseQueue).push(phase); + if (this.getDynamicPhaseType(phase) !== undefined) { + this.pushDynamicPhase(phase); + } else { + (!defer ? this.phaseQueue : this.nextCommandPhaseQueue).push(phase); + } } /** @@ -283,6 +302,7 @@ export class PhaseManager { for (const queue of [this.phaseQueue, this.phaseQueuePrepend, this.conditionalQueue, this.nextCommandPhaseQueue]) { queue.splice(0, queue.length); } + this.dynamicPhaseQueues.forEach(queue => queue.clear()); this.currentPhase = null; this.standbyPhase = null; this.clearPhaseQueueSplice(); @@ -333,8 +353,9 @@ export class PhaseManager { this.currentPhase = this.phaseQueue.shift() ?? null; + const unactivatedConditionalPhases: [() => boolean, Phase][] = []; // Check if there are any conditional phases queued - if (this.conditionalQueue?.length) { + while (this.conditionalQueue?.length) { // Retrieve the first conditional phase from the queue const conditionalPhase = this.conditionalQueue.shift(); // Evaluate the condition associated with the phase @@ -343,11 +364,12 @@ export class PhaseManager { this.pushPhase(conditionalPhase[1]); } else if (conditionalPhase) { // If the condition is not met, re-add the phase back to the front of the conditional queue - this.conditionalQueue.unshift(conditionalPhase); + unactivatedConditionalPhases.push(conditionalPhase); } else { console.warn("condition phase is undefined/null!", conditionalPhase); } } + this.conditionalQueue.push(...unactivatedConditionalPhases); if (this.currentPhase) { console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;"); @@ -431,17 +453,18 @@ export class PhaseManager { } /** - * Attempt to add the input phase(s) to index after target phase in the {@linkcode phaseQueue}, else simply calls {@linkcode unshiftPhase()} - * @param phase - The phase(s) to be added - * @param targetPhase - The phase to search for in phaseQueue + * Tries to add the input phase(s) to index after target phase in the {@linkcode phaseQueue}, else simply calls {@linkcode unshiftPhase()} + * @param phase {@linkcode Phase} the phase(s) to be added + * @param targetPhase {@linkcode Phase} the type of phase to search for in {@linkcode phaseQueue} + * @param condition Condition the target phase must meet to be appended to * @returns `true` if a `targetPhase` was found to append to */ - appendToPhase(phase: Phase | Phase[], targetPhase: PhaseString): boolean { + appendToPhase(phase: Phase | Phase[], targetPhase: PhaseString, condition?: (p: Phase) => boolean): boolean { if (!Array.isArray(phase)) { phase = [phase]; } const target = PHASES[targetPhase]; - const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof target); + const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof target && (!condition || condition(ph))); if (targetIndex !== -1 && this.phaseQueue.length > targetIndex) { this.phaseQueue.splice(targetIndex + 1, 0, ...phase); @@ -451,6 +474,68 @@ export class PhaseManager { return false; } + /** + * Checks a phase and returns the matching {@linkcode DynamicPhaseType}, or undefined if it does not match one + * @param phase The phase to check + * @returns The corresponding {@linkcode DynamicPhaseType} or `undefined` + */ + public getDynamicPhaseType(phase: Phase | null): DynamicPhaseType | undefined { + let phaseType: DynamicPhaseType | undefined; + this.dynamicPhaseTypes.forEach((cls, index) => { + if (phase instanceof cls) { + phaseType = index; + } + }); + + return phaseType; + } + + /** + * Pushes a phase onto its corresponding dynamic queue and marks the activation point in {@linkcode phaseQueue} + * + * The {@linkcode ActivatePriorityQueuePhase} will run the top phase in the dynamic queue (not necessarily {@linkcode phase}) + * @param phase The phase to push + */ + public pushDynamicPhase(phase: Phase): void { + const type = this.getDynamicPhaseType(phase); + if (type === undefined) { + return; + } + + this.pushPhase(new ActivatePriorityQueuePhase(type)); + this.dynamicPhaseQueues[type].push(phase); + } + + /** + * Unshifts the top phase from the corresponding dynamic queue onto {@linkcode phaseQueue} + * @param type {@linkcode DynamicPhaseType} The type of dynamic phase to start + */ + public startDynamicPhaseType(type: DynamicPhaseType): void { + const phase = this.dynamicPhaseQueues[type].pop(); + if (phase) { + this.unshiftPhase(phase); + } + } + + /** + * Unshifts an {@linkcode ActivatePriorityQueuePhase} for {@linkcode phase}, then pushes {@linkcode phase} to its dynamic queue + * + * This is the same as {@linkcode pushDynamicPhase}, except the activation phase is unshifted + * + * {@linkcode phase} is not guaranteed to be the next phase from the queue to run (if the queue is not empty) + * @param phase The phase to add + * @returns + */ + public startDynamicPhase(phase: Phase): void { + const type = this.getDynamicPhaseType(phase); + if (type === undefined) { + return; + } + + this.unshiftPhase(new ActivatePriorityQueuePhase(type)); + this.dynamicPhaseQueues[type].push(phase); + } + /** * Adds a MessagePhase, either to PhaseQueuePrepend or nextCommandPhaseQueue * @param message - string for MessagePhase @@ -578,4 +663,11 @@ export class PhaseManager { ): boolean { return this.appendToPhase(this.create(phase, ...args), targetPhase); } + + public startNewDynamicPhase( + phase: T, + ...args: ConstructorParameters + ): void { + this.startDynamicPhase(this.create(phase, ...args)); + } } diff --git a/src/phases/activate-priority-queue-phase.ts b/src/phases/activate-priority-queue-phase.ts new file mode 100644 index 00000000000..df42c491676 --- /dev/null +++ b/src/phases/activate-priority-queue-phase.ts @@ -0,0 +1,23 @@ +import type { DynamicPhaseType } from "#enums/dynamic-phase-type"; +import { globalScene } from "#app/global-scene"; +import { Phase } from "#app/phase"; + +export class ActivatePriorityQueuePhase extends Phase { + public readonly phaseName = "ActivatePriorityQueuePhase"; + private type: DynamicPhaseType; + + constructor(type: DynamicPhaseType) { + super(); + this.type = type; + } + + override start() { + super.start(); + globalScene.phaseManager.startDynamicPhaseType(this.type); + this.end(); + } + + public getType(): DynamicPhaseType { + return this.type; + } +} diff --git a/src/phases/post-summon-activate-ability-phase.ts b/src/phases/post-summon-activate-ability-phase.ts new file mode 100644 index 00000000000..ba6c80d4ee0 --- /dev/null +++ b/src/phases/post-summon-activate-ability-phase.ts @@ -0,0 +1,27 @@ +import { applyPostSummonAbAttrs } from "#app/data/abilities/apply-ab-attrs"; +import { PostSummonPhase } from "#app/phases/post-summon-phase"; +import type { BattlerIndex } from "#enums/battler-index"; + +/** + * Helper to {@linkcode PostSummonPhase} which applies abilities + */ +export class PostSummonActivateAbilityPhase extends PostSummonPhase { + private priority: number; + private passive: boolean; + + constructor(battlerIndex: BattlerIndex, priority: number, passive: boolean) { + super(battlerIndex); + this.priority = priority; + this.passive = passive; + } + + start() { + applyPostSummonAbAttrs("PostSummonAbAttr", this.getPokemon(), this.passive, false); + + this.end(); + } + + public override getPriority() { + return this.priority; + } +} diff --git a/src/phases/post-summon-phase.ts b/src/phases/post-summon-phase.ts index 3acd7ca24e9..26fffd1b024 100644 --- a/src/phases/post-summon-phase.ts +++ b/src/phases/post-summon-phase.ts @@ -1,10 +1,10 @@ import { globalScene } from "#app/global-scene"; -import { applyAbAttrs, applyPostSummonAbAttrs } from "#app/data/abilities/apply-ab-attrs"; import { ArenaTrapTag } from "#app/data/arena-tag"; import { StatusEffect } from "#app/enums/status-effect"; import { PokemonPhase } from "./pokemon-phase"; import { MysteryEncounterPostSummonTag } from "#app/data/battler-tags"; import { BattlerTagType } from "#enums/battler-tag-type"; +import { applyAbAttrs } from "#app/data/abilities/apply-ab-attrs"; export class PostSummonPhase extends PokemonPhase { public readonly phaseName = "PostSummonPhase"; @@ -26,7 +26,6 @@ export class PostSummonPhase extends PokemonPhase { pokemon.lapseTag(BattlerTagType.MYSTERY_ENCOUNTER_POST_SUMMON); } - applyPostSummonAbAttrs("PostSummonAbAttr", pokemon); const field = pokemon.isPlayer() ? globalScene.getPlayerField() : globalScene.getEnemyField(); for (const p of field) { applyAbAttrs("CommanderAbAttr", p, null, false); @@ -34,4 +33,8 @@ export class PostSummonPhase extends PokemonPhase { this.end(); } + + public getPriority() { + return 0; + } } diff --git a/src/phases/switch-summon-phase.ts b/src/phases/switch-summon-phase.ts index 6b76d4e8926..af03cc42b54 100644 --- a/src/phases/switch-summon-phase.ts +++ b/src/phases/switch-summon-phase.ts @@ -245,7 +245,7 @@ export class SwitchSummonPhase extends SummonPhase { } queuePostSummon(): void { - globalScene.phaseManager.unshiftNew("PostSummonPhase", this.getPokemon().getBattlerIndex()); + globalScene.phaseManager.startNewDynamicPhase("PostSummonPhase", this.getPokemon().getBattlerIndex()); } /** diff --git a/test/abilities/ability_activation_order.test.ts b/test/abilities/ability_activation_order.test.ts new file mode 100644 index 00000000000..04adf40b623 --- /dev/null +++ b/test/abilities/ability_activation_order.test.ts @@ -0,0 +1,95 @@ +import { AbilityId } from "#enums/ability-id"; +import { MoveId } from "#enums/move-id"; +import { SpeciesId } from "#enums/species-id"; +import { Stat } from "#enums/stat"; +import { WeatherType } from "#enums/weather-type"; +import GameManager from "#test/testUtils/gameManager"; +import Phaser from "phaser"; +import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; + +describe("Ability Activation Order", () => { + let phaserGame: Phaser.Game; + let game: GameManager; + + beforeAll(() => { + phaserGame = new Phaser.Game({ + type: Phaser.HEADLESS, + }); + }); + + afterEach(() => { + game.phaseInterceptor.restoreOg(); + }); + + beforeEach(() => { + game = new GameManager(phaserGame); + game.override + .moveset([MoveId.SPLASH]) + .ability(AbilityId.BALL_FETCH) + .battleStyle("single") + .disableCrits() + .enemySpecies(SpeciesId.MAGIKARP) + .enemyAbility(AbilityId.BALL_FETCH) + .enemyMoveset(MoveId.SPLASH); + }); + + it("should activate the ability of the faster Pokemon first", async () => { + game.override.enemyLevel(100).ability(AbilityId.DRIZZLE).enemyAbility(AbilityId.DROUGHT); + await game.classicMode.startBattle([SpeciesId.SLOWPOKE]); + + // Enemy's ability should activate first, so sun ends up replaced with rain + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.RAIN); + }); + + it("should consider base stat boosting items in determining order", async () => { + game.override + .startingLevel(25) + .enemyLevel(50) + .enemySpecies(SpeciesId.MAGIKARP) + .enemyAbility(AbilityId.DROUGHT) + .ability(AbilityId.DRIZZLE) + .startingHeldItems([{ name: "BASE_STAT_BOOSTER", type: Stat.SPD, count: 100 }]); + + await game.classicMode.startBattle([SpeciesId.MAGIKARP]); + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SUNNY); + }); + + it("should consider stat boosting items in determining order", async () => { + game.override + .startingLevel(35) + .enemyLevel(50) + .enemySpecies(SpeciesId.DITTO) + .enemyAbility(AbilityId.DROUGHT) + .ability(AbilityId.DRIZZLE) + .startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "QUICK_POWDER" }]); + + await game.classicMode.startBattle([SpeciesId.DITTO]); + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SUNNY); + }); + + it("should activate priority abilities first", async () => { + game.override + .startingLevel(1) + .enemyLevel(100) + .enemySpecies(SpeciesId.ACCELGOR) + .enemyAbility(AbilityId.DROUGHT) + .ability(AbilityId.NEUTRALIZING_GAS); + + await game.classicMode.startBattle([SpeciesId.SLOWPOKE]); + expect(game.scene.arena.weather).toBeUndefined(); + }); + + it("should update dynamically based on speed order", async () => { + game.override + .startingLevel(35) + .enemyLevel(50) + .enemySpecies(SpeciesId.MAGIKARP) + .enemyAbility(AbilityId.SLOW_START) + .enemyPassiveAbility(AbilityId.DROUGHT) + .ability(AbilityId.DRIZZLE); + + await game.classicMode.startBattle([SpeciesId.MAGIKARP]); + // Slow start activates and makes enemy slower, so drought activates after drizzle + expect(game.scene.arena.weather?.weatherType).toBe(WeatherType.SUNNY); + }); +}); From 425985a05687896fa72e48ae252b43c25b81ae50 Mon Sep 17 00:00:00 2001 From: Mourouh <61661226+Mourouh@users.noreply.github.com> Date: Thu, 12 Jun 2025 23:56:37 +0200 Subject: [PATCH 06/10] [Balance] Add wild encounter chance to Maushold and Dudunsparce forms (#5975) Added wild encounter chance to Maushold and Dudunsparce forms --- src/battle-scene.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index d5cb5dcae42..81c65d85e06 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -1635,6 +1635,9 @@ export default class BattleScene extends SceneBase { case SpeciesId.TATSUGIRI: case SpeciesId.PALDEA_TAUROS: return randSeedInt(species.forms.length); + case SpeciesId.MAUSHOLD: + case SpeciesId.DUDUNSPARCE: + return !randSeedInt(4) ? 1 : 0; case SpeciesId.PIKACHU: if (this.currentBattle?.battleType === BattleType.TRAINER && this.currentBattle?.waveIndex < 30) { return 0; // Ban Cosplay and Partner Pika from Trainers before wave 30 From 7c6189e8126242c1b9dcec5b0ca274ee4d85758c Mon Sep 17 00:00:00 2001 From: NightKev <34855794+DayKev@users.noreply.github.com> Date: Thu, 12 Jun 2025 21:30:01 -0700 Subject: [PATCH 07/10] [Refactor] Create utility function `coerceArray` (#5723) * [Refactor] Create utility function `makeArray` This replaces the `if(!Array.isArray(var)) { var = [var] }` pattern * Replace `if` with ternary, rename to `coerceArray` * Add TSDocs * Improve type inferencing * Replace missed `Array.isArray` checks * Apply Biome * Re-apply changes to phase manager * Re-apply to `SpeciesFormChangeStatusEffectTrigger` constructor Apply to new instances in test mocks --- src/data/abilities/ability.ts | 5 +-- src/data/battle-anims.ts | 4 +-- src/data/battler-tags.ts | 4 +-- .../mystery-encounter-requirements.ts | 30 +++++++++--------- .../mystery-encounters/mystery-encounter.ts | 8 ++--- .../can-learn-move-requirement.ts | 4 +-- .../utils/encounter-phase-utils.ts | 6 ++-- .../pokemon-forms/form-change-triggers.ts | 7 ++--- src/data/trainers/trainer-config.ts | 31 +++++++------------ src/field/pokemon-sprite-sparkle-handler.ts | 10 ++---- src/field/pokemon.ts | 5 ++- src/phase-manager.ts | 10 ++---- src/plugins/cache-busted-loader-plugin.ts | 10 ++---- src/plugins/vite/vite-minify-json-plugin.ts | 4 +-- src/scene-base.ts | 6 ++-- src/ui/pokemon-icon-anim-handler.ts | 10 ++---- src/utils/common.ts | 9 ++++++ test/testUtils/helpers/moveHelper.ts | 5 ++- test/testUtils/helpers/overridesHelper.ts | 10 ++---- .../mocks/mocksContainer/mockContainer.ts | 17 +++------- .../mocks/mocksContainer/mockRectangle.ts | 7 ++--- .../mocks/mocksContainer/mockSprite.ts | 10 +++--- 22 files changed, 88 insertions(+), 124 deletions(-) diff --git a/src/data/abilities/ability.ts b/src/data/abilities/ability.ts index d8743a0effe..ef4529c361e 100644 --- a/src/data/abilities/ability.ts +++ b/src/data/abilities/ability.ts @@ -9,6 +9,7 @@ import { randSeedInt, type Constructor, randSeedFloat, + coerceArray, } from "#app/utils/common"; import { getPokemonNameWithAffix } from "#app/messages"; import { GroundedTag } from "#app/data/battler-tags"; @@ -4689,7 +4690,7 @@ export class PreApplyBattlerTagImmunityAbAttr extends PreApplyBattlerTagAbAttr { constructor(immuneTagTypes: BattlerTagType | BattlerTagType[]) { super(true); - this.immuneTagTypes = Array.isArray(immuneTagTypes) ? immuneTagTypes : [immuneTagTypes]; + this.immuneTagTypes = coerceArray(immuneTagTypes); } override canApplyPreApplyBattlerTag( @@ -6694,7 +6695,7 @@ export class FlinchStatStageChangeAbAttr extends FlinchEffectAbAttr { constructor(stats: BattleStat[], stages: number) { super(); - this.stats = Array.isArray(stats) ? stats : [stats]; + this.stats = stats; this.stages = stages; } diff --git a/src/data/battle-anims.ts b/src/data/battle-anims.ts index 7aa419ca470..131086625df 100644 --- a/src/data/battle-anims.ts +++ b/src/data/battle-anims.ts @@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene"; import { allMoves } from "./data-lists"; import { MoveFlags } from "#enums/MoveFlags"; import type Pokemon from "../field/pokemon"; -import { type nil, getFrameMs, getEnumKeys, getEnumValues, animationFileName } from "../utils/common"; +import { type nil, getFrameMs, getEnumKeys, getEnumValues, animationFileName, coerceArray } from "../utils/common"; import type { BattlerIndex } from "#enums/battler-index"; import { MoveId } from "#enums/move-id"; import { SubstituteTag } from "./battler-tags"; @@ -520,7 +520,7 @@ function logMissingMoveAnim(move: MoveId, ...optionalParams: any[]) { * @param encounterAnim one or more animations to fetch */ export async function initEncounterAnims(encounterAnim: EncounterAnim | EncounterAnim[]): Promise { - const anims = Array.isArray(encounterAnim) ? encounterAnim : [encounterAnim]; + const anims = coerceArray(encounterAnim); const encounterAnimNames = getEnumKeys(EncounterAnim); const encounterAnimFetches: Promise>[] = []; for (const anim of anims) { diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 0daf1913737..89d5a76159f 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -21,7 +21,7 @@ import type { MoveEffectPhase } from "#app/phases/move-effect-phase"; import type { MovePhase } from "#app/phases/move-phase"; import type { StatStageChangeCallback } from "#app/phases/stat-stage-change-phase"; import i18next from "#app/plugins/i18n"; -import { BooleanHolder, getFrameMs, NumberHolder, toDmgValue } from "#app/utils/common"; +import { BooleanHolder, coerceArray, getFrameMs, NumberHolder, toDmgValue } from "#app/utils/common"; import { AbilityId } from "#enums/ability-id"; import { BattlerTagType } from "#enums/battler-tag-type"; import { MoveId } from "#enums/move-id"; @@ -50,7 +50,7 @@ export class BattlerTag { isBatonPassable = false, ) { this.tagType = tagType; - this.lapseTypes = Array.isArray(lapseType) ? lapseType : [lapseType]; + this.lapseTypes = coerceArray(lapseType); this.turnCount = turnCount; this.sourceMove = sourceMove!; // TODO: is this bang correct? this.sourceId = sourceId; diff --git a/src/data/mystery-encounters/mystery-encounter-requirements.ts b/src/data/mystery-encounters/mystery-encounter-requirements.ts index bca34be723b..a6e6e84846f 100644 --- a/src/data/mystery-encounters/mystery-encounter-requirements.ts +++ b/src/data/mystery-encounters/mystery-encounter-requirements.ts @@ -11,7 +11,7 @@ import { WeatherType } from "#enums/weather-type"; import type { PlayerPokemon } from "#app/field/pokemon"; import { AttackTypeBoosterModifier } from "#app/modifier/modifier"; import type { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type"; -import { isNullOrUndefined } from "#app/utils/common"; +import { coerceArray, isNullOrUndefined } from "#app/utils/common"; import type { AbilityId } from "#enums/ability-id"; import { MoveId } from "#enums/move-id"; import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; @@ -272,7 +272,7 @@ export class TimeOfDayRequirement extends EncounterSceneRequirement { constructor(timeOfDay: TimeOfDay | TimeOfDay[]) { super(); - this.requiredTimeOfDay = Array.isArray(timeOfDay) ? timeOfDay : [timeOfDay]; + this.requiredTimeOfDay = coerceArray(timeOfDay); } override meetsRequirement(): boolean { @@ -294,7 +294,7 @@ export class WeatherRequirement extends EncounterSceneRequirement { constructor(weather: WeatherType | WeatherType[]) { super(); - this.requiredWeather = Array.isArray(weather) ? weather : [weather]; + this.requiredWeather = coerceArray(weather); } override meetsRequirement(): boolean { @@ -360,7 +360,7 @@ export class PersistentModifierRequirement extends EncounterSceneRequirement { constructor(heldItem: string | string[], minNumberOfItems = 1) { super(); this.minNumberOfItems = minNumberOfItems; - this.requiredHeldItemModifiers = Array.isArray(heldItem) ? heldItem : [heldItem]; + this.requiredHeldItemModifiers = coerceArray(heldItem); } override meetsRequirement(): boolean { @@ -426,7 +426,7 @@ export class SpeciesRequirement extends EncounterPokemonRequirement { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredSpecies = Array.isArray(species) ? species : [species]; + this.requiredSpecies = coerceArray(species); } override meetsRequirement(): boolean { @@ -466,7 +466,7 @@ export class NatureRequirement extends EncounterPokemonRequirement { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredNature = Array.isArray(nature) ? nature : [nature]; + this.requiredNature = coerceArray(nature); } override meetsRequirement(): boolean { @@ -504,7 +504,7 @@ export class TypeRequirement extends EncounterPokemonRequirement { this.excludeFainted = excludeFainted; this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredType = Array.isArray(type) ? type : [type]; + this.requiredType = coerceArray(type); } override meetsRequirement(): boolean { @@ -558,7 +558,7 @@ export class MoveRequirement extends EncounterPokemonRequirement { this.excludeDisallowedPokemon = excludeDisallowedPokemon; this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredMoves = Array.isArray(moves) ? moves : [moves]; + this.requiredMoves = coerceArray(moves); } override meetsRequirement(): boolean { @@ -609,7 +609,7 @@ export class CompatibleMoveRequirement extends EncounterPokemonRequirement { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredMoves = Array.isArray(learnableMove) ? learnableMove : [learnableMove]; + this.requiredMoves = coerceArray(learnableMove); } override meetsRequirement(): boolean { @@ -665,7 +665,7 @@ export class AbilityRequirement extends EncounterPokemonRequirement { this.excludeDisallowedPokemon = excludeDisallowedPokemon; this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredAbilities = Array.isArray(abilities) ? abilities : [abilities]; + this.requiredAbilities = coerceArray(abilities); } override meetsRequirement(): boolean { @@ -710,7 +710,7 @@ export class StatusEffectRequirement extends EncounterPokemonRequirement { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredStatusEffect = Array.isArray(statusEffect) ? statusEffect : [statusEffect]; + this.requiredStatusEffect = coerceArray(statusEffect); } override meetsRequirement(): boolean { @@ -785,7 +785,7 @@ export class CanFormChangeWithItemRequirement extends EncounterPokemonRequiremen super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredFormChangeItem = Array.isArray(formChangeItem) ? formChangeItem : [formChangeItem]; + this.requiredFormChangeItem = coerceArray(formChangeItem); } override meetsRequirement(): boolean { @@ -843,7 +843,7 @@ export class CanEvolveWithItemRequirement extends EncounterPokemonRequirement { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredEvolutionItem = Array.isArray(evolutionItems) ? evolutionItems : [evolutionItems]; + this.requiredEvolutionItem = coerceArray(evolutionItems); } override meetsRequirement(): boolean { @@ -908,7 +908,7 @@ export class HeldItemRequirement extends EncounterPokemonRequirement { super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredHeldItemModifiers = Array.isArray(heldItem) ? heldItem : [heldItem]; + this.requiredHeldItemModifiers = coerceArray(heldItem); this.requireTransferable = requireTransferable; } @@ -972,7 +972,7 @@ export class AttackTypeBoosterHeldItemTypeRequirement extends EncounterPokemonRe super(); this.minNumberOfPokemon = minNumberOfPokemon; this.invertQuery = invertQuery; - this.requiredHeldItemTypes = Array.isArray(heldItemTypes) ? heldItemTypes : [heldItemTypes]; + this.requiredHeldItemTypes = coerceArray(heldItemTypes); this.requireTransferable = requireTransferable; } diff --git a/src/data/mystery-encounters/mystery-encounter.ts b/src/data/mystery-encounters/mystery-encounter.ts index 6510e32fe76..bd3082afe19 100644 --- a/src/data/mystery-encounters/mystery-encounter.ts +++ b/src/data/mystery-encounters/mystery-encounter.ts @@ -2,7 +2,7 @@ import type { EnemyPartyConfig } from "#app/data/mystery-encounters/utils/encoun import type { PlayerPokemon } from "#app/field/pokemon"; import type { PokemonMove } from "../moves/pokemon-move"; import type Pokemon from "#app/field/pokemon"; -import { capitalizeFirstLetter, isNullOrUndefined } from "#app/utils/common"; +import { capitalizeFirstLetter, coerceArray, isNullOrUndefined } from "#app/utils/common"; import type { MysteryEncounterType } from "#enums/mystery-encounter-type"; import type { MysteryEncounterSpriteConfig } from "#app/field/mystery-encounter-intro"; import MysteryEncounterIntroVisuals from "#app/field/mystery-encounter-intro"; @@ -717,7 +717,7 @@ export class MysteryEncounterBuilder implements Partial { withAnimations( ...encounterAnimations: EncounterAnim[] ): this & Required> { - const animations = Array.isArray(encounterAnimations) ? encounterAnimations : [encounterAnimations]; + const animations = coerceArray(encounterAnimations); return Object.assign(this, { encounterAnimations: animations }); } @@ -729,7 +729,7 @@ export class MysteryEncounterBuilder implements Partial { withDisallowedGameModes( ...disallowedGameModes: GameModes[] ): this & Required> { - const gameModes = Array.isArray(disallowedGameModes) ? disallowedGameModes : [disallowedGameModes]; + const gameModes = coerceArray(disallowedGameModes); return Object.assign(this, { disallowedGameModes: gameModes }); } @@ -741,7 +741,7 @@ export class MysteryEncounterBuilder implements Partial { withDisallowedChallenges( ...disallowedChallenges: Challenges[] ): this & Required> { - const challenges = Array.isArray(disallowedChallenges) ? disallowedChallenges : [disallowedChallenges]; + const challenges = coerceArray(disallowedChallenges); return Object.assign(this, { disallowedChallenges: challenges }); } diff --git a/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts b/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts index c0e45d5401c..0123ea7d6ba 100644 --- a/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts +++ b/src/data/mystery-encounters/requirements/can-learn-move-requirement.ts @@ -1,7 +1,7 @@ import type { MoveId } from "#enums/move-id"; import type { PlayerPokemon } from "#app/field/pokemon"; import { PokemonMove } from "#app/data/moves/pokemon-move"; -import { isNullOrUndefined } from "#app/utils/common"; +import { coerceArray, isNullOrUndefined } from "#app/utils/common"; import { EncounterPokemonRequirement } from "#app/data/mystery-encounters/mystery-encounter-requirements"; import { globalScene } from "#app/global-scene"; @@ -29,7 +29,7 @@ export class CanLearnMoveRequirement extends EncounterPokemonRequirement { constructor(requiredMoves: MoveId | MoveId[], options: CanLearnMoveRequirementOptions = {}) { super(); - this.requiredMoves = Array.isArray(requiredMoves) ? requiredMoves : [requiredMoves]; + this.requiredMoves = coerceArray(requiredMoves); this.excludeLevelMoves = options.excludeLevelMoves ?? false; this.excludeTmMoves = options.excludeTmMoves ?? false; diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 599edb11628..e2b92230985 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -25,7 +25,7 @@ import type { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-optio import type { PartyOption, PokemonSelectFilter } from "#app/ui/party-ui-handler"; import { PartyUiMode } from "#app/ui/party-ui-handler"; import { UiMode } from "#enums/ui-mode"; -import { isNullOrUndefined, randSeedInt, randomString, randSeedItem } from "#app/utils/common"; +import { isNullOrUndefined, randSeedInt, randomString, randSeedItem, coerceArray } from "#app/utils/common"; import type { BattlerTagType } from "#enums/battler-tag-type"; import { BiomeId } from "#enums/biome-id"; import type { TrainerType } from "#enums/trainer-type"; @@ -449,7 +449,7 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig): * @param moves */ export function loadCustomMovesForEncounter(moves: MoveId | MoveId[]) { - moves = Array.isArray(moves) ? moves : [moves]; + moves = coerceArray(moves); return Promise.all(moves.map(move => initMoveAnim(move))).then(() => loadMoveAnimAssets(moves)); } @@ -792,7 +792,7 @@ export function setEncounterRewards( * @param useWaveIndex - set to false when directly passing the the full exp value instead of baseExpValue */ export function setEncounterExp(participantId: number | number[], baseExpValue: number, useWaveIndex = true) { - const participantIds = Array.isArray(participantId) ? participantId : [participantId]; + const participantIds = coerceArray(participantId); globalScene.currentBattle.mysteryEncounter!.doEncounterExp = () => { globalScene.phaseManager.unshiftNew("PartyExpPhase", baseExpValue, useWaveIndex, new Set(participantIds)); diff --git a/src/data/pokemon-forms/form-change-triggers.ts b/src/data/pokemon-forms/form-change-triggers.ts index eb2c0a557c2..3726781d9e3 100644 --- a/src/data/pokemon-forms/form-change-triggers.ts +++ b/src/data/pokemon-forms/form-change-triggers.ts @@ -1,5 +1,5 @@ import i18next from "i18next"; -import type { Constructor } from "#app/utils/common"; +import { coerceArray, type Constructor } from "#app/utils/common"; import type { TimeOfDay } from "#enums/time-of-day"; import type Pokemon from "#app/field/pokemon"; import type { SpeciesFormChange } from "#app/data/pokemon-forms"; @@ -125,10 +125,7 @@ export class SpeciesFormChangeStatusEffectTrigger extends SpeciesFormChangeTrigg constructor(statusEffects: StatusEffect | StatusEffect[], invert = false) { super(); - if (!Array.isArray(statusEffects)) { - statusEffects = [statusEffects]; - } - this.statusEffects = statusEffects; + this.statusEffects = coerceArray(statusEffects); this.invert = invert; // this.description = i18next.t("pokemonEvolutions:Forms.statusEffect"); } diff --git a/src/data/trainers/trainer-config.ts b/src/data/trainers/trainer-config.ts index 8c065666202..063dddafee8 100644 --- a/src/data/trainers/trainer-config.ts +++ b/src/data/trainers/trainer-config.ts @@ -1,7 +1,14 @@ import { globalScene } from "#app/global-scene"; import { modifierTypes } from "../data-lists"; import { PokemonMove } from "../moves/pokemon-move"; -import { toReadableString, isNullOrUndefined, randSeedItem, randSeedInt, randSeedIntRange } from "#app/utils/common"; +import { + toReadableString, + isNullOrUndefined, + randSeedItem, + randSeedInt, + coerceArray, + randSeedIntRange, +} from "#app/utils/common"; import { pokemonEvolutions, pokemonPrevolutions } from "#app/data/balance/pokemon-evolutions"; import { getPokemonSpecies } from "#app/data/pokemon-species"; import { tmSpecies } from "#app/data/balance/tms"; @@ -554,10 +561,7 @@ export class TrainerConfig { this.speciesPools = evilAdminTrainerPools[poolName]; signatureSpecies.forEach((speciesPool, s) => { - if (!Array.isArray(speciesPool)) { - speciesPool = [speciesPool]; - } - this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(speciesPool)); + this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(coerceArray(speciesPool))); }); const nameForCall = this.name.toLowerCase().replace(/\s/g, "_"); @@ -620,10 +624,7 @@ export class TrainerConfig { this.setPartyTemplates(trainerPartyTemplates.RIVAL_5); } signatureSpecies.forEach((speciesPool, s) => { - if (!Array.isArray(speciesPool)) { - speciesPool = [speciesPool]; - } - this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(speciesPool)); + this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(coerceArray(speciesPool))); }); if (!isNullOrUndefined(specialtyType)) { this.setSpeciesFilter(p => p.isOfType(specialtyType)); @@ -668,12 +669,8 @@ export class TrainerConfig { // Set up party members with their corresponding species. signatureSpecies.forEach((speciesPool, s) => { - // Ensure speciesPool is an array. - if (!Array.isArray(speciesPool)) { - speciesPool = [speciesPool]; - } // Set a function to get a random party member from the species pool. - this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(speciesPool)); + this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(coerceArray(speciesPool))); }); // If specialty type is provided, set species filter and specialty type. @@ -729,12 +726,8 @@ export class TrainerConfig { // Set up party members with their corresponding species. signatureSpecies.forEach((speciesPool, s) => { - // Ensure speciesPool is an array. - if (!Array.isArray(speciesPool)) { - speciesPool = [speciesPool]; - } // Set a function to get a random party member from the species pool. - this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(speciesPool)); + this.setPartyMemberFunc(-(s + 1), getRandomPartyMemberFunc(coerceArray(speciesPool))); }); // Set species filter and specialty type if provided, otherwise filter by base total. diff --git a/src/field/pokemon-sprite-sparkle-handler.ts b/src/field/pokemon-sprite-sparkle-handler.ts index cceb0bd7717..bda9414bb92 100644 --- a/src/field/pokemon-sprite-sparkle-handler.ts +++ b/src/field/pokemon-sprite-sparkle-handler.ts @@ -1,6 +1,6 @@ import { globalScene } from "#app/global-scene"; import Pokemon from "./pokemon"; -import { fixedInt, randInt } from "#app/utils/common"; +import { fixedInt, coerceArray, randInt } from "#app/utils/common"; export default class PokemonSpriteSparkleHandler { private sprites: Set; @@ -57,9 +57,7 @@ export default class PokemonSpriteSparkleHandler { } add(sprites: Phaser.GameObjects.Sprite | Phaser.GameObjects.Sprite[]): void { - if (!Array.isArray(sprites)) { - sprites = [sprites]; - } + sprites = coerceArray(sprites); for (const s of sprites) { if (this.sprites.has(s)) { continue; @@ -69,9 +67,7 @@ export default class PokemonSpriteSparkleHandler { } remove(sprites: Phaser.GameObjects.Sprite | Phaser.GameObjects.Sprite[]): void { - if (!Array.isArray(sprites)) { - sprites = [sprites]; - } + sprites = coerceArray(sprites); for (const s of sprites) { this.sprites.delete(s); } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 964d66d352e..834c65437af 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -41,6 +41,7 @@ import { type nil, type Constructor, randSeedIntRange, + coerceArray, } from "#app/utils/common"; import type { TypeDamageMultiplier } from "#app/data/type"; import { getTypeDamageMultiplier, getTypeRgb } from "#app/data/type"; @@ -1774,9 +1775,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { let overrideArray: MoveId | Array = this.isPlayer() ? Overrides.MOVESET_OVERRIDE : Overrides.OPP_MOVESET_OVERRIDE; - if (!Array.isArray(overrideArray)) { - overrideArray = [overrideArray]; - } + overrideArray = coerceArray(overrideArray); if (overrideArray.length > 0) { if (!this.isPlayer()) { this.moveset = []; diff --git a/src/phase-manager.ts b/src/phase-manager.ts index b4fefe3f2d6..8c22a45758c 100644 --- a/src/phase-manager.ts +++ b/src/phase-manager.ts @@ -12,7 +12,7 @@ import { CheckStatusEffectPhase } from "#app/phases/check-status-effect-phase"; import { CheckSwitchPhase } from "#app/phases/check-switch-phase"; import { CommandPhase } from "#app/phases/command-phase"; import { CommonAnimPhase } from "#app/phases/common-anim-phase"; -import type { Constructor } from "#app/utils/common"; +import { coerceArray, type Constructor } from "#app/utils/common"; import { DamageAnimPhase } from "#app/phases/damage-anim-phase"; import type { DynamicPhaseType } from "#enums/dynamic-phase-type"; import { EggHatchPhase } from "#app/phases/egg-hatch-phase"; @@ -438,9 +438,7 @@ export class PhaseManager { * @returns boolean if a targetPhase was found and added */ prependToPhase(phase: Phase | Phase[], targetPhase: PhaseString): boolean { - if (!Array.isArray(phase)) { - phase = [phase]; - } + phase = coerceArray(phase); const target = PHASES[targetPhase]; const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof target); @@ -460,9 +458,7 @@ export class PhaseManager { * @returns `true` if a `targetPhase` was found to append to */ appendToPhase(phase: Phase | Phase[], targetPhase: PhaseString, condition?: (p: Phase) => boolean): boolean { - if (!Array.isArray(phase)) { - phase = [phase]; - } + phase = coerceArray(phase); const target = PHASES[targetPhase]; const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof target && (!condition || condition(ph))); diff --git a/src/plugins/cache-busted-loader-plugin.ts b/src/plugins/cache-busted-loader-plugin.ts index e5b1abb5903..4ae9b352ae3 100644 --- a/src/plugins/cache-busted-loader-plugin.ts +++ b/src/plugins/cache-busted-loader-plugin.ts @@ -1,10 +1,8 @@ +import { coerceArray } from "#app/utils/common"; + let manifest: object; export default class CacheBustedLoaderPlugin extends Phaser.Loader.LoaderPlugin { - constructor(scene: Phaser.Scene) { - super(scene); - } - get manifest() { return manifest; } @@ -14,9 +12,7 @@ export default class CacheBustedLoaderPlugin extends Phaser.Loader.LoaderPlugin } addFile(file): void { - if (!Array.isArray(file)) { - file = [file]; - } + file = coerceArray(file); file.forEach(item => { if (manifest) { diff --git a/src/plugins/vite/vite-minify-json-plugin.ts b/src/plugins/vite/vite-minify-json-plugin.ts index f14fdf7042d..38f299eea50 100644 --- a/src/plugins/vite/vite-minify-json-plugin.ts +++ b/src/plugins/vite/vite-minify-json-plugin.ts @@ -41,9 +41,9 @@ export function minifyJsonPlugin(basePath: string | string[], recursive?: boolea }, async closeBundle() { console.log("Minifying JSON files..."); - const basePathes = Array.isArray(basePath) ? basePath : [basePath]; + const basePaths = Array.isArray(basePath) ? basePath : [basePath]; - basePathes.forEach(basePath => { + basePaths.forEach(basePath => { const baseDir = path.resolve(buildDir, basePath); if (fs.existsSync(baseDir)) { applyToDir(baseDir, recursive); diff --git a/src/scene-base.ts b/src/scene-base.ts index 430a9bc8aac..ccea373fca0 100644 --- a/src/scene-base.ts +++ b/src/scene-base.ts @@ -1,3 +1,5 @@ +import { coerceArray } from "#app/utils/common"; + export const legacyCompatibleImages: string[] = []; export class SceneBase extends Phaser.Scene { @@ -88,9 +90,7 @@ export class SceneBase extends Phaser.Scene { } else { folder += "/"; } - if (!Array.isArray(filenames)) { - filenames = [filenames]; - } + filenames = coerceArray(filenames); for (const f of filenames as string[]) { this.load.audio(folder + key, this.getCachedUrl(`audio/${folder}${f}`)); } diff --git a/src/ui/pokemon-icon-anim-handler.ts b/src/ui/pokemon-icon-anim-handler.ts index 253ccbe3623..8a206167a94 100644 --- a/src/ui/pokemon-icon-anim-handler.ts +++ b/src/ui/pokemon-icon-anim-handler.ts @@ -1,5 +1,5 @@ import { globalScene } from "#app/global-scene"; -import { fixedInt } from "#app/utils/common"; +import { fixedInt, coerceArray } from "#app/utils/common"; export enum PokemonIconAnimMode { NONE, @@ -49,9 +49,7 @@ export default class PokemonIconAnimHandler { } addOrUpdate(icons: PokemonIcon | PokemonIcon[], mode: PokemonIconAnimMode): void { - if (!Array.isArray(icons)) { - icons = [icons]; - } + icons = coerceArray(icons); for (const i of icons) { if (this.icons.has(i) && this.icons.get(i) === mode) { continue; @@ -66,9 +64,7 @@ export default class PokemonIconAnimHandler { } remove(icons: PokemonIcon | PokemonIcon[]): void { - if (!Array.isArray(icons)) { - icons = [icons]; - } + icons = coerceArray(icons); for (const i of icons) { if (this.toggled) { const icon = this.icons.get(i); diff --git a/src/utils/common.ts b/src/utils/common.ts index 56fa3b5c698..c8b37c4e3fd 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -611,3 +611,12 @@ export function getShinyDescriptor(variant: Variant): string { return i18next.t("common:commonShiny"); } } + +/** + * If the input isn't already an array, turns it into one. + * @returns An array with the same type as the type of the input + */ +export function coerceArray(input: T): T extends any[] ? T : [T]; +export function coerceArray(input: T): T | [T] { + return Array.isArray(input) ? input : [input]; +} diff --git a/test/testUtils/helpers/moveHelper.ts b/test/testUtils/helpers/moveHelper.ts index 1b799e12da7..0f87fa9a4c1 100644 --- a/test/testUtils/helpers/moveHelper.ts +++ b/test/testUtils/helpers/moveHelper.ts @@ -12,6 +12,7 @@ import { UiMode } from "#enums/ui-mode"; import { getMovePosition } from "#test/testUtils/gameManagerUtils"; import { GameManagerHelper } from "#test/testUtils/helpers/gameManagerHelper"; import { vi } from "vitest"; +import { coerceArray } from "#app/utils/common"; /** * Helper to handle a Pokemon's move @@ -157,9 +158,7 @@ export class MoveHelper extends GameManagerHelper { * @param moveset - The {@linkcode MoveId} (single or array) to change the Pokemon's moveset to. */ public changeMoveset(pokemon: Pokemon, moveset: MoveId | MoveId[]): void { - if (!Array.isArray(moveset)) { - moveset = [moveset]; - } + moveset = coerceArray(moveset); pokemon.moveset = []; moveset.forEach(move => { pokemon.moveset.push(new PokemonMove(move)); diff --git a/test/testUtils/helpers/overridesHelper.ts b/test/testUtils/helpers/overridesHelper.ts index c01acbe0f2e..9869c7450e2 100644 --- a/test/testUtils/helpers/overridesHelper.ts +++ b/test/testUtils/helpers/overridesHelper.ts @@ -14,7 +14,7 @@ import { StatusEffect } from "#enums/status-effect"; import type { WeatherType } from "#enums/weather-type"; import { expect, vi } from "vitest"; import { GameManagerHelper } from "./gameManagerHelper"; -import { shiftCharCodes } from "#app/utils/common"; +import { coerceArray, shiftCharCodes } from "#app/utils/common"; import type { RandomTrainerOverride } from "#app/overrides"; import type { BattleType } from "#enums/battle-type"; @@ -202,9 +202,7 @@ export class OverridesHelper extends GameManagerHelper { */ public moveset(moveset: MoveId | MoveId[]): this { vi.spyOn(Overrides, "MOVESET_OVERRIDE", "get").mockReturnValue(moveset); - if (!Array.isArray(moveset)) { - moveset = [moveset]; - } + moveset = coerceArray(moveset); const movesetStr = moveset.map(moveId => MoveId[moveId]).join(", "); this.log(`Player Pokemon moveset set to ${movesetStr} (=[${moveset.join(", ")}])!`); return this; @@ -382,9 +380,7 @@ export class OverridesHelper extends GameManagerHelper { */ public enemyMoveset(moveset: MoveId | MoveId[]): this { vi.spyOn(Overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue(moveset); - if (!Array.isArray(moveset)) { - moveset = [moveset]; - } + moveset = coerceArray(moveset); const movesetStr = moveset.map(moveId => MoveId[moveId]).join(", "); this.log(`Enemy Pokemon moveset set to ${movesetStr} (=[${moveset.join(", ")}])!`); return this; diff --git a/test/testUtils/mocks/mocksContainer/mockContainer.ts b/test/testUtils/mocks/mocksContainer/mockContainer.ts index f1371643ce3..d31165bb847 100644 --- a/test/testUtils/mocks/mocksContainer/mockContainer.ts +++ b/test/testUtils/mocks/mocksContainer/mockContainer.ts @@ -1,3 +1,4 @@ +import { coerceArray } from "#app/utils/common"; import type MockTextureManager from "#test/testUtils/mocks/mockTextureManager"; import type { MockGameObject } from "../mockGameObject"; @@ -216,11 +217,7 @@ export default class MockContainer implements MockGameObject { } add(obj: MockGameObject | MockGameObject[]): this { - if (Array.isArray(obj)) { - this.list.push(...obj); - } else { - this.list.push(obj); - } + this.list.push(...coerceArray(obj)); return this; } @@ -232,18 +229,12 @@ export default class MockContainer implements MockGameObject { addAt(obj: MockGameObject | MockGameObject[], index = 0): this { // Adds a Game Object to this Container at the given index. - if (!Array.isArray(obj)) { - obj = [obj]; - } - this.list.splice(index, 0, ...obj); + this.list.splice(index, 0, ...coerceArray(obj)); return this; } remove(obj: MockGameObject | MockGameObject[], destroyChild = false): this { - if (!Array.isArray(obj)) { - obj = [obj]; - } - for (const item of obj) { + for (const item of coerceArray(obj)) { const index = this.list.indexOf(item); if (index !== -1) { this.list.splice(index, 1); diff --git a/test/testUtils/mocks/mocksContainer/mockRectangle.ts b/test/testUtils/mocks/mocksContainer/mockRectangle.ts index 7f54a0e255f..a8eeb370115 100644 --- a/test/testUtils/mocks/mocksContainer/mockRectangle.ts +++ b/test/testUtils/mocks/mocksContainer/mockRectangle.ts @@ -1,3 +1,4 @@ +import { coerceArray } from "#app/utils/common"; import type { MockGameObject } from "../mockGameObject"; export default class MockRectangle implements MockGameObject { @@ -50,11 +51,7 @@ export default class MockRectangle implements MockGameObject { add(obj: MockGameObject | MockGameObject[]): this { // Adds a child to this Game Object. - if (Array.isArray(obj)) { - this.list.push(...obj); - } else { - this.list.push(obj); - } + this.list.push(...coerceArray(obj)); return this; } diff --git a/test/testUtils/mocks/mocksContainer/mockSprite.ts b/test/testUtils/mocks/mocksContainer/mockSprite.ts index df36b3a29fd..ed1f1df6609 100644 --- a/test/testUtils/mocks/mocksContainer/mockSprite.ts +++ b/test/testUtils/mocks/mocksContainer/mockSprite.ts @@ -1,6 +1,8 @@ +import { coerceArray } from "#app/utils/common"; import Phaser from "phaser"; import type { MockGameObject } from "../mockGameObject"; -import Frame = Phaser.Textures.Frame; + +type Frame = Phaser.Textures.Frame; export default class MockSprite implements MockGameObject { private phaserSprite; @@ -204,11 +206,7 @@ export default class MockSprite implements MockGameObject { add(obj: MockGameObject | MockGameObject[]): this { // Adds a child to this Game Object. - if (Array.isArray(obj)) { - this.list.push(...obj); - } else { - this.list.push(obj); - } + this.list.push(...coerceArray(obj)); return this; } From 718d6f61cf435e69cb6dd9d070d4a8d0d69db089 Mon Sep 17 00:00:00 2001 From: damocleas Date: Fri, 13 Jun 2025 21:10:38 -0400 Subject: [PATCH 08/10] [Bug] Fix Fog interactions with Morning Sun/Synthesis/Moonlight and Solar Beam/Blade (#5987) Fix Weather based Healing Moves and Solar Beam/Blade not interacting with Fog Update move.ts --- src/data/moves/move.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index e713020cf9c..b46f109db9e 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -2156,6 +2156,7 @@ export class PlantHealAttr extends WeatherHealAttr { case WeatherType.SANDSTORM: case WeatherType.HAIL: case WeatherType.SNOW: + case WeatherType.FOG: case WeatherType.HEAVY_RAIN: return 0.25; default: @@ -4157,6 +4158,7 @@ export class AntiSunlightPowerDecreaseAttr extends VariablePowerAttr { case WeatherType.SANDSTORM: case WeatherType.HAIL: case WeatherType.SNOW: + case WeatherType.FOG: case WeatherType.HEAVY_RAIN: power.value *= 0.5; return true; From d91a6ee11ee2436cc477b1e47616291ef57af70f Mon Sep 17 00:00:00 2001 From: Bertie690 <136088738+Bertie690@users.noreply.github.com> Date: Fri, 13 Jun 2025 21:38:54 -0400 Subject: [PATCH 09/10] [Github] Update `pull_request_template.md` with more labels https://github.com/pagefaultgames/pokerogue/pull/5974 * Update pull_request_template.md with more labels More better * Fix create test script name post refactor Forgot to change it earlier --- .github/pull_request_template.md | 37 +++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a25a2f807f3..c7d8b1e4d9c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,25 +2,28 @@ + ## What are the changes the user will see? @@ -66,11 +69,11 @@ Do the reviewers need to do something special in order to test your changes? - [ ] Have I provided a clear explanation of the changes? - [ ] Have I tested the changes manually? - [ ] Are all unit tests still passing? (`npm run test:silent`) - - [ ] Have I created new automated tests (`npm run create-test`) or updated existing tests related to the PR's changes? + - [ ] Have I created new automated tests (`npm run test:create`) or updated existing tests related to the PR's changes? - [ ] Have I provided screenshots/videos of the changes (if applicable)? - [ ] Have I made sure that any UI change works for both UI themes (default and legacy)? Are there any localization additions or changes? If so: - [ ] Has a locales PR been created on the [locales](https://github.com/pagefaultgames/pokerogue-locales) repo? - [ ] If so, please leave a link to it here: -- [ ] Has the translation team been contacted for proofreading/translation? \ No newline at end of file +- [ ] Has the translation team been contacted for proofreading/translation? From 9a525ac8fd89743e9c8d4c8f4c96d369af5a9763 Mon Sep 17 00:00:00 2001 From: fabske0 <192151969+fabske0@users.noreply.github.com> Date: Sat, 14 Jun 2025 05:19:05 +0200 Subject: [PATCH 10/10] [UI/UX] Position setting Icons dynamically (#5969) * position setting icons dynamically * add comment for potential overlap --- src/ui/settings/abstract-control-settings-ui-handler.ts | 9 +++++++-- src/ui/settings/abstract-settings-ui-handler.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ui/settings/abstract-control-settings-ui-handler.ts b/src/ui/settings/abstract-control-settings-ui-handler.ts index 495a0f68540..e3631c062df 100644 --- a/src/ui/settings/abstract-control-settings-ui-handler.ts +++ b/src/ui/settings/abstract-control-settings-ui-handler.ts @@ -126,6 +126,11 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler ); this.actionsBg.setOrigin(0, 0); + /* + * If there isn't enough space to fit all the icons and texts, there will be an overlap + * This currently doesn't happen, but it's something to keep in mind. + */ + const iconAction = globalScene.add.sprite(0, 0, "keyboard"); iconAction.setOrigin(0, -0.1); iconAction.setPositionRelative(this.actionsBg, this.navigationContainer.width - 32, 4); @@ -137,7 +142,7 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler const iconCancel = globalScene.add.sprite(0, 0, "keyboard"); iconCancel.setOrigin(0, -0.1); - iconCancel.setPositionRelative(this.actionsBg, this.navigationContainer.width - 100, 4); + iconCancel.setPositionRelative(this.actionsBg, actionText.x - 28, 4); this.navigationIcons["BUTTON_CANCEL"] = iconCancel; const cancelText = addTextObject(0, 0, i18next.t("settings:back"), TextStyle.SETTINGS_LABEL); @@ -146,7 +151,7 @@ export default abstract class AbstractControlSettingsUiHandler extends UiHandler const iconReset = globalScene.add.sprite(0, 0, "keyboard"); iconReset.setOrigin(0, -0.1); - iconReset.setPositionRelative(this.actionsBg, this.navigationContainer.width - 180, 4); + iconReset.setPositionRelative(this.actionsBg, cancelText.x - 28, 4); this.navigationIcons["BUTTON_HOME"] = iconReset; const resetText = addTextObject(0, 0, i18next.t("settings:reset"), TextStyle.SETTINGS_LABEL); diff --git a/src/ui/settings/abstract-settings-ui-handler.ts b/src/ui/settings/abstract-settings-ui-handler.ts index 1fb4b6d34dc..a621b056e28 100644 --- a/src/ui/settings/abstract-settings-ui-handler.ts +++ b/src/ui/settings/abstract-settings-ui-handler.ts @@ -94,7 +94,7 @@ export default class AbstractSettingsUiHandler extends MessageUiHandler { const iconCancel = globalScene.add.sprite(0, 0, "keyboard"); iconCancel.setOrigin(0, -0.1); - iconCancel.setPositionRelative(actionsBg, this.navigationContainer.width - 100, 4); + iconCancel.setPositionRelative(actionsBg, actionText.x - 28, 4); this.navigationIcons["BUTTON_CANCEL"] = iconCancel; const cancelText = addTextObject(0, 0, i18next.t("settings:back"), TextStyle.SETTINGS_LABEL);