import * as mc from "@minecraft/server";
import * as utils from "../../utils/index";
utils.afterEvents.scriptEventRecieve.subscribe("ldz:hint", event => {
    var _a;
    const player = (_a = event.sourceEntity) === null || _a === void 0 ? void 0 : _a.getPlayer();
    if (!player)
        return;
    utils.waitForEvent(20, () => {
        switch (event.data) {
            case "tutorial":
                showHeartSorterHint(player);
                break;
            case "postgame":
                showPostGameHint(player);
                break;
            default:
                player.sendMessage(utils.TextFormat.red(("Unknown hint type: " + event.data + " valid types are 'tutorial' and 'postgame'")));
                break;
        }
    });
});
export async function showHeartSorterHint(player) {
    await new utils.MenuBuilder({
        type: "buttons",
        title: utils.translate('craftee.tutorial.title'),
        body: utils.translate('craftee.tutorial.body'),
        onPageOpen: () => {
            player.addTag("hint_menu");
            player.setGameMode(mc.GameMode.creative);
            player.playSound('craftee.dialogue.re_explain');
        },
        contents: [
            {
                text: utils.translate('craftee.tutorial.button'),
                onClick: () => { }
            }
        ]
    }).queueMenuForPlayer(player);
    if (player.isValid()) {
        player.removeTag("hint_menu");
        player.setGameMode(mc.GameMode.survival);
        player.stopSound({ soundId: "craftee.dialogue.re_explain", players: [player] });
    }
}
export async function showPostGameHint(player) {
    await new utils.MenuBuilder({
        type: "buttons",
        title: utils.translate('postgame.menu.title'),
        body: utils.translate('postgame.menu.body'),
        onPageOpen: () => {
            player.addTag("hint_menu");
            player.playSound('post_game.achievement');
            player.playSound('post_game.dialogue');
            player.setGameMode(mc.GameMode.creative);
        },
        contents: [
            {
                text: utils.translate('postgame.menu.button'),
                onClick: () => { }
            }
        ]
    }).showMenuToPlayer(player);
    if (player.isValid()) {
        player.removeTag("hint_menu");
        player.setGameMode(mc.GameMode.survival);
    }
}
