Door utility and door tracking

* Require >= 45s of time in a door before it counts as "run"
This commit is contained in:
Bryan Ashby
2019-01-18 22:09:10 -07:00
parent 4e1997302e
commit 7776391184
5 changed files with 74 additions and 48 deletions

View File

@@ -10,9 +10,10 @@ const Log = require('./logger.js').log;
const {
getEnigmaUserAgent
} = require('./misc_util.js');
const Events = require('./events.js');
const StatLog = require('./stat_log.js');
const UserProps = require('./user_property.js');
const {
trackDoorRunBegin,
trackDoorRunEnd
} = require('./door_util.js');
// deps
const async = require('async');
@@ -156,17 +157,15 @@ exports.getModule = class ExodusModule extends MenuModule {
let pipeRestored = false;
let pipedStream;
const startTime = moment();
let doorTracking;
function restorePipe() {
if(pipedStream && !pipeRestored && !clientTerminated) {
self.client.term.output.unpipe(pipedStream);
self.client.term.output.resume();
const endTime = moment();
const runTimeMinutes = Math.floor(moment.duration(endTime.diff(startTime)).asMinutes());
if(runTimeMinutes > 0) {
StatLog.incrementUserStat(self.client.user, UserProps.DoorRunTotalMinutes, runTimeMinutes);
if(doorTracking) {
trackDoorRunEnd(doorTracking);
}
}
}
@@ -198,8 +197,7 @@ exports.getModule = class ExodusModule extends MenuModule {
});
sshClient.shell(window, options, (err, stream) => {
StatLog.incrementUserStat(self.client.user, UserProps.DoorRunTotalCount, 1);
Events.emit(Events.getSystemEvents().UserRunDoor, { user : self.client.user } );
doorTracking = trackDoorRunBegin(self.client, `exodus_${self.config.door}`);
pipedStream = stream; // :TODO: ewwwwwwwww hack
self.client.term.output.pipe(stream);