import Action from "./Action";

// Entity
export default class Exploration {
    private _isStopped: boolean;
    private _explorationNumber: number;
    private _actionList: Action[];

    constructor(explorationNumber: number) {
        if (explorationNumber === null || explorationNumber === undefined) {
            throw new Error("cannot create exploration, explorationNumber is null or undefined");
        }
        this._explorationNumber = explorationNumber;

        this._isStopped = false;
        this._actionList = [];
    }

    public stop(): void {
        this._isStopped = true;
    }

    get isStopped(): boolean {
        return this._isStopped;
    }

    get explorationNumber(): number {
        return this._explorationNumber;
    }

    public addAction(action: Action): void {
        if (this.isStopped) {
            throw new Error("cannot add action to exploration, exploration is stopped");
        }
        this._actionList.push(action);
    }

    
    public addActionList(actionList: Action[]): void {
        if (this.isStopped) {
            throw new Error("cannot add comment to exploration, exploration is stopped");
        }
        this._actionList.push(...actionList);
    }

    get actionList(): Action[] {
        return this._actionList.slice();
    }

}
