diff options
| author | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-14 14:30:38 +0100 |
|---|---|---|
| committer | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-14 14:30:38 +0100 |
| commit | 51cf65e4d3e928a37b542acfb3de439c42907a9f (patch) | |
| tree | a403872f059a6abc374a1f4051db7fd85e79a20e /src/game.mjs | |
| parent | 8a05236fea86f0a9214798193c652b1b09674565 (diff) | |
Added the guests section functionality
Diffstat (limited to 'src/game.mjs')
| -rw-r--r-- | src/game.mjs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/game.mjs b/src/game.mjs index c8931ac..864f255 100644 --- a/src/game.mjs +++ b/src/game.mjs @@ -1,4 +1,4 @@ -import { Notyf } from 'notyf'; +import { Notyf } from "notyf"; import { Manager } from "./utils.mjs"; import { CourtManager } from "./court.mjs"; import { PlayerManager } from "./player.mjs"; @@ -78,6 +78,7 @@ export class GameManager extends Manager { } console.log("Loaded " + this.listData.length + " games."); this.render(); + addGameBehaviour(this); } isConfirmed() { return this.listData[0].status; @@ -122,7 +123,7 @@ export class GameManager extends Manager { propose() { console.log("Proposing new games!"); let possibleMatches = getMatchCount( - this.players.listData, + this.players.listData.concat(this.players.g.listData), this.courts.listData ); console.log("Total possible matches are " + possibleMatches + "."); @@ -152,7 +153,6 @@ export class GameManager extends Manager { for (let i = 0; i < this.listData.length; i++) { this.listData[i].status = true; } - // Need to update the number of games played here this.store(); this.render(); document.getElementById("timer-start").click(); @@ -184,3 +184,15 @@ function getMatchCount(players, courts) { possibleMatches = Math.min(possibleMatches, courts.length); return possibleMatches; } + +function addGameBehaviour(g) { + document.getElementById("propose").addEventListener("click", () => { + g.propose(); + }); + document.getElementById("confirm").addEventListener("click", () => { + g.confirm(); + }); + document.getElementById("reset").addEventListener("click", () => { + g.reset(); + }); +} |
