diff --git a/game/src/scenes/GameOverScene.ts b/game/src/scenes/GameOverScene.ts index b563ba9..28ce75e 100644 --- a/game/src/scenes/GameOverScene.ts +++ b/game/src/scenes/GameOverScene.ts @@ -13,6 +13,19 @@ export default class PlayScene extends Phaser.Scene { } async create(data) { + const pts = data.points || 0 + const lvl = data.level || 0 + const shts = data.shoots || 0 + const time = Math.ceil(data.elapsedTime || 0) + let rank = 0 + + if (window.myStuff.token) { + const response = await API.record(pts, shts, time) + rank = response.rank + + await window.updateTopList() + } + console.log("Show end screen with data:", data) this.add.image(250, 550, 'phaser-logo').setScale(0.5) @@ -25,27 +38,20 @@ export default class PlayScene extends Phaser.Scene { font: '64px Verdana', }).setOrigin(0.5, 0.5) - const rank = 0 - const pts = data.points || 0 - const lvl = data.level || 0 - const shts = data.shoots || 0 - const time = Math.ceil(data.elapsedTime || 0) + const lines: string[] = [] + if (rank) { lines.push("Miejsce w rankingu: #" + rank) } + lines.push("Punkty: " + pts) + lines.push("Poziom: " + lvl) + lines.push("Czas Gry: " + time + 's') - this.add.text(this.cameras.main.centerX, this.cameras.main.centerY, [ - "Miejsce w rankingu: #" + rank, - "Punkty: " + pts, - "Poziom: " + lvl, - "Czas Gry: " + time + 's', - ], { - font: '32px Verdana', - align: 'center', - color: 'cyan' - }).setOrigin(0.5, 0.5) + this.add.text(this.cameras.main.centerX, this.cameras.main.centerY, + lines, + { + font: '32px Verdana', + align: 'center', + color: 'cyan' + }).setOrigin(0.5, 0.5) - if (window.myStuff.token) { - await API.record(pts, shts, time) - await window.updateTopList() - } window.unfreezeGui() } }