import BaseMachine from '../slotMachines/BaseMachine';
import BaseSystem from '../systems/BaseSystem';

/**
 * @class WinningLinesResetIncrementSystem
 * @description
 * System responsible for resetting the `currentWinIndex` to `0` when activated.
 *
 * This system:
 * - Stores `currentWinIndex` in `sharedSystemData` to track the active win.
 * - Resets `currentWinIndex = 0` when entering (`onEnter()`).
 *
 * It does **not** modify game visuals, animations, or gameplay logic beyond resetting the index.
 */
export default class WinningLinesResetIncrementSystem extends BaseSystem
{
    /** System state, always `"stopped"` after execution. */
    public state = 'stopped';

    /** Shared system data: keeps track of the current win index. */
    static override sharedSystemData: string[] = ['currentWinIndex'];

    /**
     * Creates an instance of `WinningLinesResetIncrementSystem`.
     * Initializes `currentWinIndex` to `0`.
     * @param {BaseMachine} machine - Reference to the slot machine instance.
     */
    constructor(machine: BaseMachine)
    {
        super(machine);
        this.machine.sharedSystemData.currentWinIndex = 0;
    }

    /** Called when the system becomes active. Resets the win index to `0`. */
    override onEnter()
    {
        this.resetWinIndex();
    }

    /** Called when the system exits. Currently does nothing but can be extended in the future. */
    override onLeave()
    {
        // Do nothing
    }

    /**
     * Resets `currentWinIndex` to `0`.
     * @private
     */
    private resetWinIndex()
    {
        this.machine.sharedSystemData.currentWinIndex = 0;
    }

    /**
     * This system does not update per frame.
     * @param {number} _dt - Delta time since the last update (not used).
     */
    update(_dt: number)
    {
        // Do nothing
    }
}
