import { MinecraftDimensionTypes, world } from "@minecraft/server";
import config from "../config";
import { Buttons } from "./my_API";
export class Setting {
    constructor(id, defaultValue, button) {
        this.id = id;
        this.defaultValue = defaultValue;
        if (button !== undefined) {
            this.button = button;
        }
        else {
            this.button = undefined;
        }
    }
    getDescription() {
        return `nps_mot:${this.id}Description`;
    }
}
export var parameterNames;
(function (parameterNames) {
    parameterNames["GCUA"] = "GCUA";
    parameterNames["oreGeneration"] = "oreGeneration";
    parameterNames["armorEffects"] = "armorEffects";
    parameterNames["repairKitDrops"] = "repairKitDrops";
    parameterNames["monsterDrops"] = "monsterDrops";
    parameterNames["jewelDrops"] = "jewelDrops";
    parameterNames["damageIndicators"] = "damageIndicators";
    parameterNames["apocalysisDifficulty"] = "apocalysisDifficulty";
    parameterNames["oreMerchantInvocation"] = "oreMerchantInvocation";
    parameterNames["oreGenerationDistance"] = "oreGenerationDistance";
})(parameterNames || (parameterNames = {}));
;
export class Settings {
    static getSettingsScoreboard() {
        let scoreboard = world.scoreboard.getObjective(this.objectiveId);
        if (!scoreboard) {
            scoreboard = world.scoreboard.addObjective(this.objectiveId, this.objectiveId);
            for (const setting of this.settings) {
                scoreboard.setScore(setting.id, setting.defaultValue);
            }
        }
        for (const setting of this.settings) {
            if (scoreboard.hasParticipant(setting.id) == false) {
                scoreboard.setScore(setting.id, setting.defaultValue);
            }
        }
        return scoreboard;
    }
    static getSetting(settingId) {
        return this.settings.find(setting => setting.id === settingId);
    }
    static getValue(settingId) {
        const scoreboard = this.getSettingsScoreboard();
        const score = scoreboard.getScore(settingId);
        return score !== undefined ? score : undefined;
    }
    static setValue(settingId, value) {
        const scoreboard = this.getSettingsScoreboard();
        scoreboard.setScore(settingId, value);
    }
}
Settings.objectiveId = config.settingsObjectiveId;
Settings.settings = [
    new Setting(parameterNames.oreGeneration, 1, Buttons.ore_generation),
    //new Setting(parameterNames.oreGenerationDistance, 2, Buttons.ore_generation_distance),
    new Setting(parameterNames.armorEffects, 1, Buttons.armor_effects),
    new Setting(parameterNames.damageIndicators, 1, Buttons.damage_indicators),
    new Setting(parameterNames.repairKitDrops, 1, Buttons.repair_kit_drops),
    new Setting(parameterNames.monsterDrops, 1, Buttons.monster_drops),
    new Setting(parameterNames.jewelDrops, 1, Buttons.jewel_drops),
    new Setting(parameterNames.apocalysisDifficulty, 0, Buttons.apocalysis_difficulty),
    new Setting(parameterNames.oreMerchantInvocation, 1, Buttons.ore_merchant_invocation)
];
export function getRegionScoreboard(dimensionId) {
    let scoreboard = undefined;
    switch (dimensionId) {
        case world.getDimension(MinecraftDimensionTypes.overworld).id: {
            scoreboard = world.scoreboard.getObjective(config.OOGOI);
            if (scoreboard === undefined) {
                scoreboard = world.scoreboard.addObjective(config.OOGOI, config.OOGOI);
            }
            break;
        }
        case world.getDimension(MinecraftDimensionTypes.nether).id: {
            scoreboard = world.scoreboard.getObjective(config.NOGOI);
            if (scoreboard === undefined) {
                scoreboard = world.scoreboard.addObjective(config.NOGOI, config.NOGOI);
            }
            break;
        }
        case world.getDimension(MinecraftDimensionTypes.theEnd).id: {
            scoreboard = world.scoreboard.getObjective(config.EOGOI);
            if (scoreboard === undefined) {
                scoreboard = world.scoreboard.addObjective(config.EOGOI, config.EOGOI);
            }
            break;
        }
    }
    return scoreboard;
}
