X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.coffee;h=205d4ccf2fa49286034379a346f31fbccc3b7b25;hb=79d3e474a96013531cce2d8e2d6890aee11cfad9;hp=8c1abd0c8c1b297683ec51c4f3612a2088b9513c;hpb=3a8a99fd78775bdd7f71470443858e19b09dc2ed;p=peach-cgt.git diff --git a/client.coffee b/client.coffee index 8c1abd0..205d4cc 100644 --- a/client.coffee +++ b/client.coffee @@ -1,14 +1,55 @@ $table = null +state = { + card_types: [ + {text: "Rusty Camel"} + {text: "Angry Ocelot"} + {text: "Unruly Parsnip"} + ], + # values are indexes into card_types array + my_cards: [0, 0, 0, 1, 1, 2], + your_cards: [0, 1, 1, 2, 2, 2], + auto_shuffle: true +} + +unless Array::shuffle? + Array::shuffle = -> + return if @length is 0 + top = @length + + while --top + current = Math.floor(Math.random() * (top + 1)) + tmp = @[current] + @[current] = @[top] + @[top] = tmp + return + add_card = (text, x, y) -> - $table.append $ "