From 881a0e0ab9d057e3b0c342c5a234c867cb3cf390 Mon Sep 17 00:00:00 2001 From: sharktrexer Date: Thu, 26 Sep 2024 10:08:34 -0700 Subject: [PATCH] pet now uses speed of friend during chase of friend is slower --- src/panel/states.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/panel/states.ts b/src/panel/states.ts index 2e7547ab..70c9a621 100644 --- a/src/panel/states.ts +++ b/src/panel/states.ts @@ -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; }