mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-23 21:45:50 +02:00
* Grabbed reverted changes from stuff
* Added version migrator for rage fist data + deepMergeSpriteData tests
* fixed formattign
* Fied a few
* Fixed constructor (maybe), moved deepCopy and deepMergeSpriteData to own file
`common.ts` is hella bloated so seems legit
* Moved empty moveset verification mapping thing to upgrade script bc i wanted to
* Fixed tests
* test added
* Fixed summondata being cleared inside summonPhase, removed `summonDataPrimer`
like seriously how come no-one checked this
* Fixed test
I forgot that we outsped and oneshot
* Fixed test
* huhjjjjjb
* Hopefully fixed bug
my sanity and homework are paying the price for this lol
* added commented out console.log statement
uncomment to see new berry data
* Fixed migrate script, re-added deprecated attributes out of necessity
* Fixed failing test by not trying to mock rng
* Fixed test
* Fixed tests
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update overrides.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update berry-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update encounter-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update game-data.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move-phase.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Added utility function `randSeedFloat`
basically just `Phaser.math.RND.realInRange(0, 1)`
* Applied review comments, cleaned up code a bit
* Removed unnecessary null checks for turnData and co.
I explicitly made them initialized by default for this very reason
* Added tests for Last Resort regarding moveHistory
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update battle-scene.ts
Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
* Update the-winstrate-challenge-encounter.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update ability.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update move.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update battle-anims.ts
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
* Update pokemon.ts comments
* Fixed a few outstanding issues with documentation
* Updated switch summon phase comment
* Re-added BattleSummonData as TempSummonData
* Hppefully fixed -1 sprite scale glitch
* Fixed comment
* Reveted `pokemon-forms.ts`
* Fuxed constructor
* fixed -1 bug
* Revert "Added utility function `randSeedFloat`"
This reverts commit 4c3447c851.
---------
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com>
78 lines
2.5 KiB
TypeScript
78 lines
2.5 KiB
TypeScript
import {
|
|
applyAbAttrs,
|
|
PreventBerryUseAbAttr,
|
|
HealFromBerryUseAbAttr,
|
|
RepeatBerryNextTurnAbAttr,
|
|
} from "#app/data/abilities/ability";
|
|
import { CommonAnim } from "#app/data/battle-anims";
|
|
import { BerryUsedEvent } from "#app/events/battle-scene";
|
|
import { getPokemonNameWithAffix } from "#app/messages";
|
|
import { BerryModifier } from "#app/modifier/modifier";
|
|
import i18next from "i18next";
|
|
import { BooleanHolder } from "#app/utils/common";
|
|
import { FieldPhase } from "./field-phase";
|
|
import { CommonAnimPhase } from "./common-anim-phase";
|
|
import { globalScene } from "#app/global-scene";
|
|
import type Pokemon from "#app/field/pokemon";
|
|
|
|
/**
|
|
* The phase after attacks where the pokemon eat berries.
|
|
* Also triggers Cud Chew's "repeat berry use" effects
|
|
*/
|
|
export class BerryPhase extends FieldPhase {
|
|
start() {
|
|
super.start();
|
|
|
|
this.executeForAll(pokemon => {
|
|
this.eatBerries(pokemon);
|
|
applyAbAttrs(RepeatBerryNextTurnAbAttr, pokemon, null);
|
|
});
|
|
|
|
this.end();
|
|
}
|
|
|
|
/**
|
|
* Attempt to eat all of a given {@linkcode Pokemon}'s berries once.
|
|
* @param pokemon - The {@linkcode Pokemon} to check
|
|
*/
|
|
eatBerries(pokemon: Pokemon): void {
|
|
const hasUsableBerry = !!globalScene.findModifier(
|
|
m => m instanceof BerryModifier && m.shouldApply(pokemon),
|
|
pokemon.isPlayer(),
|
|
);
|
|
|
|
if (!hasUsableBerry) {
|
|
return;
|
|
}
|
|
|
|
// 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));
|
|
if (cancelled.value) {
|
|
globalScene.queueMessage(
|
|
i18next.t("abilityTriggers:preventBerryUse", {
|
|
pokemonNameWithAffix: getPokemonNameWithAffix(pokemon),
|
|
}),
|
|
);
|
|
return;
|
|
}
|
|
|
|
globalScene.unshiftPhase(
|
|
new CommonAnimPhase(pokemon.getBattlerIndex(), pokemon.getBattlerIndex(), CommonAnim.USE_ITEM),
|
|
);
|
|
|
|
for (const berryModifier of globalScene.applyModifiers(BerryModifier, pokemon.isPlayer(), pokemon)) {
|
|
// No need to track berries being eaten; already done inside applyModifiers
|
|
if (berryModifier.consumed) {
|
|
berryModifier.consumed = false;
|
|
pokemon.loseHeldItem(berryModifier);
|
|
}
|
|
globalScene.eventTarget.dispatchEvent(new BerryUsedEvent(berryModifier));
|
|
}
|
|
globalScene.updateModifiers(pokemon.isPlayer());
|
|
|
|
// Abilities.CHEEK_POUCH only works once per round of nom noms
|
|
applyAbAttrs(HealFromBerryUseAbAttr, pokemon, new BooleanHolder(false));
|
|
}
|
|
}
|