import Reel from '../../systems/reels/Reel';
import { State } from '@popiplay/state-machine';

/**
 * @class Stopped
 * @extends State
 * @description Represents the stopped phase of a reel. In this state, the reel is stationary at the specified stop position.
 */
export default class Stopped extends State
{
    private reel: Reel;

    /**
     * @class
     * @param {Reel} reel - The reel instance that this state belongs to.
     */
    constructor(reel: Reel)
    {
        super('Stopped');
        this.reel = reel;
    }

    /** Sets the reel's position to the final stop position and applies a bounce effect. Called when the state is entered. */
    public override enter(): void
    {
        this.reel.position = this.reel.stopPosition;
        this.reel.onStop();
    }

    /**
     * Sets the reel's speed to zero to ensure it remains stationary.
     * @param {number} _dt - Delta time since the last update, in milliseconds.
     */
    public override update(_dt: number): void
    {
        this.reel.speed = 0;
    }
}
