7 {text: "Unruly Parsnip"}
9 # values are indexes into card_types array
10 my_cards: [0, 0, 0, 1, 1, 2],
11 your_cards: [0, 1, 1, 2, 2, 2],
15 unless Array::shuffle?
17 return if @length is 0
21 current = Math.floor(Math.random() * (top + 1))
27 new_button = (text) -> $ $ "<div class=\"button\">#{text}</div>"
29 add_card = (text, x, y) ->
30 card = $ $ "<div class=\"card\" style=\"left: #{x}px; top: #{y}px\"><span class=\"cardtext\">#{text}</span></div>"
31 button_box = $ $ '<div/>'
32 flip_button = new_button "flip over"
33 mark_button = new_button "mark"
34 flip_button.bind 'click', ->
35 card.toggleClass 'flipped'
37 mark_button.bind 'click', ->
38 card.toggleClass 'marked'
40 button_box.append flip_button
41 button_box.append mark_button
42 card.append button_box
44 card.draggable stack: '.card'
45 card.bind 'dragstop', (event, ui) ->
47 #card.children().html("(#{p.left}, #{p.top})")
51 state.my_cards.shuffle()
52 state.your_cards.shuffle() # FIXME have the server or other player do this
53 state.auto_shuffle = false
56 for card in state.my_cards
57 add_card state.card_types[card].text, left, top
61 for card in state.your_cards
62 add_card state.card_types[card].text, left, top