JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
clients ask/get initial state on [re]load
[peach-cgt.git] / server.coffee
index 29cddb1..7e191d8 100644 (file)
@@ -171,6 +171,14 @@ new_game = (id) ->
                forward_events.call this, 'flip', agent, card, state
        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
 
        return game