aboutsummaryrefslogtreecommitdiff
path: root/src/game.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.mjs')
-rw-r--r--src/game.mjs18
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();
+ });
+}