Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sharktrexer/master
Browse files Browse the repository at this point in the history
pet now uses speed of friend during chase of friend is slower
sharktrexer authored Sep 26, 2024
2 parents 67b36bd + 881a0e0 commit 21e3718
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/panel/states.ts
Original file line number Diff line number Diff line change
@@ -354,14 +354,17 @@ export class ChaseFriendState implements IState {
if (!this.pet.hasFriend || !this.pet.friend?.isPlaying) {
return FrameResult.stateCancel; // Friend is no longer playing.
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
// Pet uses speed of friend during chase if friend is slower
/* eslint-disable @typescript-eslint/no-non-null-assertion */
const speed = this.pet.speed > this.pet.friend!.speed ? this.pet.friend!.speed : this.pet.speed;
if (this.pet.left > this.pet.friend!.left) {
this.horizontalDirection = HorizontalDirection.left;
this.pet.positionLeft(this.pet.left - this.pet.speed);
this.pet.positionLeft(this.pet.left - speed);
} else {
this.horizontalDirection = HorizontalDirection.right;
this.pet.positionLeft(this.pet.left + this.pet.speed);
this.pet.positionLeft(this.pet.left + speed);
}
/* eslint-enable @typescript-eslint/no-non-null-assertion */

return FrameResult.stateContinue;
}

0 comments on commit 21e3718

Please sign in to comment.