mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
some timer logic
This commit is contained in:
26
server/modules/GameProcess.js
Normal file
26
server/modules/GameProcess.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const globals = require('../config/globals.js');
|
||||
const ServerTimer = require('./ServerTimer.js');
|
||||
|
||||
process.on('message', (msg) => {
|
||||
const logger = require('./Logger')(msg.logLevel);
|
||||
switch (msg.command) {
|
||||
case globals.GAME_PROCESS_COMMANDS.START_TIMER:
|
||||
logger.debug('CHILD PROCESS ' + msg.accessCode + ': START TIMER');
|
||||
runGameTimer(msg.hours, msg.minutes, logger).then(() => {
|
||||
logger.debug('Timer finished for ' + msg.accessCode);
|
||||
process.send({ command: globals.GAME_PROCESS_COMMANDS.END_GAME });
|
||||
process.exit(0);
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function runGameTimer (hours, minutes, logger) {
|
||||
const cycleTimer = new ServerTimer(
|
||||
hours,
|
||||
minutes,
|
||||
globals.CLOCK_TICK_INTERVAL_MILLIS,
|
||||
logger
|
||||
);
|
||||
return cycleTimer.runTimer();
|
||||
}
|
||||
Reference in New Issue
Block a user