import * as mc from "@minecraft/server";
import { Achievement } from "./achievement";
import { NPCBase } from "../npc/index";
export class WardenAchievement extends Achievement {
    constructor() {
        super(...arguments);
        this.SkinIndex = 15;
    }
    onSetup() {
        mc.world.afterEvents.entityHurt.subscribe(this.hurtWarden.bind(this), { entityTypes: ["minecraft:warden"] });
    }
    hurtWarden(event) {
        var _a;
        if (((_a = event.damageSource.damagingEntity) === null || _a === void 0 ? void 0 : _a.typeId) === "ldz_crcomp:craftee") {
            const craftee = NPCBase.getNPC(event.damageSource.damagingEntity.id);
            if (craftee) {
                this.setStatus(craftee.Owner, true);
            }
        }
    }
    getStatusText(player) {
        if (this.getStatus(player)) {
            return { rawtext: [
                    { translate: `ldz_crcomp:craftee.achievement.${this.TypeId}.title.completed` },
                    { text: "\n" },
                    { translate: `ldz_crcomp:craftee.achievement.${this.TypeId}.status.completed`, with: { rawtext: [
                                { translate: "entity.warden.name" },
                            ] } },
                    { text: "\n\n" },
                ] };
        }
        else {
            return { rawtext: [
                    { translate: `ldz_crcomp:craftee.achievement.${this.TypeId}.title.in_progress` },
                    { text: "\n" },
                    { translate: `ldz_crcomp:craftee.achievement.${this.TypeId}.status.in_progress`, with: { rawtext: [
                                { translate: "entity.warden.name" },
                            ] } },
                    { text: "\n\n" },
                ] };
        }
    }
}
new WardenAchievement();
