@@ -177,9 +177,9 @@ export class SlimeGame extends RealTimeGame<SlimeClient> {
177177 }
178178
179179 protected override processRoundInfo ( m : ByteReader ) : void {
180- if ( this . roundPlayers . length === 2 ) {
180+ if ( this . roundPlayers . length ) {
181181 const flags = m . get ( )
182- if ( flags & 4 ) {
182+ if ( this . roundPlayers . length > 1 && ( flags & 4 ) ) {
183183 [ this . roundPlayers [ 0 ] , this . roundPlayers [ 1 ] ] = [ this . roundPlayers [ 1 ] , this . roundPlayers [ 0 ] ]
184184 }
185185 this . status = flags & 3
@@ -231,11 +231,11 @@ export class SlimeGame extends RealTimeGame<SlimeClient> {
231231
232232 protected processRoundWin ( p1Won : boolean ) : void {
233233 ( p1Won ? this . p1 : this . p2 ) . score ++
234- this . roundPlayers [ p1Won ? 0 : 1 ] . addWin ( )
235- this . roundPlayers [ p1Won ? 1 : 0 ] . addLoss ( )
234+ this . roundPlayers [ p1Won ? 0 : 1 ] ? .addWin ( )
235+ this . roundPlayers [ p1Won ? 1 : 0 ] ? .addLoss ( )
236236 this . updatePlayers ( )
237237
238- this . status = p1Won !== ( this . roundPlayers [ 1 ] === this . localClient ) ? GameStatus . WIN : GameStatus . LOSS
238+ this . status = p1Won === ( this . roundPlayers [ 0 ] === this . localClient ) ? GameStatus . WIN : GameStatus . LOSS
239239 }
240240
241241 protected processRoundStart0 ( _m : ByteReader ) : void {
@@ -285,7 +285,7 @@ export class SlimeGame extends RealTimeGame<SlimeClient> {
285285
286286 override updateGameState ( dt : number ) : void {
287287 // update network
288- if ( this . room && this . roundPlayers . length === 2 && this . localClient . active ) {
288+ if ( this . room && this . localClient . active ) {
289289 const keyFlags = this . getKeyFlags ( )
290290 if ( this . lastKeySent !== keyFlags ) {
291291 this . sendMove ( this . lastKeySent = keyFlags )
@@ -417,6 +417,7 @@ export class GameDrawer {
417417 this . drawPing ( ctx , W , H , c2 . ping , flip )
418418 } else {
419419 this . drawSlimer ( ctx , W , H , p2 . x + p2 . xe , p2 . y + p2 . ye , c1 . colorInv , '<bot>' , flip , true )
420+ this . drawPing ( ctx , W , H , 0 , flip )
420421 }
421422 }
422423
@@ -435,9 +436,7 @@ export class GameDrawer {
435436 } else if ( ! this . game . localClient . active ) {
436437 status = ! this . game . status
437438 ? 'Spectating'
438- : `${ this . game . status === GameStatus . WIN ? 'Left' : 'Right' } wins the round!`
439- } else if ( this . game . roundPlayers . length < 2 ) {
440- status = 'Waiting for opponent'
439+ : `${ this . game . status === GameStatus . WIN !== this . game . flipP1 ? 'Left' : 'Right' } wins the round!`
441440 } else if ( this . game . status === GameStatus . WIN ) {
442441 status = 'You won the round!'
443442 } else if ( this . game . status === GameStatus . LOSS ) {
0 commit comments