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; }