MCPcopy Create free account
hub / github.com/AlecM33/Werewolf / runTimer

Method runTimer

server/modules/ServerTimer.js:43–64  ·  view source on GitHub ↗
(pausedInitially = true)

Source from the content-addressed store, hash-verified

41 }
42
43 runTimer (pausedInitially = true) {
44 const total = convertFromHoursToMilliseconds(this.hours) + convertFromMinutesToMilliseconds(this.minutes);
45 this.totalTime = total;
46 this.currentTimeInMillis = total;
47 this.logger.debug('STARTING TIMER FOR ' + this.totalTime + 'ms');
48 this.start = Date.now();
49 const expected = Date.now() + this.tickInterval;
50 this.timesUpPromise = new Promise((resolve) => {
51 this.timesUpResolver = resolve;
52 });
53 const instance = this;
54 if (!pausedInitially) {
55 this.ticking = setTimeout(function () {
56 stepFn(
57 instance,
58 expected
59 );
60 }, this.tickInterval);
61 }
62
63 return this.timesUpPromise;
64 }
65
66 stopTimer () {
67 if (this.ticking) {

Callers 3

Events.jsFile · 0.80
GameManagerClass · 0.80

Calls 3

stepFnFunction · 0.70

Tested by

no test coverage detected