import BaseMachine from 'src/slotMachines/BaseMachine';
import { WinLineRecord, WinsData } from 'src/types/WinsData';
import BaseSystem from '../systems/BaseSystem';

export default class SetAllWinLinesSystem extends BaseSystem
{
    public state: 'watch' | 'animating' | 'stopped' = 'stopped';

    static override requiredInputs: string[] = ['wins'];
    static override sharedSystemData: string[] = ['animateLines'];

    constructor(machine: BaseMachine)
    {
        super(machine);
    }

    override onEnter()
    {
        this.handleWinsData();
    }

    override update(_dt: number)
    {
    // Do nothing
    }

    override onLeave()
    {
    // Do nothing
    }

    private handleWinsData()
    {
        const winsData: WinsData = this.machine.inputs.wins;
        const wins: WinLineRecord[] = winsData.wins;

        wins.forEach((win: WinLineRecord) =>
        {
            this.machine.sharedSystemData.animateLines.push(win.lineIndex);
        });
    }
}
