From 51cf65e4d3e928a37b542acfb3de439c42907a9f Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Fri, 14 Nov 2025 14:30:38 +0100 Subject: Added the guests section functionality --- src/game.mjs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/game.mjs') 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(); + }); +} -- cgit v1.3.1