package data.scripts.campaign.econ;

import com.fs.starfarer.api.impl.campaign.econ.impl.OrbitalStation;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Stats;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;

public class II_StellaCastellum extends OrbitalStation {

    public static float DEFENSE_BONUS_CASTELLUM = 3f;

    @Override
    public void apply() {
        super.apply(false);

        int size = 9;

        modifyStabilityWithBaseMod();

        applyIncomeAndUpkeep(size);

        demand(Commodities.CREW, size);
        demand(Commodities.SUPPLIES, size);

        market.getStats().getDynamic().getMod(Stats.GROUND_DEFENSES_MOD).modifyMult(getModId(), 1f + DEFENSE_BONUS_CASTELLUM, getNameForModifier());

        matchCommanderToAICore(aiCoreId);

        if (!isFunctional()) {
            supply.clear();
            unapply();
        } else {
            applyCRToStation();
        }
    }

    @Override
    protected void addPostDemandSection(TooltipMakerAPI tooltip, boolean hasDemand, IndustryTooltipMode mode) {
        if (mode != IndustryTooltipMode.NORMAL || isFunctional()) {
            Color h = Misc.getHighlightColor();
            float opad = 10f;

            float cr = getCR();
            tooltip.addPara("Station combat readiness: %s", opad, h, "" + Math.round(cr * 100f) + "%");

            addStabilityPostDemandSection(tooltip, hasDemand, mode);

            addGroundDefensesImpactSection(tooltip, DEFENSE_BONUS_CASTELLUM, Commodities.SUPPLIES);
        }
    }

    @Override
    protected int getBaseStabilityMod() {
        return 4;
    }

    @Override
    public boolean isAvailableToBuild() {
        return false;
    }

    @Override
    public boolean showWhenUnavailable() {
        return false;
    }
}
