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

#Clear
clear @a
function f:game/armor
xp set @a 0 levels
kill @e[tag=player_indicator]
kill @e[tag=gold_cooldown]

#Scores
scoreboard players set @a pumpkin_count 0
scoreboard players set @a gold 0
scoreboard players set @a cooldown -1
scoreboard players set @a poweruptime 0
scoreboard players set @a milk_time 0

#Pumpkin
effect give @e[tag=pumpkin] glowing 3 10 true
team join pumpkin @e[tag=pumpkin]
scoreboard players add @e[tag=pumpkin] time 1

#Minigun
scoreboard players set @e[tag=minigun_base] time 239
stopsound @a * minecraft:sound.minigun

#Trap
tag @e remove active_trap
execute as @e[tag=alarm] run data merge entity @s {VillagerData:{level:1,profession:"minecraft:cleric",type:"minecraft:dessert"},CustomName:'[{"text":"5","bold":true,"color":"gold"},{"translate":"game.gold_icon","color":"white","bold":false}]'}

#Win
title @a times 10 70 10
title @a title {"translate":"game.end","color":"green","bold":true}
execute if score $game_type main matches 0..2 run function f:game/end/win/win
execute if score $game_type main matches 3 run function f:game/end/win/hide_and_seek

#Bossbar
bossbar set minecraft:powerup1 players
bossbar set minecraft:powerup2 players
bossbar set minecraft:powerup3 players
bossbar set minecraft:powerup4 players

#Effects
execute as @a at @s run playsound minecraft:entity.ender_dragon.growl master @s ~ ~ ~ 300
execute as @a at @s run playsound minecraft:ui.toast.challenge_complete master @s ~ ~ ~ 300 0.5
execute as @a at @s run playsound minecraft:entity.wither.death master @s ~ ~ ~ 300 1.3
effect give @a minecraft:speed 999999 3 true
effect give @a minecraft:jump_boost 999999 1 true
effect give @a minecraft:night_vision 999999 1 true
effect give @a[team=!spec] minecraft:nausea 4 1 true
effect give @a minecraft:blindness 1 1 true