feat: server REPL
This commit is contained in:
parent
7d779e351b
commit
114832c795
|
@ -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');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user