tag @e[type=armor_stand,tag=block_receptor] add unhappy

#block receptors check if they've got the desired blocks on them
execute as @e[type=armor_stand,tag=block_receptor,tag=melon] at @s if block ~ ~ ~ melon run tag @s remove unhappy
execute as @e[type=armor_stand,tag=block_receptor,tag=melon] at @s if block ~ ~ ~ polished_blackstone_wall run tag @s remove unhappy
execute as @e[type=armor_stand,tag=block_receptor,tag=melon] at @s if block ~ ~ ~ polished_blackstone_brick_wall run tag @s remove unhappy
execute as @e[type=armor_stand,tag=block_receptor,tag=pumpkin] at @s if block ~ ~ ~ pumpkin run tag @s remove unhappy
execute as @e[type=armor_stand,tag=block_receptor,tag=barrel] at @s if block ~ ~ ~ barrel run tag @s remove unhappy
execute as @e[type=armor_stand,tag=block_receptor,tag=ice] at @s if block ~ ~ ~ ice run tag @s remove unhappy
execute as @e[type=armor_stand,tag=block_receptor,tag=slime_block] at @s if block ~ ~ ~ slime_block run tag @s remove unhappy

#block receptors turn green when happy
execute as @e[type=armor_stand,tag=block_receptor,tag=!unhappy] at @s run team join glow_yellow @e[limit=1,sort=nearest,type=furnace_minecart,tag=block_indicator]
execute as @e[type=armor_stand,tag=block_receptor,tag=unhappy] at @s run team leave @e[limit=1,sort=nearest,type=furnace_minecart,tag=block_indicator]

#set victoryState based on whether an unhappy block receptor exists
execute if score global victoryState matches 0 unless score global hitCone matches 1 unless entity @e[type=armor_stand,tag=block_receptor,tag=unhappy,limit=1] run function bd:game/victory_on
execute if score global victoryState matches 1 if entity @e[type=armor_stand,tag=block_receptor,tag=unhappy,limit=1] run function bd:game/victory_off
execute if score global victoryState matches 1 if score global hitCone matches 1 run function bd:game/victory_off