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

#Score
execute if score @s time matches 100 if score @s main matches 2 run scoreboard players remove option_kills pumpkins 1
execute if score @s time matches 101 if score @s main matches 2 run scoreboard players add option_kills pumpkins 1
execute if score @s time matches 100 if score @s main matches 1 run scoreboard players remove option_pumpkin pumpkins 1
execute if score @s time matches 101 if score @s main matches 1 run scoreboard players add option_pumpkin pumpkins 1
execute if score @s time matches 100 if score @s main matches 0 run scoreboard players remove option_time pumpkins 1
execute if score @s time matches 101 if score @s main matches 0 run scoreboard players add option_time pumpkins 1

execute if score @s time matches 100.. run scoreboard players set @s time 58
execute if score @s time matches 1.. run scoreboard players remove @s time 1

#Animation
execute if score @s time matches 57 run clear @a minecraft:birch_planks
execute if score @s[tag=!empty] time matches 57 run playsound minecraft:block.wood.break master @a ~-0.6 ~0.91 ~ 1 0.7
execute if score @s[tag=!empty] time matches 57 run particle minecraft:block oak_planks ~-0.6 ~0.91 ~ 0 0.05 0.1 0 40
execute if score @s time matches 57 run item replace entity @e[tag=option_interract,limit=3,sort=nearest,distance=..1] armor.head with air

execute if score @s time matches 57 as @e[tag=option_selected,sort=nearest,limit=1,distance=..1.5] at @s run tp @s ~ 106.5 ~
execute if score @s time matches 57 run scoreboard players set @e[tag=option_selected,sort=nearest,limit=1,distance=..1.5] kills 0
execute if score @s[tag=!empty] time matches 53 run playsound minecraft:ambient.underwater.enter master @a[distance=..6] ~ ~0.91 ~ 1 2
execute if score @s time matches 50 run kill @e[tag=option_selected,sort=nearest,limit=1,distance=..1.5]
execute if score @s time matches 50 run kill @e[tag=option_selected_time,sort=nearest,limit=1,distance=..1.5]

execute if score @s time matches 50 if score @s main matches -1 run tag @s add empty
execute if score @s time matches 50 if score @s main matches 0.. run tag @s remove empty
execute if score @s time matches 50 if score @s main matches -1 run scoreboard players set @s time 20

execute if score @s[tag=!empty] time matches 55 run playsound minecraft:block.bubble_column.upwards_ambient master @a ~ ~0.71 ~
execute if score @s[tag=!empty] time matches 44..55 run particle entity_effect ~ ~1 ~ 0 1 0 0.5 0
execute if score @s time matches 54..55 if score @s main matches 0.. run tp @s ~ ~ ~ ~ ~2.5
execute if score @s time matches 50..53 if score @s main matches 0.. run tp @s ~ ~ ~ ~ ~-2.5
execute if score @s time matches 46..49 if score @s main matches 0.. run tp @s ~ ~ ~ ~ ~2.5
execute if score @s time matches 44..45 if score @s main matches 0.. run tp @s ~ ~ ~ ~ ~-2.5

execute if score @s time matches 41 run particle minecraft:smoke ~ ~1 ~ 0 0 0 0.15 100
execute if score @s time matches 41 run playsound minecraft:block.lava.extinguish master @a ~ ~1 ~
execute if score @s time matches 41 run playsound minecraft:ambient.underwater.exit master @a[distance=..6] ~ ~1 ~ 1 2

#Summon option
execute if score @s time matches 44 if score @s main matches 1..2 run summon minecraft:armor_stand ~ ~-0.19 ~ {Tags:["option_selected","option_new","option"],Invisible:1,NoGravity:1,Small:1,ArmorItems:[{},{},{},{id:"minecraft:red_wool",Count:1}]}
execute if score @s time matches 44 if score @s main matches 0 run summon minecraft:armor_stand ~ ~-0.19 ~ {Tags:["option_selected","option_new","option"],Invisible:1,NoGravity:1,Small:1,Marker:1,ArmorItems:[{},{},{},{id:"minecraft:red_wool",Count:1}],Passengers:[{id:"armor_stand",Marker:1,Invisible:1,ArmorItems:[{},{},{},{id:"minecraft:cyan_stained_glass",Count:1b}],Small:1,Tags:["option_selected_time","option"]}]}

execute if score @s time matches 44 if score @s main matches 2 as @e[tag=option_new] run function f:lobby/options/kills/kills
execute if score @s time matches 44 if score @s main matches 1 as @e[tag=option_new] run function f:lobby/options/pumpkin/pumpkin
execute if score @s time matches 44 if score @s main matches 0 as @e[tag=option_new] run function f:lobby/options/time/time

#Update sign
execute if score @s time matches 20 if score @s main matches 2 as @e[tag=option_value,limit=1,sort=nearest,distance=..1] run function f:lobby/options/kills/sign
execute if score @s time matches 20 if score @s main matches 1 as @e[tag=option_value,limit=1,sort=nearest,distance=..1] run function f:lobby/options/pumpkin/sign
execute if score @s time matches 20 if score @s main matches 0 as @e[tag=option_value,limit=1,sort=nearest,distance=..1] run function f:lobby/options/time/sign

execute if score @s time matches 21 run playsound minecraft:block.wood.place master @a ~-0.6 ~0.91 ~ 1 0.7
execute if score @s time matches 20 run item replace entity @e[tag=option_change,limit=2,sort=nearest,distance=..1] armor.head with minecraft:birch_planks{display:{Name:'{"text":""}'}}