JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
start on deck designer
[peach-cgt.git] / server.coffee
index 80ad9c3..498e391 100644 (file)
@@ -23,11 +23,17 @@ css_handler = (args, out, request, url_parts) ->
                        out.end css
 
 js_handler = (args, out, request, url_parts) ->
+       convert = false
        basename = url_parts.pathname.substr 1, (url_parts.pathname.length - 4)
        if basename is 'client'
                filename = 'client.coffee'
+               convert = true
        else if basename is 'common'
                filename = 'common.coffee'
+               convert = true
+       else if basename is 'cs_cards'
+               filename = 'cs_cards.js'
+               convert = false
        else
                error = "Unknown js basename: #{basename}"
                console.log error
@@ -37,7 +43,10 @@ js_handler = (args, out, request, url_parts) ->
        fs.readFile filename, 'utf8', (err, data) ->
                if err
                        return out.end "Server failed to read #{filename}"
-               out.end coffee.compile data
+               if convert
+                       out.end coffee.compile data
+               else
+                       out.end data
 
 html_handler = (args, out, request, url_parts) ->
        fs.readFile 'index.html', 'utf8', (err, data) ->
@@ -161,8 +170,8 @@ new_game = (id) ->
        game.p1_queue = []
        game.p2_queue = []
 
-       game.on 'move', (agent, card, x, y, z) ->
-               forward_events.call this, 'move', agent, card, x, y, z
+       game.on 'move', (agent, card, x, y, z, pile) ->
+               forward_events.call this, 'move', agent, card, x, y, z, pile
        game.on 'mark', (agent, card, state) ->
                forward_events.call this, 'mark', agent, card, state
        game.on 'flip', (agent, card, state) ->
@@ -182,18 +191,21 @@ new_game = (id) ->
 
 test_init = ->
        test_game = new_game 'test'
-       timeout 4000, ->
+       timeout 2, ->
                test_game.set_cards 'server', [
                        { text: "Wildabeast 2/2", x: 220, y: 200, owner: 'p2'}
-                       { text: "Wild beast 2/2", x: 360, y: 200, owner: 'p2'}
+                       { text: "Boar 2/2", x: 360, y: 200, owner: 'p2', pile: 'p2_discard'}
                        { text: "Angora bunny 1/1", x: 500, y: 200, owner: 'p2'}
                        { text: "Ambulatory Cactus 2/1", x: 660, y: 200, owner: 'p2'}
                        { text: "Ent 0/5", x: 800, y: 200, owner: 'p2'}
                        { text: "Carnivore 2/1", x: 220, y: 420, owner: 'p1'}
                        { text: "Herbivore 1/2", x: 360, y: 420, owner: 'p1'}
-                       { text: "Stone Wall 0/10", x: 500, y: 420, owner: 'p1'}
-                       { text: "Log 0/1", x: 660, y: 420, owner: 'p1'}
-                       { text: "Ent 0/5", x: 800, y: 420, owner: 'p1'}
+                       { text: "Stone Wall 0/10", x: 500, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true}
+                       { text: "Log 0/1", x: 660, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true}
+                       { text: "Ent 0/5", x: 800, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true}
+                       { text: "Barricade 0/10", x: 500, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true}
+                       { text: "O(log(n)) 0/1", x: 660, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true}
+                       { text: "Fence 0/5", x: 800, y: 420, owner: 'p1', pile: 'p1_draw', flipped: true}
                ]
 
 test_init()