diff --git a/client/src/scenes/home.instances.js b/client/src/scenes/home.instances.js index 2d3bf5cb..fa2bd2c3 100644 --- a/client/src/scenes/home.instances.js +++ b/client/src/scenes/home.instances.js @@ -5,6 +5,7 @@ const X = MENU_MAIN.x(); const Y = MENU_MAIN.y(); const WIDTH = MENU_MAIN.width(); const HEIGHT = MENU_MAIN.height(); +const NULL_UUID = '00000000-0000-0000-0000-000000000000'; class HomeRankings extends Phaser.Scene { constructor() { @@ -20,10 +21,17 @@ class HomeRankings extends Phaser.Scene { .setInteractive() .setOrigin(0) .on('pointerdown', () => { - this.game.events.emit('SET_PLAYER', player); + if (player.ready) { + this.registry.set('player', player); + this.registry.get('ws').sendInstanceReady(player.instance); + } else { + this.game.events.emit('SET_PLAYER', player); + } }); + const name = player.instance === NULL_UUID ? 'Normal Mode' : `${player.instance.substring(0, 5)}`; + const disp = player.ready ? name.concat(' - in progress') : name; this.add - .text(joinNormal.getCenter().x, joinNormal.getCenter().y, `${player.instance}`, TEXT.NORMAL) + .text(joinNormal.getCenter().x, joinNormal.getCenter().y, disp, TEXT.NORMAL) .setOrigin(0.5, 0.5); }; diff --git a/client/src/scenes/item.list.js b/client/src/scenes/item.list.js index c66d859e..fe64196a 100644 --- a/client/src/scenes/item.list.js +++ b/client/src/scenes/item.list.js @@ -134,7 +134,9 @@ class ItemList extends Phaser.Scene { } create() { - const { vbox } = this.registry.get('player'); + const player = this.registry.get('player'); + if (!player) return false; + const { vbox } = player; this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this); if (!vbox.bound) return false; diff --git a/client/src/scenes/menu.cryps.list.js b/client/src/scenes/menu.cryps.list.js index 33b36683..aa3bbe00 100644 --- a/client/src/scenes/menu.cryps.list.js +++ b/client/src/scenes/menu.cryps.list.js @@ -23,7 +23,8 @@ class MenuCrypList extends Phaser.Scene { // this.cameras.main.setViewport(CRYP_LIST.x(), CRYP_LIST.y(), CRYP_LIST.width(), CRYP_LIST.height()); this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this); - this.drawCryps(this.registry.get('player').cryps); + const player = this.registry.get('player'); + if (player) this.drawCryps(player.cryps); } updateData(parent, key, data) { diff --git a/client/src/scenes/menu.js b/client/src/scenes/menu.js index 4f4b397d..7b6cfdaf 100644 --- a/client/src/scenes/menu.js +++ b/client/src/scenes/menu.js @@ -43,8 +43,8 @@ class Menu extends Phaser.Scene { this.registry.set('inMenu', true); // Request the latest player state when we load the scene - const { instance } = this.registry.get('player'); - this.registry.get('ws').sendPlayerState(instance); + const player = this.registry.get('player'); + this.registry.get('ws').sendPlayerState(player.instance); return true; } diff --git a/client/src/scenes/menu.score.js b/client/src/scenes/menu.score.js index 24e29e33..067374e3 100644 --- a/client/src/scenes/menu.score.js +++ b/client/src/scenes/menu.score.js @@ -11,9 +11,11 @@ class MenuScore extends Phaser.Scene { } create() { - const { score } = this.registry.get('player'); - this.add.text(X, Y, `Wins: ${score.wins}`, TEXT.HEADER); - this.add.text(X, Y + HEIGHT * 0.1, `Losses: ${score.losses}`, TEXT.HEADER); + const player = this.registry.get('player'); + if (!player) return false; + this.add.text(X, Y, `Wins: ${player.score.wins}`, TEXT.HEADER); + this.add.text(X, Y + HEIGHT * 0.1, `Losses: ${player.score.losses}`, TEXT.HEADER); + return true; } cleanUp() {