import { GameMap } from "../game-map";
import { Worker } from "../worker";

export type JobState = 'pending' | 'walking' | 'working' | 'returning' | 'done';

export abstract class Job {
    state: JobState = 'pending';
    progress = 0;
    workDuration = 3; // sekunden
    protected map: GameMap;
    protected worker: Worker;

    constructor(map: GameMap, worker: Worker) {
        this.map = map;
        this.worker = worker;
    }

    /** Initialisierung (z. B. Pfad setzen) */
    abstract start(): void;

    /** Wird pro Frame aufgerufen */
    abstract update(dt: number): void;

    /** Ob Job abgeschlossen ist */
    get done(): boolean {
        return this.state === 'done';
    }

    walk(dt: number) {
         if (this.worker.followPath(dt)) {
            this.state = 'working';
            this.progress = 0;
        }
        
    }
} 