Skip to content

Commit

Permalink
fix(gameplaymanager): precountdown being counted in games other than …
Browse files Browse the repository at this point in the history
…first
  • Loading branch information
Sup3rFire committed Aug 11, 2021
1 parent 02ded93 commit 1bc2a3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/gameplay/GameplayManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class GameplayManager extends EventEmitter {
this.started = new Date();

this.start();
}, (this.options.countdown ? this.options.countdown_count * this.options.countdown_interval : 0) + this.options.precountdown + this.options.prestart);
}, (this.options.countdown ? this.options.countdown_count * this.options.countdown_interval : 0) + (this.first ? this.options.precountdown : 0) + this.options.prestart);
});
}

Expand Down Expand Up @@ -78,7 +78,7 @@ export default class GameplayManager extends EventEmitter {

public currentFrame() {
if (!this.started) this.started = new Date();
return ((new Date().getTime() - this.started.getTime()) / 1000) * 60;
return Math.round(((new Date().getTime() - this.started.getTime()) / 1000) * 60);
}

public async inGameEvent(data: any) {
Expand Down Expand Up @@ -284,6 +284,7 @@ export default class GameplayManager extends EventEmitter {
const currentFrame = this.currentFrame();

const sendFrames: (KeyEvent | StartEvent | Targets | InGameEvent)[] = [];
console.log(this.nextFrames);
for (const [i, frame] of this.nextFrames.entries()) {
if (frame.frame < currentFrame) sendFrames.push(...this.nextFrames.splice(i, 1));
}
Expand Down
5 changes: 4 additions & 1 deletion src/websocket/WebSocketManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class WebSocketManager {
*/
public send_packet(data: any): void {
// console.log("Client:", data);
// fs.appendFile("./send.log", `[${new Date().toString()}] ${JSON.stringify(data)}\n`, () => {
// fs.appendFile("./send.log", `[O ${new Date().toString()}] ${JSON.stringify(data)}\n`, () => {
// return;
// });

Expand Down Expand Up @@ -190,6 +190,9 @@ export default class WebSocketManager {
}

// console.log("Server:", packet);
// fs.appendFile("./send.log", `[I ${new Date().toString()}] ${JSON.stringify(packet)}\n`, () => {
// return;
// });

const message = this.messages.get(packet.data.command);

Expand Down

0 comments on commit 1bc2a3b

Please sign in to comment.