#say @n[tag=clicked] grabbed @s

execute if entity @n[tag=clicked,tag=has_flag] as @n[tag=clicked,tag=has_flag] run return run function pctf:logic/game/flag/already_has_flag

execute if entity @s[tag=red_interaction,tag=!dropped] if entity @n[tag=clicked,team=red] as @n[tag=clicked,team=red] at @s run return run function pctf:logic/game/flag/own_flag
execute if entity @s[tag=blue_interaction,tag=!dropped] if entity @n[tag=clicked,team=blue] as @n[tag=clicked,team=blue] at @s run return run function pctf:logic/game/flag/own_flag

execute if entity @s[tag=red_interaction,tag=dropped] if entity @n[tag=clicked,team=red] as @n[type=block_display,tag=flag] run return run function pctf:logic/game/flag/return
execute if entity @s[tag=blue_interaction,tag=dropped] if entity @n[tag=clicked,team=blue] as @n[type=block_display,tag=flag] run return run function pctf:logic/game/flag/return

execute if entity @s[tag=red_interaction] if entity @n[tag=clicked,team=blue] if entity @s[tag=light_purple_interaction] as @n[tag=clicked,team=blue] at @s run function pctf:logic/game/flag/get_light_purple
execute if entity @s[tag=red_interaction] if entity @n[tag=clicked,team=blue] if entity @s[tag=yellow_interaction] as @n[tag=clicked,team=blue] at @s run function pctf:logic/game/flag/get_yellow

execute if entity @s[tag=blue_interaction] if entity @n[tag=clicked,team=red] if entity @s[tag=aqua_interaction] as @n[tag=clicked,team=red] at @s run function pctf:logic/game/flag/get_aqua
execute if entity @s[tag=blue_interaction] if entity @n[tag=clicked,team=red] if entity @s[tag=green_interaction] as @n[tag=clicked,team=red] at @s run function pctf:logic/game/flag/get_green

execute as @n[tag=clicked] run function pctf:logic/game/flag/rewards