2017-09-04 12:53:25 -04:00
|
|
|
if (process.argv.length < 3) {
|
|
|
|
console.log("Usage: node game-client-bot.js <socket-url> [<name>]")
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:06:50 -04:00
|
|
|
var core = require("../game-core");
|
|
|
|
var client = require("../client");
|
2017-09-04 12:53:25 -04:00
|
|
|
var user;
|
|
|
|
|
2017-10-30 22:24:39 -04:00
|
|
|
var GRID_SIZE = core.GRID_SIZE;
|
|
|
|
var CELL_WIDTH = core.CELL_WIDTH;
|
2017-09-04 12:53:25 -04:00
|
|
|
|
2017-09-04 13:23:12 -04:00
|
|
|
function connect() {
|
|
|
|
client.connectGame(process.argv[2], process.argv[3] || '[BOT]', function(success, msg) {
|
|
|
|
});
|
|
|
|
}
|
2017-09-04 12:53:25 -04:00
|
|
|
|
2017-09-04 13:23:12 -04:00
|
|
|
client.allowAnimation = false;
|
2017-09-04 12:53:25 -04:00
|
|
|
client.renderer = {
|
|
|
|
disconnect: function() {
|
|
|
|
console.log("I died...");
|
2017-09-04 13:23:12 -04:00
|
|
|
connect();
|
2017-09-04 12:53:25 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
setUser: function(u) {
|
|
|
|
user = u;
|
|
|
|
},
|
|
|
|
|
|
|
|
update: function(frame) {
|
|
|
|
if (frame % 6 == 1)
|
|
|
|
{
|
|
|
|
//TODO: decide move.
|
2017-09-04 13:23:12 -04:00
|
|
|
client.changeHeading(Math.floor(Math.random() * 4));
|
2017-09-04 12:53:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-09-04 13:23:12 -04:00
|
|
|
connect();
|