// Script for talking to herobrine and herobrine related chat situations

// vars
var HelloReplyChance = 300
var FuckHerobrineReplyChance = 150
var IsAnyonethereChance = 300
var WhoAreYouChance = 400


// listens for play sending message
PlayerEvents.chat(event => {
    // checks what the player sent
    switch(event.message.toLowerCase())
    {
        case "hello":
            if (RandomReply(HelloReplyChance) == 1)
            {
                HerobrineReply("Hi", event)
            }
        case "fuck herobrine":
            if (RandomReply(FuckHerobrineReplyChance) == 1)
            {
                HerobrineReply("You shouldn't have done that", event)
            }
        case "is anyone there?":
            if (RandomReply(IsAnyonethereChance) == 1)
            {
                HerobrineReply("Look behind you.", event)
                event.player.playNotifySound("block.wooden_door.open", "ambient", 1, 1)
            }
        case "who are you?":
            if (RandomReply(WhoAreYouChance) == 1)
            {
                HerobrineReply("Your nightmare", event)
            }
    }
})

// Function for getting a random number
function RandomReply(RandomChance)
{
    return Math.floor(Math.random() * RandomChance) + 1
}

// Function that handles replying to the player
function HerobrineReply(ReplyText, event)
{
    console.info("Herobrine Reply")

    setTimeout(() => {
        event.player.tell(`<§k!@#%^?§r> ${ReplyText}`)
    }, 3000)
}