X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.coffee;h=da53a242f18e05db60f8542ba3987893a0d0431f;hb=e39c3d01d9c40b425168f1f8dcb2d9ddef975808;hp=5a5341cfc79d1d4fc87d09e290a9f22dec6ddfbe;hpb=5e5f70bb208fb1f8a7e774ed5a172e78660be639;p=peach-cgt.git diff --git a/client.coffee b/client.coffee index 5a5341c..da53a24 100644 --- a/client.coffee +++ b/client.coffee @@ -61,6 +61,7 @@ instantiate_card = (card) -> card.z = next_card_z() view = $ $ "
#{text}
" + view.data card.number button_box = $ $ '
' flip_button = new_button "flip over" mark_button = new_button "mark" @@ -150,32 +151,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 = ->