diff options
| author | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-12 21:46:00 +0100 |
|---|---|---|
| committer | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-12 21:46:00 +0100 |
| commit | 6dff11c285d4990bb9a5b11d6ac36d491bea8de3 (patch) | |
| tree | 5b3930cb01c9ff78878e6a59caa84bfd96ee53f4 /index.js | |
| parent | 0878eeb2200d609930ba597699933ed852e3ee98 (diff) | |
Added the history and working version for games
Diffstat (limited to 'index.js')
| -rw-r--r-- | index.js | 49 |
1 files changed, 12 insertions, 37 deletions
@@ -1,48 +1,23 @@ -import { CourtManager } from "./court.mjs"; +import { GameManager } from "./game.mjs"; import { PlayerManager, addLoadBehaviour } from "./player.mjs"; -import { Round, generateDummyGames, proposeGames } from "./game.mjs"; // Court and player handling -let c = new CourtManager(); +let g = new GameManager(); let p = new PlayerManager(); addLoadBehaviour(p); // Game handling -let proposal; -let session = []; // Persist this in local storage with 1 day limit -if (session.length === 0) { - session.push(new Round(generateDummyGames(c.listData, "---"), 0)); -} -document.getElementById("game_list").innerHTML = session.at(-1).render(); document.getElementById("propose").addEventListener("click", () => { - let normalize = Number(document.getElementById("skill").value); - console.log(normalize); - let players = p.listData.map(function (p) { - p.skill = Math.ceil(p.skill / normalize); - return p; - }); - proposal = proposeGames(players, c.listData); - document.getElementById("game_list").innerHTML = new Round(proposal).render(); + let factor = Number(document.getElementById("skill").value); + let players = p.normalize(factor); + console.log(players); + g.propose(players); }); document.getElementById("confirm").addEventListener("click", () => { - console.log( - "Confirm the proposal on screen for round " + session.length + "." - ); - session.push(new Round(proposal, session.length)); - // Need to update the number of games played here - document.getElementById("game_list").innerHTML = session.at(-1).render(); - document.getElementById("timer-start").click(); - const notification = new Notyf({ - duration: 30 * 1000, - position: { x: "center", y: "top" }, - types: [ - { - type: "success", - background: "green", - duration: 1000 * 1000, - dismissible: true, - }, - ], - }); - notification.success("Round confirmed!"); + console.log("Confirm the proposal for round " + g.round + "."); + g.confirm(); +}); +document.getElementById("reset").addEventListener("click", () => { + console.log("Resetting the session!"); + g.reset(); }); |
