X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-cgt.git;a=blobdiff_plain;f=client.coffee;h=a87cb5404d6b074c0bb8dcb3cb20d9f1dddb3395;hp=61643b01c333f0490585e4683e62afb66099df00;hb=f46ce45eaf3db64e5d7bd9ea2c19ed3d4431c35a;hpb=4197e7b5a4746c9d04a96190707d7021e443aa42 diff --git a/client.coffee b/client.coffee index 61643b0..a87cb54 100644 --- a/client.coffee +++ b/client.coffee @@ -1,16 +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) -> - card = $ $ "