#Set status to ending
scoreboard players set gameStatus gameInfoValues 3


#Fireworks
function subchronos:game/end/firework

#Resistance
effect give @a resistance infinite 255 true

#Title
title @a times 40 90 40
title @a clear
execute unless score playersAlive gameInfoValues matches 0 run title @a subtitle {"color":"#FFCA38","italic":false,"fallback":"Has won the game!","translate":"subchronos.game.has_won"}
execute if score playersAlive gameInfoValues matches 0 run title @a title {"color":"#FFCA38","italic":false,"translate":"subchronos.game.draw","fallback":"Draw!"}
#SOLO
    execute if score playersAlive gameInfoValues matches 1 unless score teams gameInfoValues matches 1.. run title @a title {"color":"#FFCA38","italic":false,"selector":"@a[tag=!spectating]"}
#TEAMS
    execute unless score playersAlive gameInfoValues matches 0 if score teams gameInfoValues matches 1.. if entity @a[tag=!spectating,team=t1] run title @a title {"color":"#FFCA38","italic":false,"fallback":"Team 1","translate":"subchronos.game.team1.title"}
    execute unless score playersAlive gameInfoValues matches 0 if score teams gameInfoValues matches 1.. if entity @a[tag=!spectating,team=t2] run title @a title {"color":"#FFCA38","italic":false,"fallback":"Team 2","translate":"subchronos.game.team2.title"}
    execute unless score playersAlive gameInfoValues matches 0 if score teams gameInfoValues matches 1.. if entity @a[tag=!spectating,team=t3] run title @a title {"color":"#FFCA38","italic":false,"fallback":"Team 3","translate":"subchronos.game.team3.title"}
    execute unless score playersAlive gameInfoValues matches 0 if score teams gameInfoValues matches 1.. if entity @a[tag=!spectating,team=t4] run title @a title {"color":"#FFCA38","italic":false,"fallback":"Team 4","translate":"subchronos.game.team4.title"}

gamerule keep_inventory true

#Game id
scoreboard players reset game gameID

#STAT
scoreboard players add @a[tag=!spectating] statsWins 1

#reset 10s
schedule function subchronos:game/end/fade 9s
schedule function subchronos:game/end/reset 10s