import { updatePlanetDefenses } from "../../db/planets";
import { Planet } from "./PlanetManager";
import DefenseManager from "./abstract/DefenseManager";

export default class PlanetDefenseManager extends DefenseManager {
    constructor(planet: Planet) {
        super(planet);
    }

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

    async sync() {
        await updatePlanetDefenses(this.manager._id, this.defenses.map(def => { return { id: def.data.id, amount: def.amount } }));
    }
}