diff --git a/src/pong/src/game.ts b/src/pong/src/game.ts index cb93941..92bdacf 100644 --- a/src/pong/src/game.ts +++ b/src/pong/src/game.ts @@ -1,8 +1,6 @@ import { UserId } from '@shared/database/mixin/user'; import { randomInt } from 'crypto'; - - export class Paddle { public static readonly DEFAULT_SPEED = 10; public static readonly DEFAULT_HEIGHT = 80; @@ -155,28 +153,24 @@ export class Pong { public userRight: UserId, ) { } - public readyup(uid : UserId) - { + public readyup(uid : UserId) { if (uid === this.userLeft) { this.ready_checks[LEFT] = true; - } if (uid === this.userRight) { + } + if (uid === this.userRight) { this.ready_checks[RIGHT] = true; } } - public readydown(uid : UserId) - { + public readydown(uid : UserId) { // is everyone already ready? if (this.ready_checks[LEFT] === true && this.ready_checks[RIGHT] === true) return ; - if (uid === this.userLeft) - this.ready_checks[LEFT] = false; - if (uid === this.userRight) - this.ready_checks[RIGHT] = false; + if (uid === this.userLeft) { this.ready_checks[LEFT] = false; } + if (uid === this.userRight) { this.ready_checks[RIGHT] = false; } } public tick() { - if (!this.local && (this.ready_checks[LEFT] !== true || this.ready_checks[RIGHT] !== true)) - return; + if (!this.local && (this.ready_checks[LEFT] !== true || this.ready_checks[RIGHT] !== true)) { return;} if (this.paddleCollision(this.leftPaddle, 'left')) { this.ball.collided( 'left', diff --git a/src/pong/src/state.ts b/src/pong/src/state.ts index 3995565..4725f67 100644 --- a/src/pong/src/state.ts +++ b/src/pong/src/state.ts @@ -74,14 +74,12 @@ class StateI { // wait for ready up // --- g.tick(); - if (g.sendSig === false && g.ready_checks[0] === true && g.ready_checks[1] === true) - { + if (g.sendSig === false && g.ready_checks[0] === true && g.ready_checks[1] === true) { u1.socket.emit('rdyEnd'); u2.socket.emit('rdyEnd'); g.sendSig = true; } - if (g.ready_checks[0] === true && g.ready_checks[1] === true) - { + if (g.ready_checks[0] === true && g.ready_checks[1] === true) { this.gameUpdate(gameId, u1.socket); this.gameUpdate(gameId, u2.socket); } @@ -228,7 +226,7 @@ class StateI { socket.emit('queueEvent', 'unregistered'); } - private readydownUser(socket: SSocket) : void { // + private readydownUser(socket: SSocket) : void { // do we know this user ? if (!this.users.has(socket.authUser.id)) return; const user = this.users.get(socket.authUser.id)!; @@ -239,7 +237,7 @@ class StateI { if (game.local === true) return; game.readydown(user.id); } - private readyupUser(socket: SSocket) : void { // + private readyupUser(socket: SSocket) : void { // do we know this user ? if (!this.users.has(socket.authUser.id)) return; const user = this.users.get(socket.authUser.id)!;