#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
#
#    This function has been created by Skilendarz Group.
#             https://skilendarz.com
#
#      GIVE MAP MAKERS THE CREDIT THEY DESERVE!
#             COPYING IS PROHIBITED!
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#Select game type
kill @e[tag=game_type_marker]
execute if entity @s[tag=classic] run scoreboard players set $game_type main 0
execute if entity @s[tag=ctp] run scoreboard players set $game_type main 1
execute if entity @s[tag=deathmatch] run scoreboard players set $game_type main 2
execute if entity @s[tag=hide_and_seek] run scoreboard players set $game_type main 3

#Rotation
execute unless entity @s[tag=selected_game_type] run function f:lobby/options/game_type/cauldron
execute unless entity @s[tag=selected_game_type] run scoreboard players set @s time 32
execute unless entity @s[tag=selected_game_type] run scoreboard players set @e[tag=option_game_type,scores={time=0},limit=1,sort=random] time 27
execute unless entity @s[tag=selected_game_type] run scoreboard players set @e[tag=option_game_type,scores={time=0},limit=1,sort=random] time 20
execute unless entity @s[tag=selected_game_type] run scoreboard players set @e[tag=option_game_type,scores={time=0},limit=1,sort=random] time 17

execute unless entity @s[tag=selected_game_type] run scoreboard players set @e[tag=option_game_type_pole] time 17
execute unless entity @s[tag=selected_game_type] run scoreboard players set $game_type time 35

#Info
execute if entity @s[tag=selected_game_type,tag=classic] run tellraw @a[scores={vill=1..},tag=info_classic] ["\n",{"text":" > ","color":"gold"},{"translate":"gamemode.classic","bold":true,"color":"green"},"\n",{"translate":"gamemode.classic.desc","color":"gray"},"\n"]
execute if entity @s[tag=selected_game_type,tag=ctp] run tellraw @a[scores={vill=1..},tag=info_ctp] ["\n",{"text":" > ","color":"gold"},{"translate":"gamemode.ctp","bold":true,"color":"green"},"\n",{"translate":"gamemode.ctp.desc","color":"gray"},"\n"]
execute if entity @s[tag=selected_game_type,tag=deathmatch] run tellraw @a[scores={vill=1..},tag=info_deathmatch] ["\n",{"text":" > ","color":"gold"},{"translate":"gamemode.deathmatch","bold":true,"color":"green"},"\n",{"translate":"gamemode.deathmatch.desc","color":"gray"},"\n"]
execute if entity @s[tag=selected_game_type,tag=hide_and_seek] run tellraw @a[scores={vill=1..},tag=info_hide_and_seek] ["\n",{"text":" > ","color":"gold"},{"translate":"gamemode.hide_and_seek","bold":true,"color":"green"},"\n",{"translate":"gamemode.hide_and_seek.desc","color":"gray"},"\n"]

execute if entity @s[tag=classic] run tellraw @a[scores={vill=1..},tag=!info_classic] ["\n",{"text":" > ","color":"gold"},{"translate":"gamemode.classic","bold":true,"color":"green"},"\n",{"translate":"gamemode.classic.desc","color":"gray"},"\n"]
execute if entity @s[tag=ctp] run tellraw @a[scores={vill=1..},tag=!info_ctp] ["\n",{"text":" > ","color":"gold"},{"translate":"gamemode.ctp","bold":true,"color":"green"},"\n",{"translate":"gamemode.ctp.desc","color":"gray"},"\n"]
execute if entity @s[tag=deathmatch] run tellraw @a[scores={vill=1..},tag=!info_deathmatch] ["\n",{"text":" > ","color":"gold"},{"translate":"gamemode.deathmatch","bold":true,"color":"green"},"\n",{"translate":"gamemode.deathmatch.desc","color":"gray"},"\n"]
execute if entity @s[tag=hide_and_seek] run tellraw @a[scores={vill=1..},tag=!info_hide_and_seek] ["\n",{"text":" > ","color":"gold"},{"translate":"gamemode.hide_and_seek","bold":true,"color":"green"},"\n",{"translate":"gamemode.hide_and_seek.desc","color":"gray"},"\n"]

execute if entity @s[tag=classic] run tag @a[scores={vill=1..}] add info_classic
execute if entity @s[tag=ctp] run tag @a[scores={vill=1..}] add info_ctp
execute if entity @s[tag=deathmatch] run tag @a[scores={vill=1..}] add info_deathmatch
execute if entity @s[tag=hide_and_seek] run tag @a[scores={vill=1..}] add info_hide_and_seek

tag @e[tag=selected_game_type] remove selected_game_type
tag @s add selected_game_type

playsound minecraft:entity.player.attack.knockback master @a ~ ~ ~ 1 2
