type PlayerStateCommandGuardOption = {
    alive?: boolean;
    wounded?: boolean;
    knocked?: boolean;
    dead?: boolean;
};

export const PlayerStateCommandGuard = (options?: PlayerStateCommandGuardOption): CommandGuard => {
    return (player: PlayerMp) => {
        if (!options) {
            return true;
        }

        if (options.alive !== undefined) {
            if (options.alive && player.state.deathState !== 'ALIVE') {
                return `You must be alive.`;
            } else if (!options.alive && player.state.deathState === 'ALIVE') {
                return `You must not be alive.`;
            }
        }

        if (options.wounded !== undefined) {
            if (options.wounded && player.state.deathState !== 'WOUNDED') {
                return `You aren't brutally wounded.`;
            } else if (!options.wounded && player.state.deathState === 'WOUNDED') {
                return `You're brutally wounded.`;
            }
        }

        if (options.knocked !== undefined) {
            if (!options.knocked && player.state.deathState === 'KNOCKED') {
                return `You're knocked out.`;
            }
        }

        if (options.dead !== undefined) {
            if (options.dead && player.state.deathState !== 'DEAD') {
                return `You aren't dead.`;
            } else if (!options.dead && player.state.deathState === 'DEAD') {
                return `You're dead.`;
            }
        }

        return true;
    };
};
