feat: server REPL

This commit is contained in:
cha0s 2019-05-03 01:27:09 -05:00
parent 7d779e351b
commit 114832c795

View File

@ -11,8 +11,26 @@ const socketServer = new SocketServer();
let game; let game;
let httpServer; let httpServer;
import repl from 'repl';
import {Entity} from '@avocado/entity';
import {flowerBarrelJSON} from './create-server-room';
const instance = repl.start({
prompt: 'humus> ',
input: process.stdin,
output: process.stdout
});
instance.context.createBarrel = () => {
return (new Entity()).fromJSON(flowerBarrelJSON([400, 400]));
};
instance.context.addEntityToRoom = (entity) => {
game.room.addEntityToLayer(entity, 'everything');
};
function createGame() { function createGame() {
game = new Game(); game = new Game();
instance.context.game = game;
// Listen for connections. // Listen for connections.
httpServer = http.createServer(); httpServer = http.createServer();
httpServer.listen(8420, '0.0.0.0'); httpServer.listen(8420, '0.0.0.0');