From 642b40ad50fa33b2208617e20aa48ad54d87e163 Mon Sep 17 00:00:00 2001 From: Paolo Brasolin <paolo.brasolin@eurac.edu> Date: Thu, 17 Mar 2022 15:40:38 +0100 Subject: [PATCH] feat: #fe sent game start to #be --- frontend/src/js/fight_scene.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/js/fight_scene.ts b/frontend/src/js/fight_scene.ts index 82ef30d..8c1f33f 100644 --- a/frontend/src/js/fight_scene.ts +++ b/frontend/src/js/fight_scene.ts @@ -8,11 +8,14 @@ import backend from "./backend"; import levenshtein from "damerau-levenshtein"; import Clue from "./clue"; +import * as Types from "../../../backend/src/types"; + export default class FightScene extends Phaser.Scene { foes: Array<Critter>; ground: Phaser.Types.Physics.Arcade.ImageWithStaticBody; player: Phaser.Types.Physics.Arcade.SpriteWithDynamicBody; cluesGroup: Phaser.Physics.Arcade.Group; + beGame: Types.Game; constructor() { super("fight"); @@ -75,7 +78,7 @@ export default class FightScene extends Phaser.Scene { }); } - create() { + async create() { this.initCluesGroup(); // Draw background forest ["b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "b10"].forEach( @@ -161,6 +164,14 @@ export default class FightScene extends Phaser.Scene { ); this.scale.refresh(); initAndBindGuessPreview(this); + + this.beGame = (await backend.createGame()).data; + this.beGame.began_at = new Date().toISOString(); + await backend.updateGame(this.beGame.id, { + began_at: this.beGame.began_at, + ended_at: null, + }); + gameStart(this); } -- GitLab