Skip to content

Instantly share code, notes, and snippets.

@vanatteveldt
Created May 31, 2014 23:46
Show Gist options
  • Save vanatteveldt/7c434b668becbfcacb44 to your computer and use it in GitHub Desktop.
Save vanatteveldt/7c434b668becbfcacb44 to your computer and use it in GitHub Desktop.
$ # Create a new game
$ curl -XPOST http://localhost:5000/games/ -d '{"name": "test"}'
{
"created": true,
"game_id": "538a68372cd1c647236a7a8d"
}
$ # Get state of the universe at (start of) turn 1
$ curl http://localhost:5000/games/538a68372cd1c647236a7a8d/turns/1/
{
"done": false,
"fleets": [
{
"name": "Peeping Tom",
"x": 10,
"y": 10
}
],
"planets": [
{
"planet": "Sol",
"population": 100000,
"x": 10,
"y": 10
},
{
"planet": "Alpha",
"population": null,
"x": 100,
"y": 100
}
]
}
$ # Let's move our scout from Sol to Alpha, warp 9, done=true means "end turn"
$ curl -XPUT http://localhost:5000/games/538a68372cd1c647236a7a8d/turns/1/orders/ -d '
{"fleetorders":
[{"fleet": "Peeping Tom",
"dest_x": 100,
"dest_y": 100,
"warp": 9}]
,"done": true }'
{
"done": true,
"status": "ok"
}
$ # Since 'all' orders are in, the next turn is processed immediately
$ curl http://localhost:5000/games/538a68372cd1c647236a7a8d/turns/2/
{
"done": false,
"fleets": [
{
"name": "Peeping Tom",
"x": 67,
"y": 67
}
],
"planets": [
{
"planet": "Sol",
"population": 110000,
"x": 10,
"y": 10
},
{
"planet": "Alpha",
"population": null,
"x": 100,
"y": 100
}
]
}
$ # As you can see, the population of Sol grew by 10%, and the scout moved 81 out of the 125 ly. The order is still there:
$ curl http://localhost:5000/games/538a68372cd1c647236a7a8d/turns/2/orders/
{
"done": null,
"fleetorders": [
{
"dest_x": 100,
"dest_y": 100,
"fleet": "Fleet object",
"warp": 9
}
]
}
$ # Let's go warp 14 (the good part of alpha games ;-))
$ curl -XPUT http://localhost:5000/games/538a68372cd1c647236a7a8d/turns/2/orders/ -d '
{"fleetorders":
[{"fleet": "Peeping Tom",
"dest_x": 100,
"dest_y": 100,
"warp": 14}]
,"done": true }'
{
"done": true,
"status": "ok"
}
$ curl http://localhost:5000/games/538a68372cd1c647236a7a8d/turns/3/
{
"done": false,
"fleets": [
{
"name": "Peeping Tom",
"x": 100,
"y": 100
}
],
"planets": [
{
"planet": "Sol",
"population": 121000,
"x": 10,
"y": 10
},
{
"planet": "Alpha",
"population": null,
"x": 100,
"y": 100
}
]
}
$ # Our scout made it to Alpha! :) Order is also gone since he arrived:
$ curl http://localhost:5000/games/538a68372cd1c647236a7a8d/turns/3/orders/
{
"done": null,
"fleetorders": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment