Skip to content

Commit

Permalink
[Hotfix] Prevent crash if enemy Future Sight user is caught (#4905)
Browse files Browse the repository at this point in the history
  • Loading branch information
DayKev authored Nov 18, 2024
1 parent 89a3edb commit dd904fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pokemon-rogue-battle",
"private": true,
"version": "1.2.0",
"version": "1.2.1",
"type": "module",
"scripts": {
"start": "vite",
Expand Down
7 changes: 5 additions & 2 deletions src/field/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3243,11 +3243,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
return null;
}

getMoveHistory(): TurnMove[] {
public getMoveHistory(): TurnMove[] {
return this.battleSummonData.moveHistory;
}

pushMoveHistory(turnMove: TurnMove) {
public pushMoveHistory(turnMove: TurnMove): void {
if (!this.isOnField()) {
return;
}
turnMove.turn = this.scene.currentBattle?.turn;
this.getMoveHistory().push(turnMove);
}
Expand Down
10 changes: 7 additions & 3 deletions src/phases/move-effect-phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ export class MoveEffectPhase extends PokemonPhase {

const isDelayedAttack = this.move.getMove().hasAttr(DelayedAttackAttr);
/** If the user was somehow removed from the field and it's not a delayed attack, end this phase */
if (!user.isOnField() && !isDelayedAttack) {
return super.end();
if (!user.isOnField()) {
if (!isDelayedAttack) {
return super.end();
} else {
user.resetTurnData();
}
}

/**
Expand Down Expand Up @@ -174,7 +178,7 @@ export class MoveEffectPhase extends PokemonPhase {

const playOnEmptyField = this.scene.currentBattle?.mysteryEncounter?.hasBattleAnimationsWithoutTargets ?? false;
// Move animation only needs one target
new MoveAnim(move.id as Moves, user, this.getFirstTarget()!.getBattlerIndex()!, playOnEmptyField).play(this.scene, move.hitsSubstitute(user, this.getFirstTarget()!), () => {
new MoveAnim(move.id as Moves, user, this.getFirstTarget()!.getBattlerIndex(), playOnEmptyField).play(this.scene, move.hitsSubstitute(user, this.getFirstTarget()!), () => {
/** Has the move successfully hit a target (for damage) yet? */
let hasHit: boolean = false;
for (const target of targets) {
Expand Down

0 comments on commit dd904fe

Please sign in to comment.