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

tag @s remove blue_base
tag @s remove red_base
tag @s remove green_base
tag @s remove yellow_base
tag @s remove in_base
tag @s remove stealing
xp set @s 0 points
execute if block ~ 140 ~ end_stone_bricks run tag @s add blue_base
execute if block ~ 140 ~ purpur_pillar run tag @s add red_base
execute if block ~ 140 ~ purpur_block run tag @s add green_base
execute if block ~ 140 ~ end_stone run tag @s add yellow_base
execute if entity @p[team=blue] if block ~ 140 ~ end_stone_bricks run tag @s add in_base
execute if entity @p[team=red] if block ~ 140 ~ purpur_pillar run tag @s add in_base
execute if entity @p[team=green] if block ~ 140 ~ purpur_block run tag @s add in_base
execute if entity @p[team=yellow] if block ~ 140 ~ end_stone run tag @s add in_base

#Deposit
execute if entity @s[team=blue,tag=blue_base,scores={pumpkin_count=1..}] run function f:game/score/blue_base
execute if entity @s[team=red,tag=red_base,scores={pumpkin_count=1..}] run function f:game/score/red_base
execute if entity @s[team=green,tag=green_base,scores={pumpkin_count=1..}] run function f:game/score/green_base
execute if entity @s[team=yellow,tag=yellow_base,scores={pumpkin_count=1..}] run function f:game/score/yellow_base

#Stealing
execute if score $team_blue pumpkin_count matches 1.. run tag @s[team=!blue,tag=blue_base] add stealing
execute if score $team_red pumpkin_count matches 1.. run tag @s[team=!red,tag=red_base] add stealing
execute if score $team_green pumpkin_count matches 1.. run tag @s[team=!green,tag=green_base] add stealing
execute if score $team_yellow pumpkin_count matches 1.. run tag @s[team=!yellow,tag=yellow_base] add stealing

scoreboard players set @s[tag=!stealing] stealing 0
xp set @s[tag=!stealing] 0 points
execute if entity @s[tag=stealing] run function f:game/stealing