import { GameMap } from "../game-map";
import { ResourceType } from "../resource-manager";
import { Building } from "./building";
import { Worker } from "../worker";

export abstract class ResouceBuilding extends Building {
    maxStorage = 10;
    public stored: Partial<Record<ResourceType, number>> = {};
    public assignedWorker: Worker | null = null;

    constructor(map: GameMap, x: number, y: number, buildings: Building[]) {
        super(map, x, y, buildings);
    }

    get storageFull(): boolean {
        return Object.values(this.stored).reduce((a, b) => a+b, 0) >= this.maxStorage;
    }

    
    abstract assignWorker(worker: Worker): void;

    update(dt: number) {
        if (this.assignedWorker) {
            this.assignedWorker.update(dt)
        }
    }
}