import { world, system, ItemStack } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";

// missoes diarias

const daily = [
  {
    "name": `%npc.button.15`,
    "max": 1,
    "property": "chestDaily",
    "body": `%npc.text.7`,
    "rank": "e",
    "symbol": "",
    "xp": 2,
    "moedas": 5,
    "stars": 1,
    "indice": 0
  },
  {
    "name": "%npc.button.16",
    "max": 2,
    "property": "banditDaily",
    "body": "%npc.text.8",
    "rank": "e",
    "symbol": "",
    "xp": 5,
    "moedas": 10,
    "stars": 1,
    "indice": 1
  },
  {
    "name": "%npc.button.17",
    "max": 5,
    "property": "boarDaily",
    "body": "%npc.text.9",
    "rank": "e",
    "symbol": "",
    "xp": 5,
    "moedas": 10,
    "stars": 1,
    "indice": 2
  },
  {
    "name": "%npc.button.18",
    "max": 25,
    "property": "mobDaily",
    "body": "%npc.text.10",
    "rank": "e",
    "symbol": "",
    "xp": 5,
    "moedas": 5,
    "stars": 1,
    "indice": 3
  },
  {
    "name": "%npc.button.25",
    "max": 1,
    "property": "npcBuy",
    "body": "%npc.text.15",
    "rank": "e",
    "symbol": "",
    "xp": 2,
    "moedas": 5,
    "stars": 1,
    "indice": 4
  }
]

const history = [
  {
    body: `%npc.text.11`,
    stars: 1,
    xp: 10,
    moedas: 30,
    rank: "",
    spawn(player) {
      player.runCommand("tp @s ~~~ ~ 0")
      player.runCommand("summon yokai:revchi ^^^4")
      const entities = player.dimension.getEntities({
        location: player.location,
        maxDistance: 15,
        type: "yokai:revchi",
      })
      for (let entity of entities) {
        const tags = entity.getTags()
        if (tags.length > 0) continue
        entity.addTag(`h${player.id}`)
      }
    }
  },
  {
    body: `%npc.text.13`,
    stars: 1,
    xp: 20,
    moedas: 50,
    rank: "",
    spawn(player) {
      player.runCommand("tp @s ~~~ ~ 0")
      player.runCommand("summon yokai:fluss ^-3^^6")
      player.runCommand("summon yokai:fluss ^3^^6")
      player.runCommand("summon yokai:fluss2 ^^^9")
      const entities = player.dimension.getEntities({
        location: player.location,
        maxDistance: 15,
      })
      for (let entity of entities) {
        if (entity.typeId != "yokai:fluss" && entity.typeId != "yokai:fluss2") continue
        const tags = entity.getTags()
        if (tags.length > 0) continue
        entity.addTag(`h${player.id}`)
      }
    }
  },
  {
    body: `%npc.text.14`,
    stars: 1,
    xp: 40,
    moedas: 70,
    rank: "",
    spawn(player) {
      player.runCommand("tp @s ~~~ ~ 0")
      player.runCommand("summon yokai:heath ^^^4")
      const entities = player.dimension.getEntities({
        location: player.location,
        maxDistance: 15,
        type: "yokai:heath",
      })
      for (let entity of entities) {
        const tags = entity.getTags()
        if (tags.length > 0) continue
        entity.addTag(`h${player.id}`)
      }
    }
  }
  
]

export default daily

//Uso do item de menu
world.afterEvents.itemUse.subscribe(function (use) {
  const item = use.itemStack.typeId
  if (item === "yokai:menu_m") {
    const player = use.source
    Menu(player)
  }
})

//Menu inicial
function Menu(player) {
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  const menu = new ActionFormData()
    .title("menu")
    .button({translate:"npc.button.7"})
    .button({translate:"npc.button.8"})
    .button(`${moedas}`)
    .button(`${stars}`)
    .button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) Missoes(player)
    if (escolha.selection == 1) Classi(player)
  })
}


//Menu classificacao
function Classi(player) {
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  const menu = new ActionFormData()
    .title("classi")
    .button(" players")
    .button({translate:"npc.button.9"})
    .button("")
    .button(`${moedas}`)
    .button(`${stars}`)
    .button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) ClassiPlayers(player)
    if (escolha.selection == 1) ClassiSquads(player)
    if (escolha.selection == 2) Menu(player)
  }) 
}



//classificacao dos players
function ClassiPlayers(player) {
  const players = []
  world.getPlayers().forEach(cmc => {
    const stars = cmc.getDynamicProperty("stars") ?? 0
    let squad = "null";
    const squads = ["tn", "ap", "ra", "ad", "op", "ld", "rl", "cc", "pc"];
    squads.forEach(tag => {
        if (cmc.hasTag(tag)) squad = tag;
    });
    switch (squad) {
      case "null":
        squad = ""
      break
      case "pc":
        squad = ""
      break
      case "ld":
        squad = ""
      break
      case "ra":
        squad = ""
      break
      case "ap":
        squad = ""
      break
      case "ad":
        squad = ""
      break
      case "rl":
        squad = ""
      break
      case "tn":
        squad = ""
      break
      case "cc":
        squad = ""
      break
      case "op":
        squad = ""
      break
    }
    players.push(
      {
        name: `${cmc.name}${squad}`,
        stars: stars
      }
    )
  })
  const textBody = Classificar(players)
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  const menu = new ActionFormData()
    .title("classi_desc")
    .body(textBody)
    .button(" players")
    .button({translate:"npc.button.9"})
    .button("")
    .button(`${moedas}`)
    .button(`${stars}`)
    .button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) ClassiPlayers(player)
    if (escolha.selection == 1) ClassiSquads(player)
    if (escolha.selection == 2) Menu(player)
  }) 
}



//classificacao dos esquadroes
function ClassiSquads(player) {
  const squadsObj = []
  const squads = ["tn", "ap", "ra", "ad", "op", "ld", "rl", "cc", "pc"];
  squads.forEach((squad) => {
    switch (squad) {
      case "pc":
        squad = ""
      break
      case "ld":
        squad = ""
      break
      case "ra":
        squad = ""
      break
      case "ap":
        squad = ""
      break
      case "ad":
        squad = ""
      break
      case "rl":
        squad = ""
      break
      case "tn":
        squad = ""
      break
      case "cc":
        squad = ""
      break
      case "op":
        squad = ""
      break
    }
    const stars = world.getDynamicProperty(`${squad}Stars`) ?? 0
    squadsObj.push(
      {
        name: `${squad}`,
        stars: stars
      }
    )
  })
  const textBody = Classificar(squadsObj)
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  const menu = new ActionFormData()
    .title("classi_desc")
    .body(textBody)
    .button(" players")
    .button({translate:"npc.button.9"})
    .button("")
    .button(`${moedas}`)
    .button(`${stars}`)
    .button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) ClassiPlayers(player)
    if (escolha.selection == 1) ClassiSquads(player)
    if (escolha.selection == 2) Menu(player)
  }) 
}


function Classificar(obj) {
  const ordem = obj.sort((a, b) => b.stars - a.stars)
  
  let rank = 0
  let ultimoStars = null
  let text = ""
  ordem.slice(0, 9).forEach((item, index) => {
    let pulo = "" 
    if (index == 0) {
      pulo = "\n".repeat(Math.max(0, (ordem.length - 1) * 2 - 1))
    }
    item.rank = index + 1
    text += `${pulo}\n\n${item.rank}° ${item.stars}  ${item.name}`
  })
  return text
}



//Menu missoes
function Missoes(player) {
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  const menu = new ActionFormData()
    .title("missoes")
    .button({translate:"npc.button.10"})
    .button({translate:"npc.button.11"})
    .button("")
    .button(`${moedas}`)
    .button(`${stars}`)
    .button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) History1(player)
    if (escolha.selection == 1) DailyM(player)
    if (escolha.selection == 2) Menu(player)
  }) 
}





//Menu missoes diarias
function DailyM(player) {
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  const d1 = player.getDynamicProperty("daily1")
  const d2 = player.getDynamicProperty("daily2")
  const d3 = player.getDynamicProperty("daily3")
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  const menu = new ActionFormData()
    .title("daily")
    if (d1 != "resgatado") {
      menu.button(`${daily[d1].name} ${player.getDynamicProperty(daily[d1].property) ?? 0}/${daily[d1].max}`)
    } else {
      menu.button({translate:"npc.button.12"})
    }
    if (d2 != "resgatado") {
      menu.button(`${daily[d2].name} ${player.getDynamicProperty(daily[d2].property) ?? 0}/${daily[d2].max}`)
    } else {
      menu.button({translate:"npc.button.12"})
    }
    if (d3 != "resgatado") {
      menu.button(`${daily[d3].name} ${player.getDynamicProperty(daily[d3].property) ?? 0}/${daily[d3].max}`)
    } else {
      menu.button({translate:"npc.button.12"})
    }
    menu.button("")
    menu.button(`${moedas}`)
    menu.button(`${stars}`)
    menu.button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) {
      if (d1 != "resgatado") {
        dailyInfo(player, 1)
      } else {
        DailyM(player)
      }
    }
    if (escolha.selection == 1) {
      if (d2 != "resgatado") {
        dailyInfo(player, 2)
      } else {
        DailyM(player)
      }
    }
    if (escolha.selection == 2) {
      if (d3 != "resgatado") {
        dailyInfo(player, 3)
      } else {
        DailyM(player)
      }
    }
    if (escolha.selection == 3) Missoes(player)
  }) 
}


//Menu missoes diarias
function dailyInfo(player, d) {
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  const dCerto = player.getDynamicProperty(`daily${d}`)
  const d1 = player.getDynamicProperty("daily1")
  const d2 = player.getDynamicProperty("daily2")
  const d3 = player.getDynamicProperty("daily3")
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  
  
  const menu = new ActionFormData()
    .title("daily_info")
    .body(`\n\n\n\n\n\n\n${daily[dCerto].body}\n\nrank: ${daily[dCerto].symbol}\n\n%npc.text.6\n ${daily[dCerto].xp}\n ${daily[dCerto].moedas}\n ${daily[dCerto].stars}`)
    if (d1 != "resgatado") {
      menu.button(`${daily[d1].name} ${player.getDynamicProperty(daily[d1].property) ?? 0}/${daily[d1].max}`)
    } else {
      menu.button({translate:"npc.button.12"})
    }
    if (d2 != "resgatado") {
      menu.button(`${daily[d2].name} ${player.getDynamicProperty(daily[d2].property) ?? 0}/${daily[d2].max}`)
    } else {
      menu.button({translate:"npc.button.12"})
    }
    if (d3 != "resgatado") {
      menu.button(`${daily[d3].name} ${player.getDynamicProperty(daily[d3].property) ?? 0}/${daily[d3].max}`)
    } else {
      menu.button({translate:"npc.button.12"})
    }
    menu.button("")
    if ((player.getDynamicProperty(daily[dCerto].property) ?? 0) >= daily[dCerto].max) {
      menu.button({translate:"npc.button.14"})
    } else {
      menu.button({translate:"npc.button.13"})
    }
    menu.button(`${moedas}`)
    menu.button(`${stars}`)
    menu.button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) {
      if (d1 != "resgatado") {
        dailyInfo(player, 1)
      } else {
        DailyM(player)
      }
    }
    if (escolha.selection == 1) {
      if (d2 != "resgatado") {
        dailyInfo(player, 2)
      } else {
        DailyM(player)
      }
    }
    if (escolha.selection == 2) {
      if (d3 != "resgatado") {
        dailyInfo(player, 3)
      } else {
        DailyM(player)
      }
    }
    if (escolha.selection == 3) Missoes(player)
    
    if (escolha.selection == 4) {
      if ((player.getDynamicProperty(daily[dCerto].property) ?? 0) >= daily[dCerto].max) {
        player.runCommand("playsound random.levelup @s")
        const xpValue = player.getDynamicProperty("xp") ?? 0
        const starsValue = player.getDynamicProperty("stars") ?? 0
        world.scoreboard.getObjective("moedas").addScore(player, daily[dCerto].moedas)
        player.setDynamicProperty("xp", xpValue + daily[dCerto].xp)
        player.setDynamicProperty("stars", starsValue + daily[dCerto].stars)
        player.setDynamicProperty(`daily${d}`, "resgatado")
      }
      DailyM(player)
    }
  }) 
}





//missoes de historia 1
function History1(player) {
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  const h1 = player.getDynamicProperty("history1")
  const h2 = player.getDynamicProperty("history2")
  const h3 = player.getDynamicProperty("history3")
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  const menu = new ActionFormData()
    .title("history_noBack")
    if (h1 != "end") {
      menu.button(`%npc.button.19`)
    } else {
      menu.button(`%npc.button.21`)
    }
    if (h2) {
      if (h2 != "end") {
        menu.button(`%npc.button.23`)
      } else {
        menu.button(`%npc.button.21`)
      }
    } else {
        menu.button(`%npc.button.20`)
    }
    
    if (h3) {
      if (h3 != "end") {
        menu.button(`%npc.button.24`)
      } else {
        menu.button(`%npc.button.21`)
      }
    } else {
        menu.button(`%npc.button.20`)
    }
    menu.button("")
    menu.button(`${moedas}`)
    menu.button(`${stars}`)
    menu.button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) {
      if (h1 != "end") {
        History1_info(player, 0)
      } else {
        History1(player)
      }
    }
    if (escolha.selection == 1) {
      if (h2 == "open") {
        History1_info(player, 1)
      } else {
        History1(player)
      }
    }
    if (escolha.selection == 2) {
      if (h3 == "open") {
        History1_info(player, 2)
      } else {
        History1(player)
      }
    }
    if (escolha.selection == 3) Missoes(player)
  }) 
}



//missoes de historia 1 com info
function History1_info(player, mission) {
  const moedasScore = world.scoreboard.getObjective("moedas")
  const moedas = moedasScore.getScore(player)
  const stars = player.getDynamicProperty("stars") ?? 0
  const h1 = player.getDynamicProperty("history1")
  const h2 = player.getDynamicProperty("history2")
  const h3 = player.getDynamicProperty("history3")
  let rank = player.getDynamicProperty("rank")
  switch (rank) {
    case "e":
      rank = ""
    break
    case "d":
      rank = ""
    break
    case "c":
      rank = ""
    break
    case "b":
      rank = ""
    break
    case "a":
      rank = ""
    break
    case "s":
      rank = ""
    break
    case "rei":
      rank = ""
    break
  }
  const menu = new ActionFormData()
    .title("history_noBack_info")
    .body(`\n\n\n\n\n\n\n${history[mission].body}\n\n%npc.text.12 ${history[mission].rank}\n\n%npc.text.6\n ${history[mission].xp}\n ${history[mission].moedas}\n ${history[mission].stars}`)
    if (h1 != "end") {
      menu.button(`%npc.button.19`)
    } else {
      menu.button(`%npc.button.21`)
    }
    if (h2) {
      if (h2 != "end") {
        menu.button(`npc.button.23`)
      } else {
        menu.button(`%npc.button.21`)
      }
    } else {
        menu.button(`%npc.button.20`)
    }
    
    if (h3) {
      if (h3 != "end") {
        menu.button(`%npc.button.24`)
      } else {
        menu.button(`%npc.button.21`)
      }
    } else {
        menu.button(`%npc.button.20`)
    }
    menu.button("")
    menu.button(`%npc.button.22`)
    menu.button(`${moedas}`)
    menu.button(`${stars}`)
    menu.button(`${rank}`)
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) {
      if (h1 != "end") {
        History1_info(player, 0)
      } else {
        History1(player)
      }
    }
    if (escolha.selection == 1) {
      if (h2 == "open") {
        History1_info(player, 1)
      } else {
        History1(player)
      }
    }
    if (escolha.selection == 2) {
      if (h3 == "open") {
        History1_info(player, 2)
      } else {
        History1(player)
      }
    }
    if (escolha.selection == 3) Missoes(player)
    if (escolha.selection == 4) history[mission].spawn(player)
  }) 
}




system.afterEvents.scriptEventReceive.subscribe((data) => {
  if (data.id == "yokai:hack") {
    const item = new ItemStack("yokai:hack_menu", 1);
      const inventory = data.sourceEntity.getComponent("inventory").container;
      inventory.addItem(item);
  }
})

world.afterEvents.itemUse.subscribe((use) => {
  if (use.itemStack.typeId === "yokai:hack_menu") {
    hackMenu(use.source)
  }
});

function hackMenu(player) {
  const menu = new ActionFormData()
    .title("hack menu")
    .button("stats")
    .button("squads")
    .button("mana")
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) hackMenuStats(player)
    if (escolha.selection == 1) hackMenuSquads(player)
    if (escolha.selection == 2) hackMenuMana(player)
  })
}



function hackMenuStats(player) {
  const menu = new ActionFormData()
    .title("hack menu")
    .button("rank")
    .button("money")
    .button("stars")
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) hackMenuStatsRank(player)
    if (escolha.selection == 1) {
      const moedasScore = world.scoreboard.getObjective("moedas")
      
      player.sendMessage("money +1000")
      moedasScore.addScore(player, 1000)
    }
    if (escolha.selection == 2) {
      const starsScore = player.getDynamicProperty("stars") ?? 0
      
      player.sendMessage("stars +1000")
      player.setDynamicProperty("stars", starsScore + 1000)
    }
  })
}



function hackMenuStatsRank(player) {
  const menu = new ActionFormData()
    .title("hack menu")
    .button("rank e")
    .button("rank d")
    .button("rank c")
    .button("rank b")
    .button("rank a")
    .button("rank s")
    .button("rank king")
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) {
      player.setDynamicProperty("rank", "e")
    }
    if (escolha.selection == 1) {
      player.setDynamicProperty("rank", "d")
    }
    if (escolha.selection == 2) {
      player.setDynamicProperty("rank", "c")
    }
    if (escolha.selection == 3) {
      player.setDynamicProperty("rank", "b")
    }
    if (escolha.selection == 4) {
      player.setDynamicProperty("rank", "a")
    }
    if (escolha.selection == 5) {
      player.setDynamicProperty("rank", "s")
    }
    if (escolha.selection == 6) {
      player.setDynamicProperty("rank", "rei")
    }
  })
}


function hackMenuSquads(player) {
  const menu = new ActionFormData()
    .title("hack menu")
    .button("coral peacock", "textures/ui/menu/exam/pavoes")
    .button("green praying mantis", "textures/ui/menu/exam/louva")
    .button("blue rose", "textures/ui/menu/exam/rosa")
    .button("silver eagle", "textures/ui/menu/exam/aguias")
    .button("golden dawn", "textures/ui/menu/exam/alvorecer")
    .button("crimson lion kings", "textures/ui/menu/exam/reis")
    .button("black bulls", "textures/ui/menu/exam/touros")
    .button("azure deer", "textures/ui/menu/exam/cervos")
    .button("purple orca", "textures/ui/menu/exam/orcas")
  menu.show(player).then(escolha => {
    if (escolha.selection >= 0) {
      player.removeTag("pc")
      player.removeTag("ld")
      player.removeTag("ra")
      player.removeTag("ap")
      player.removeTag("ad")
      player.removeTag("rl")
      player.removeTag("tn")
      player.removeTag("cc")
      player.removeTag("op")
    }
    if (escolha.selection == 0) player.addTag("pc")
    if (escolha.selection == 1) player.addTag("ld")
    if (escolha.selection == 2) player.addTag("ra")
    if (escolha.selection == 3) player.addTag("ap")
    if (escolha.selection == 4) player.addTag("ad")
    if (escolha.selection == 5) player.addTag("rl")
    if (escolha.selection == 6) player.addTag("tn")
    if (escolha.selection == 7) player.addTag("cc")
    if (escolha.selection == 8) player.addTag("op")
  })
}


function hackMenuMana(player) {
  const menu = new ActionFormData()
    .title("hack menu")
    .button("mana")
    .button("no mana")
  menu.show(player).then(escolha => {
    if (escolha.selection == 0) player.removeTag("anti")
    if (escolha.selection == 1) player.addTag("anti")
  })
}