-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsoleExecuter.js
82 lines (75 loc) · 1.88 KB
/
ConsoleExecuter.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"use strict";
const MEMORY_KEY = "core:consoleExecuter";
module.exports = class ConsoleExecuter
{
constructor(memoryBank, locator, actors, logger)
{
this.memoryBank = memoryBank;
this.locator = locator;
this.actors = actors;
this.logger = logger;
}
rewindCore()
{
this.memoryObject = this.memoryBank.getMemory(MEMORY_KEY);
}
execute()
{
if(this.memoryObject.consoleInterfaceHook === null)
return;
switch(this.memoryObject.consoleInterfaceHook)
{
case 1:
this.logger.memoryObject.errors = {};
break;
case 2:
this.logger.memoryObject.warnings = {};
break;
case 3:
this.actors.resetActor(this.memoryObject.p1);
break;
case 4:
this.actors.removeActor(this.memoryObject.p1);
break;
case 5:
this.actors.resetAllActors();
break;
case 6:
try
{
console.log( ( eval(this.memoryObject.p1) )(this.locator) );
//allows console user to execute arbritrary commands DURING a cycle rather than at the end of it.
}
catch(e)
{
console.log("failed " + e);
this.logger.error("could not run consoleExecuter command\n" + this.memoryObject.p1, e);
}
break;
case 7:
this.locator.resetService(this.memoryObject.p1);
break;
case 8:
this.actors.createActor("ActorAdhocHauler", (script)=>script.initiateActor(this.memoryObject.p1,
this.memoryObject.p2,
this.memoryObject.p3,
this.memoryObject.p4,
this.memoryObject.p5));
break;
case 9:
this.memoryBank.eraseMemory(this.memoryObject.p1);
break;
case 10:
this.locator.getService(SERVICE_NAMES.ROOM_SCORING).scoreRoom(this.memoryObject.p1);
break;
default:
break;
}
}
unwindCore()
{
this.memoryObject = { consoleInterfaceHook: null };
this.memoryBank.setMemory(MEMORY_KEY, this.memoryObject);
}
hardResetCore(){}
};