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

#End
execute if score timer time matches 0 run function f:game/end/start

#Win effects
execute if score timer time matches 0 as @a[scores={wineffect_select=1},tag=win] at @s run function f:game/end/win/effect1
execute if score timer time matches 0 as @a[scores={wineffect_select=3},tag=win] at @s run function f:game/end/win/effect3_spawn
execute if score timer time matches 0 as @a[scores={wineffect_select=4},tag=win] at @s run function f:game/end/win/effect4_spawn
execute if score timer time matches -9..0 as @a[scores={wineffect_select=5},tag=win] at @s run function f:game/end/win/effect5
execute if score timer time matches 0 as @a[scores={wineffect_select=6},tag=win] at @s run function f:game/end/win/effect6
execute if score timer time matches -9..0 as @a[scores={wineffect_select=7},tag=win] at @s run function f:game/end/win/effect7

#Other
execute if score timer time matches -9..0 run function f:game/end/fw
execute if score timer time matches -4..0 as @a[x=24,y=247,z=84,distance=..10] run function f:spec
execute if score timer time matches -4..0 run tp @a[x=24,y=247,z=84,distance=..10] ~ 150 ~

#Stats/database
execute if score timer time matches -10 run scoreboard players add @a[tag=win] wins 1
execute if score timer time matches -10 run team join lobby @a
execute if score timer time matches -10 run function f:lobby/load
execute if score timer time matches -10 run function f:data/main

execute if score timer time matches -10 run function f:reset

#execute if score timer time matches -9 run scoreboard players set timer time -1