X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-cgt.git;a=blobdiff_plain;f=client.coffee;h=1e2c966322042676284e6d8c8f0d2c253d1e01dd;hp=5a5341cfc79d1d4fc87d09e290a9f22dec6ddfbe;hb=349583c86f05f027c2d92920549df2b22328d5c6;hpb=5e5f70bb208fb1f8a7e774ed5a172e78660be639 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 = ->