mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-22 13:05:51 +02:00
* Replace various `scene` pass-arounds with global scene variable * Modify tests * Add scene back to `fade[in|out]()` calls Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Fix Bug Superfan ME test Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Re-enable fixed test Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com> * Rename `gScene` to `globalScene` * Move `globalScene` to its own file to fix import/async issues * Fix `SelectModifierPhase` tests * Fix ME tests by removing `scene` from `expect()`s * Resolve merge issues * Remove tsdocs referencing `scene` params Remove missed instances of `.scene` * Remove unnecessary `globalScene` usage in `loading-scene.ts` * Fix merge conflicts * Attempt to fix circular import issue * Found the source of the import issue * Fix merge issues --------- Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com>
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { globalScene } from "#app/global-scene";
|
|
import { TrainerSlot } from "#app/data/trainer-config";
|
|
import { Phase } from "#app/phase";
|
|
|
|
export class BattlePhase extends Phase {
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
showEnemyTrainer(trainerSlot: TrainerSlot = TrainerSlot.NONE): void {
|
|
const sprites = globalScene.currentBattle.trainer?.getSprites()!; // TODO: is this bang correct?
|
|
const tintSprites = globalScene.currentBattle.trainer?.getTintSprites()!; // TODO: is this bang correct?
|
|
for (let i = 0; i < sprites.length; i++) {
|
|
const visible = !trainerSlot || !i === (trainerSlot === TrainerSlot.TRAINER) || sprites.length < 2;
|
|
[ sprites[i], tintSprites[i] ].map(sprite => {
|
|
if (visible) {
|
|
sprite.x = trainerSlot || sprites.length < 2 ? 0 : i ? 16 : -16;
|
|
}
|
|
sprite.setVisible(visible);
|
|
sprite.clearTint();
|
|
});
|
|
sprites[i].setVisible(visible);
|
|
tintSprites[i].setVisible(visible);
|
|
sprites[i].clearTint();
|
|
tintSprites[i].clearTint();
|
|
}
|
|
globalScene.tweens.add({
|
|
targets: globalScene.currentBattle.trainer,
|
|
x: "-=16",
|
|
y: "+=16",
|
|
alpha: 1,
|
|
ease: "Sine.easeInOut",
|
|
duration: 750
|
|
});
|
|
}
|
|
|
|
hideEnemyTrainer(): void {
|
|
globalScene.tweens.add({
|
|
targets: globalScene.currentBattle.trainer,
|
|
x: "+=16",
|
|
y: "-=16",
|
|
alpha: 0,
|
|
ease: "Sine.easeInOut",
|
|
duration: 750
|
|
});
|
|
}
|
|
}
|