import Action from "./Action";
import Guard from "./Guard";

export abstract class Objective {

    name; string;
    status: boolean;
    type: string;
    id: string;
    nextActions: Action[];
    nextGuards: Guard[];

    constructor(id: string, name: string, status: boolean, type: string, nextActions:Action[] = [], nextGuards: Guard[] = []) {
        this.id = id;
        this.name = name;
        this.status = status;
        this.type = type;
        this.nextActions = nextActions;
        this.nextGuards = nextGuards;
    }

    public static parseObjective(object: any) {
        if (object.type === "step") {
            return new StepObjective(object.id, object.name, object.status, object.text);
        } else {
            throw new Error("Invalid Objective data" + object.toStrin());
        }
    }
}


export class StepObjective extends Objective{

    public text: string;

    constructor(id: string, name: string, status: boolean, text: string) {
        super(id, name, status, "step")
        this.text = text;
    }
}

export class CheckList {
    public objectiveList: Objective[];

    constructor(objectiveList: Objective[] = []) {
        this.objectiveList = objectiveList;
    }

    public update(evaluationDataList: any[]): void {

       
    }

    public isFulfilled(): boolean {
        return this.objectiveList.every(objective => objective.status)
    }
}