X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=server.coffee;h=c7d71b4a1ca6cf75054de9dd1b5088de1b3de8ff;hb=4eb019697492c1f826548e05f0811cbef887a8ad;hp=ab0ca9f06fef926624c4b29c34fea7586c4c94e9;hpb=4ae9f3f4c527c3565fa7e82c114f025053927df3;p=peach-cgt.git diff --git a/server.coffee b/server.coffee index ab0ca9f..c7d71b4 100644 --- a/server.coffee +++ b/server.coffee @@ -169,20 +169,33 @@ new_game = (id) -> forward_events.call this, 'mark', agent, card, state game.on 'flip', (agent, card, state) -> forward_events.call this, 'flip', agent, card, state - game.on 'set_cards', (cards) -> - forward_events.call this, 'set_cards', 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 return game test_init = -> test_game = new_game 'test' timeout 4000, -> - test_game.set_cards [ - { text: "Wildabeast 2/2", x: 20, y: 140} - { text: "Wild beast 2/2", x: 150, y: 140} - { text: "Angora bunny 1/1", x: 300, y: 140} - { text: "Ambulatory Cactus 2/1", x: 450, y: 140} - { text: "Ent 0/5", x: 600, y: 140} + test_game.set_cards 'server', [ + { text: "Wildabeast 2/2", x: 220, y: 200} + { text: "Wild beast 2/2", x: 350, y: 200} + { text: "Angora bunny 1/1", x: 500, y: 200} + { text: "Ambulatory Cactus 2/1", x: 650, y: 200} + { text: "Ent 0/5", x: 800, y: 200} + { text: "Carnivore 2/1", x: 220, y: 420} + { text: "Herbivore 1/2", x: 350, y: 420} + { text: "Stone Wall 0/10", x: 500, y: 420} + { text: "Log 0/1", x: 650, y: 420} + { text: "Ent 0/5", x: 800, y: 420} ] test_init()