From 114832c795db9c146fb28499bd18be92cba4d0cd Mon Sep 17 00:00:00 2001 From: cha0s Date: Fri, 3 May 2019 01:27:09 -0500 Subject: [PATCH] feat: server REPL --- server/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/index.js b/server/index.js index 8eab83f..9248f81 100644 --- a/server/index.js +++ b/server/index.js @@ -11,8 +11,26 @@ const socketServer = new SocketServer(); let game; 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() { game = new Game(); + instance.context.game = game; // Listen for connections. httpServer = http.createServer(); httpServer.listen(8420, '0.0.0.0');