-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·40 lines (27 loc) · 871 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var _ = require("underscore"),
colors = require('colors'),
vm = require("vm");
var Engine = require("./src/engine.js");
var config = Engine.loadConfig("./spec/fixtures/game.yml")
var world = global.world = new Engine.World(config);
world.DEBUG = true;
require("./spec/helpers.js");
var TICK_TIME_MS = 1000;
setupREPL();
function setupREPL() {
report("Starting Enchantment CLI. Take a look at your " + "world".yellow + " and " + "player".yellow);
var repl = require("repl").start("Enchantment > ");
_.extend(repl.context, Engine);
repl.context.world = world;
repl.context.player = createWarriorPlayer();
setInterval(function() {
world.tick();
}, TICK_TIME_MS);
repl.rli.on('close', function() {
report("\nYou set up camp and fall asleep.".green);
process.exit();
});
}
function report(message) {
console.log(message)
}