From 349583c86f05f027c2d92920549df2b22328d5c6 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Tue, 1 Nov 2011 16:23:04 -0400 Subject: [PATCH] draw deck starting to work --- client.coffee | 53 +++++++++++++++++++++++++++++++---------------------- server.coffee | 6 +++--- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/client.coffee b/client.coffee index 5a5341c..1e2c966 100644 --- a/client.coffee +++ b/client.coffee @@ -150,32 +150,41 @@ initialize_cards = () -> # build piles piles = [ - {key: 'p2_draw', x: transform_x(160), y: transform_y(20), name: "Draw Pile"} + {key: 'p2_draw', x: transform_x(140), y: transform_y(20), name: "Draw Pile"} {key: 'p2_discard', x: transform_x(20), y: transform_y(20), name: "Discard Pile"} - {key: 'p1_draw', x: transform_x(160), y: transform_y(flip_y(20)), name: "Draw Pile"} + {key: 'p1_draw', x: transform_x(140), y: transform_y(flip_y(20)), name: "Draw Pile"} {key: 'p1_discard', x: transform_x(20), y: transform_y(flip_y(20)), name: "Discard Pile"} ] for pile in piles - pile.$blank = new_blank_card pile.x, pile.y - count = 0 - top = null - if state.piles[pile.key]?.length - count = state.piles[pile.key].length - top = state.piles[pile.key][0] - $caption = $ $ "
#{pile.name}:
#{n_cards count}
" - pile.$caption = $caption - if top? - top.x = pile.x - top.y = pile.y - instantiate_card top - top = top.view - else - top = pile.$blank - - top.append $caption - - #pile.drag_handler = top.bind 'dragstart', -> - # FIXME + manage_pile = (pile) -> + pile.$blank = new_blank_card pile.x, pile.y + count = 0 + top = null + if state.piles[pile.key]?.length + count = state.piles[pile.key].length + top = state.piles[pile.key][0] + $caption = $ $ "
#{pile.name}:
#{n_cards count}
" + pile.$caption = $caption + if top? + top.x = pile.x + top.y = pile.y + instantiate_card top + view = top.view + else + view = pile.$blank + + view.append $caption + + if top? + pile.drag_handler = view.bind 'dragstart', -> + pile.$caption.remove() + delete top.pile + state.piles[pile.key].shift() + manage_pile pile + # FIXME make sure this state change is sent + # FIXME handle this message coming in + + manage_pile pile init = -> diff --git a/server.coffee b/server.coffee index 43e0bc6..3ba1034 100644 --- a/server.coffee +++ b/server.coffee @@ -191,9 +191,9 @@ test_init = -> { text: "Ent 0/5", x: 800, y: 200, owner: 'p2'} { text: "Carnivore 2/1", x: 220, y: 420, owner: 'p1'} { text: "Herbivore 1/2", x: 360, y: 420, owner: 'p1'} - { text: "Stone Wall 0/10", x: 500, y: 420, owner: 'p1'} - { text: "Log 0/1", x: 660, y: 420, owner: 'p1', pile: 'p1_draw'} - { text: "Ent 0/5", x: 800, y: 420, owner: 'p1'} + { text: "Stone Wall 0/10", x: 500, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true} + { text: "Log 0/1", x: 660, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true} + { text: "Ent 0/5", x: 800, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true} ] test_init() -- 1.7.10.4