- game.on 'set_cards', (cards) ->
- forward_events.call this, 'set_cards', cards
+ game.on 'new_cards', (agent, cards) ->
+ # server assigns card numbers, and tells both clients
+ # (unlike all other api calls, sending agent expects to get this one back)
+ forward_events.call this, 'new_cards', 'server', cards
+ game.on 'set_cards', (agent, cards) ->
+ forward_events.call this, 'set_cards', agent, cards
+ game.on 'send_state', (agent) ->
+ timeout 10, =>
+ if agent is 'p1'
+ @p1_queue.push ['set_cards', 'server', @cards]
+ answer_soon this
+ if agent is 'p2'
+ @p2_queue.push ['set_cards', 'server', @cards]
+ answer_soon this