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

/**
 * @class Spinning
 * @extends State
 * @description Represents the spinning phase of a reel. In this state, the reel maintains a constant maximum speed.
 */
export default class Spinning extends State
{
    private reel: Reel;

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

    /** Sets the reel's speed to the maximum speed defined in its settings. Called when the state is entered. */
    override enter(): void
    {
        this.reel.speed = this.reel.maxSpeed;
    }

    /**
     * Updates the reel's position based on its speed and the time delta.
     * @param {number} dt - Delta time since the last update, in milliseconds.
     */
    override update(dt: number): void
    {
        this.reel.position += dt * 0.001 * this.reel.speed;
    }

}
