import SpinningExpandedSymbolsSystem from './SpinningExpandedSymbolsSystem';

/**
 * @class InitSpinningExpandedSymbolsSystem
 * @extends SpinningExpandedSymbolsSystem
 * @description Handles the init of spinning expanded symbols. 
 */
export default class InitSpinningExpandedSymbolsSystem extends SpinningExpandedSymbolsSystem
{

    /**
     * Handles the actions to be performed when entering the system.
     * Initializes the state to active.
     */
    override onEnter(): void
    {
        this.state = 'active';
    }

    /**
     * Updates the state of the spin system based on the current state.
     */
    override update(): void
    {
        if (!this.machine.inputs.expandedSymbolsData) return;
        this.machine.inputs.expandedSymbolsData.forEach((expandedSymbolData: any, reelIndex: number) =>
        {
            if (!expandedSymbolData) return;
            const { key, value } = expandedSymbolData;
            const expandedSymbol = this.createSymbol({ ...this.machine.config.expandedSymbols[key], value }, reelIndex);
            this.landSymbol(expandedSymbol);
            this.updateSymbol(expandedSymbol);
        });
        this.state = 'stopped';
    }

    /**
     * Handles the actions to be performed when leaving the current state.
     * @returns {void}
     */
    override onLeave(): void
    {
    }
}