#turn tag
tag * remove turn
execute @e[tag=dummy,scores={turn=1}] ~ ~ ~ tag @a[scores={player_id=1}] add turn
execute @e[tag=dummy,scores={turn=2}] ~ ~ ~ tag @a[scores={player_id=2}] add turn
execute @e[tag=dummy,scores={turn=3}] ~ ~ ~ tag @a[scores={player_id=3}] add turn
execute @e[tag=dummy,scores={turn=4}] ~ ~ ~ tag @a[scores={player_id=4}] add turn



#tp draw button
execute @e[tag=button] ~ ~ ~ tp @s ~ 24 ~
execute @e[tag=dummy,scores={turn=1}] ~ ~ ~ execute @e[tag=p1_drawbutton] ~ ~ ~ tp @s ~ 28 ~
execute @e[tag=dummy,scores={turn=2}] ~ ~ ~ execute @e[tag=p2_drawbutton] ~ ~ ~ tp @s ~ 28 ~
execute @e[tag=dummy,scores={turn=3}] ~ ~ ~ execute @e[tag=p3_drawbutton] ~ ~ ~ tp @s ~ 28 ~
execute @e[tag=dummy,scores={turn=4}] ~ ~ ~ execute @e[tag=p4_drawbutton] ~ ~ ~ tp @s ~ 28 ~


#event
execute @e[tag=dummy,scores={turn=1}] ~ ~ ~ event entity @e[tag=p1_drawbutton] clickable_draw
execute @e[tag=dummy,scores={turn=2}] ~ ~ ~ event entity @e[tag=p2_drawbutton] clickable_draw
execute @e[tag=dummy,scores={turn=3}] ~ ~ ~ event entity @e[tag=p3_drawbutton] clickable_draw
execute @e[tag=dummy,scores={turn=4}] ~ ~ ~ event entity @e[tag=p4_drawbutton] clickable_draw



#notification sound
execute @a[tag=turn] ~ ~ ~ playsound note.chime @s



#give hastodraw score
execute @e[tag=tempinteract,tag=plus2] ~ ~ ~ scoreboard players add @e[tag=dummy] hastodraw 2
execute @e[tag=tempinteract,tag=plus4] ~ ~ ~ scoreboard players add @e[tag=dummy] hastodraw 4
execute @e[scores={tableorder=0},tag=red_plus4] ~ ~ ~ scoreboard players add @e[tag=dummy] hastodraw 4
execute @e[scores={tableorder=0},tag=blue_plus4] ~ ~ ~ scoreboard players add @e[tag=dummy] hastodraw 4
execute @e[scores={tableorder=0},tag=green_plus4] ~ ~ ~ scoreboard players add @e[tag=dummy] hastodraw 4
execute @e[scores={tableorder=0},tag=yellow_plus4] ~ ~ ~ scoreboard players add @e[tag=dummy] hastodraw 4




#announce turn has to draw
tellraw @a {"rawtext": [{"text": "§c"},{"selector": "@a[tag=turn]"},{"text": " has to draw "},{"score":{"name":"@e[tag=dummy]","objective":"hastodraw"}},{"text": " cards or play a draw card!"}]}





#make cards unclickable except draw cards
event entity @e[type=cero:card] stop_clickable
execute @e[tag=dummy,scores={turn=1}] ~ ~ ~ execute @e[type=cero:card,tag=player1] ~ ~ ~ function card_clickable
execute @e[tag=dummy,scores={turn=2}] ~ ~ ~ execute @e[type=cero:card,tag=player2] ~ ~ ~ function card_clickable
execute @e[tag=dummy,scores={turn=3}] ~ ~ ~ execute @e[type=cero:card,tag=player3] ~ ~ ~ function card_clickable
execute @e[tag=dummy,scores={turn=4}] ~ ~ ~ execute @e[type=cero:card,tag=player4] ~ ~ ~ function card_clickable