import { world, Player, system } from '@minecraft/server';
import { Command } from '../../handler';
import { sendPlayerMessage } from '../../../config';
import { randomN } from '../../../lifesteal';

new Command({
    name: `guess`,
    ghostsOnly: true,
    code({ player, args }) {
        if (isNaN(+args[0])) return sendPlayerMessage(player, `§cThats not a number!`);
        if (+args[0] <= 0 || +args[0] > 9) return sendPlayerMessage(player, `§cYou can only choose a number between 1-9!`);
        let chosen1 = +args[0];
        let chosen2 = randomN(1, 9);
        if (chosen1 == chosen2) {
            sendPlayerMessage(player, `§aYou won! It was ${chosen2}`);
            return;
        }
        sendPlayerMessage(player, `§cYou lost! It was ${chosen2}`);
    }
});