mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 07:47:50 +01:00
fix bug with redundant play/pause events, fix spec, tweak current moderator css
This commit is contained in:
@@ -188,7 +188,8 @@ export class InProgress {
|
||||
toast('You have been killed!', 'warning', true, true, 'medium');
|
||||
} else {
|
||||
toast(killedPlayer.name + ' was killed!', 'warning', true, true, 'medium');
|
||||
if (killedPlayer.userType === globals.USER_TYPES.MODERATOR) {
|
||||
if (killedPlayer.userType === globals.USER_TYPES.MODERATOR
|
||||
&& this.stateBucket.currentGameState.client.userType !== globals.USER_TYPES.TEMPORARY_MODERATOR) {
|
||||
SharedStateUtil.displayCurrentModerator(killedPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
border-radius: 5px;
|
||||
color: #d7d7d7;
|
||||
background-color: #16141e;
|
||||
width: fit-content;
|
||||
padding: 0 20px;
|
||||
padding: 0 10px;
|
||||
width: 90%;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
margin: 1em auto 140px auto;
|
||||
margin: 0 auto 140px auto;
|
||||
}
|
||||
|
||||
#game-state-container h2 {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"build:dev": "webpack --watch --config client/webpack/webpack-dev.config.js --mode=development",
|
||||
"start:dev": "NODE_ENV=development && webpack --config client/webpack/webpack-dev.config.js --mode=development && nodemon index.js",
|
||||
"start:dev:no-hot-reload": "NODE_ENV=development && webpack --config client/webpack/webpack-dev.config.js --mode=development && node index.js",
|
||||
"start:dev:windows": "SET NODE_ENV=development && webpack --config client/webpack/webpack-dev.config.js --mode=development && nodemon index.js",
|
||||
"start:dev:windows": "SET NODE_ENV=development && webpack --config client/webpack/webpack-dev.config.js --mode=development && nodemon index.js -- loglevel=debug",
|
||||
"start:dev:windows:no-hot-reload:debug": "SET NODE_ENV=development && webpack --config client/webpack/webpack-dev.config.js --mode=development && node --inspect index.js",
|
||||
"start:dev:windows:no-hot-reload": "SET NODE_ENV=development && webpack --config client/webpack/webpack-dev.config.js --mode=development && node index.js",
|
||||
"start": "NODE_ENV=production node index.js -- loglevel=debug",
|
||||
|
||||
@@ -66,26 +66,29 @@ class ServerTimer {
|
||||
}
|
||||
|
||||
stopTimer () {
|
||||
this.logger.debug('STOPPING TIMER');
|
||||
if (this.ticking) {
|
||||
this.logger.debug('STOPPING TIMER');
|
||||
clearTimeout(this.ticking);
|
||||
this.ticking = null;
|
||||
}
|
||||
}
|
||||
|
||||
resumeTimer () {
|
||||
this.logger.debug('RESUMING TIMER FOR ' + this.currentTimeInMillis + 'ms');
|
||||
this.start = Date.now();
|
||||
this.totalTime = this.currentTimeInMillis;
|
||||
const expected = Date.now() + this.tickInterval;
|
||||
const instance = this;
|
||||
this.ticking = setTimeout(function () {
|
||||
stepFn(
|
||||
instance,
|
||||
expected
|
||||
);
|
||||
}, this.tickInterval);
|
||||
if (!this.ticking) {
|
||||
this.logger.debug('RESUMING TIMER FOR ' + this.currentTimeInMillis + 'ms');
|
||||
this.start = Date.now();
|
||||
this.totalTime = this.currentTimeInMillis;
|
||||
const expected = Date.now() + this.tickInterval;
|
||||
const instance = this;
|
||||
this.ticking = setTimeout(function () {
|
||||
stepFn(
|
||||
instance,
|
||||
expected
|
||||
);
|
||||
}, this.tickInterval);
|
||||
|
||||
return this.timesUpPromise;
|
||||
return this.timesUpPromise;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class EventManager {
|
||||
try {
|
||||
messageComponents = message.split(';', 3);
|
||||
if (messageComponents[messageComponents.length - 1] === this.instanceId) {
|
||||
this.logger.trace('Disregarding self-authored message');
|
||||
this.logger.debug('Disregarding self-authored message');
|
||||
return;
|
||||
}
|
||||
args = JSON.parse(
|
||||
|
||||
@@ -21,12 +21,11 @@ describe('ServerTimer', () => {
|
||||
serverTimer = new ServerTimer(1, 0, 10, logger);
|
||||
spyOn(global, 'clearTimeout');
|
||||
serverTimer.runTimer(false).then(() => {
|
||||
fail();
|
||||
serverTimer.stopTimer();
|
||||
expect(clearTimeout).toHaveBeenCalledWith(serverTimer.ticking);
|
||||
}).catch((e) => {
|
||||
fail(e);
|
||||
});
|
||||
serverTimer.stopTimer();
|
||||
expect(clearTimeout).toHaveBeenCalledWith(serverTimer.ticking);
|
||||
});
|
||||
|
||||
it('should stop and resume the timer', async () => {
|
||||
|
||||
Reference in New Issue
Block a user