#add event to table
event entity @s interact_succeed:go_to_table

#remove player draw tag
tag @a[tag=drawing] remove drawing



#add color tag
tag @s[tag=red_wild] add red
tag @s[tag=blue_wild] add blue
tag @s[tag=green_wild] add green
tag @s[tag=yellow_wild] add yellow


tag @s[tag=red_plus4] add red
tag @s[tag=blue_plus4] add blue
tag @s[tag=green_plus4] add green
tag @s[tag=yellow_plus4] add yellow



#teleport
tag @s add tempinteract
execute @e[tag=dummy,scores={turn=1}] ~ ~ ~ function card_interact/table_offset_p1
execute @e[tag=dummy,scores={turn=2}] ~ ~ ~ function card_interact/table_offset_p2
execute @e[tag=dummy,scores={turn=3}] ~ ~ ~ function card_interact/table_offset_p3
execute @e[tag=dummy,scores={turn=4}] ~ ~ ~ function card_interact/table_offset_p4
tag @s remove tempinteract



#add tag
tag @s add table
tag @s remove player1
tag @s remove player2
tag @s remove player3
tag @s remove player4




#remove chosing cards that weren't selected
tag @e[tag=red_wild,tag=!table] add discardme
tag @e[tag=blue_wild,tag=!table] add discardme
tag @e[tag=green_wild,tag=!table] add discardme
tag @e[tag=yellow_wild,tag=!table] add discardme
tag @e[tag=red_plus4,tag=!table] add discardme
tag @e[tag=blue_plus4,tag=!table] add discardme
tag @e[tag=green_plus4,tag=!table] add discardme
tag @e[tag=yellow_plus4,tag=!table] add discardme
tag @e[tag=choosecolor] add discardme

event entity @e[tag=discardme] dummy_invisible
tp @e[tag=discardme] 40 -1000 -40
kill @e[tag=discardme]




#next turn
execute @s[tag=red_wild] ~ ~ ~ function nextturn/normal
execute @s[tag=blue_wild] ~ ~ ~ function nextturn/normal
execute @s[tag=green_wild] ~ ~ ~ function nextturn/normal
execute @s[tag=yellow_wild] ~ ~ ~ function nextturn/normal

execute @s[tag=red_plus4] ~ ~ ~ execute @e[tag=dummy,scores={drawstacking=0}] ~ ~ ~ function nextturn/draw_classic
execute @s[tag=blue_plus4] ~ ~ ~ execute @e[tag=dummy,scores={drawstacking=0}] ~ ~ ~ function nextturn/draw_classic
execute @s[tag=green_plus4] ~ ~ ~ execute @e[tag=dummy,scores={drawstacking=0}] ~ ~ ~ function nextturn/draw_classic
execute @s[tag=yellow_plus4] ~ ~ ~ execute @e[tag=dummy,scores={drawstacking=0}] ~ ~ ~ function nextturn/draw_classic

execute @s[tag=red_plus4] ~ ~ ~ execute @e[tag=dummy,scores={drawstacking=1}] ~ ~ ~ function nextturn/draw_stacking
execute @s[tag=blue_plus4] ~ ~ ~ execute @e[tag=dummy,scores={drawstacking=1}] ~ ~ ~ function nextturn/draw_stacking
execute @s[tag=green_plus4] ~ ~ ~ execute @e[tag=dummy,scores={drawstacking=1}] ~ ~ ~ function nextturn/draw_stacking
execute @s[tag=yellow_plus4] ~ ~ ~ execute @e[tag=dummy,scores={drawstacking=1}] ~ ~ ~ function nextturn/draw_stacking
