mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-10 21:28:02 -04:00
Add simulate script foundation
This commit is contained in:
parent
2cc344c4f0
commit
cb1c21e80a
2 changed files with 27 additions and 0 deletions
|
@ -1,6 +1,13 @@
|
|||
###
|
||||
This file will simulate games on node.js by emulating the browser environment.
|
||||
###
|
||||
if process.argv[2] is "one-game"
|
||||
#calculate result of one game here
|
||||
if Math.random() > 0.5
|
||||
process.stdout.write "ogres"
|
||||
else
|
||||
process.stdout.write "humans"
|
||||
process.exit(0)
|
||||
|
||||
bowerComponentsPath = "./bower_components/"
|
||||
headlessClientPath = "./headless_client/"
|
||||
|
|
20
scripts/simulate.coffee
Normal file
20
scripts/simulate.coffee
Normal file
|
@ -0,0 +1,20 @@
|
|||
spawn = require("child_process").spawn
|
||||
|
||||
[sessionOne, sessionTwo] = [process.argv[2],process.argv[3]]
|
||||
|
||||
unless sessionOne and sessionTwo and sessionOne.length is 24 and sessionTwo.length is 24
|
||||
console.log "Not enough games to continue!"
|
||||
process.exit(1)
|
||||
command = "coffee ../headless_client.coffee one-game"
|
||||
run = (cb) ->
|
||||
command = spawn("coffee",["headless_client.coffee","one-game"],{cwd:"/Users/schmatz/codecombat/"})
|
||||
result = ""
|
||||
command.stdout.on 'data', (data) ->
|
||||
result += data.toString()
|
||||
command.stdout.on 'close', ->
|
||||
return cb(result)
|
||||
run (result) ->
|
||||
process.stdout.write result
|
||||
process.exit(0)
|
||||
|
||||
|
Loading…
Reference in a new issue