+ ACS: AC for achievement count check

+ ACS: AP for achievement point check
+ User minutes used on the system are now tracked
+ MCI: TO for total time spent online system (friendly format)
* Fix up a couple ACS bugs with |value|
* Fix formatting of achievement text
+ Add more achievements
* Fix achievement duration formatting
This commit is contained in:
Bryan Ashby 2019-01-10 20:34:52 -07:00
parent 091a9ae2c7
commit 2788c37492
12 changed files with 149 additions and 27 deletions

View file

@ -40,6 +40,7 @@ const MenuStack = require('./menu_stack.js');
const ACS = require('./acs.js');
const Events = require('./events.js');
const UserInterruptQueue = require('./user_interrupt_queue.js');
const UserProps = require('./user_property.js');
// deps
const stream = require('stream');
@ -442,13 +443,36 @@ Client.prototype.startIdleMonitor = function() {
//
// Every 1m, check for idle.
// We also update minutes spent online the system here,
// if we have a authenticated user.
//
this.idleCheck = setInterval( () => {
const nowMs = Date.now();
const idleLogoutSeconds = this.user.isAuthenticated() ?
Config().users.idleLogoutSeconds :
Config().users.preAuthIdleLogoutSeconds;
let idleLogoutSeconds;
if(this.user.isAuthenticated()) {
idleLogoutSeconds = Config().users.idleLogoutSeconds;
//
// We don't really want to be firing off an event every 1m for
// every user, but want at least some updates for various things
// such as achievements. Send off every 5m.
//
const minOnline = this.user.incrementProperty(UserProps.MinutesOnlineTotalCount, 1);
if(0 === (minOnline % 5)) {
Events.emit(
Events.getSystemEvents().UserStatIncrement,
{
user : this.user,
statName : UserProps.MinutesOnlineTotalCount,
statIncrementBy : 1,
statValue : minOnline
}
);
}
} else {
idleLogoutSeconds = Config().users.preAuthIdleLogoutSeconds;
}
if(nowMs - this.lastKeyPressMs >= (idleLogoutSeconds * 1000)) {
this.emit('idle timeout');
@ -473,6 +497,14 @@ Client.prototype.end = function () {
currentModule.leave();
}
// persist time online for authenticated users
if(this.user.isAuthenticated()) {
this.user.persistProperty(
UserProps.MinutesOnlineTotalCount,
this.user.getProperty(UserProps.MinutesOnlineTotalCount)
);
}
this.stopIdleMonitor();
try {