import { Planet } from "./PlanetManager";
import EnergyManager from "./abstract/EnergyManager";

export default class PlanetEnergyManager extends EnergyManager {
    constructor(system: Planet) {
        super(system);
    }

    get manager() {
        return this._manager as Planet;
    }

    update() {
        const buildings = this.manager.buildings.buildings;

        this.production = 0;
        this.consumption = 0;

        for(const building of buildings) {
            if(building.data.category === "power-plants") {
                this.production += (building.data.energy * building.level);
            } else {
                this.consumption += (building.data.energy * building.level);
            }
        }

        return this;
    }
}