From 4ff9794fa2b545134efe341ad012667c67f70d15 Mon Sep 17 00:00:00 2001
From: Karan Jayachandra
Date: Sat, 15 Nov 2025 20:09:51 +0100
Subject: Added the changes to include the game counting
---
src/data.js | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
(limited to 'src/data.js')
diff --git a/src/data.js b/src/data.js
index 6abad81..3e133ee 100644
--- a/src/data.js
+++ b/src/data.js
@@ -1,9 +1,9 @@
class Switch {
- constructor(id, description, status) {
+ constructor(id, status) {
this.id = id;
this.status = typeof status !== "undefined" ? status : false;
- this.description = description;
- this.name = description + " " + (id + 1);
+ this.description = this.constructor.name;
+ this.name = this.description + " " + (id + 1);
}
toggle() {
this.status = !this.status;
@@ -22,18 +22,18 @@ class Switch {
export class Court extends Switch {
constructor(id, status) {
- super(id, "Court", status);
+ super(id, status);
}
}
export class Regular extends Switch {
constructor(id, status, level, games, firstName, lastName) {
- super(id, "Regular", status);
- console.log(this.constructor.name);
+ super(id, status);
this.level = typeof level !== "undefined" ? level : 1;
this.games = typeof games !== "undefined" ? games : 0;
- this.firstName = typeof firstName !== "undefined" ? firstName : this.description;
- this.lastName = typeof lastName !== "undefined" ? lastName : ( this.id + 1 );
+ this.firstName =
+ typeof firstName !== "undefined" ? firstName : this.description;
+ this.lastName = typeof lastName !== "undefined" ? lastName : this.id + 1;
this.name = this.firstName + " " + this.lastName;
}
}
@@ -49,7 +49,7 @@ export class Guest extends Switch {
categoryCount = 3;
constructor(id, status, games) {
- super(id, "Guest", status);
+ super(id, status);
const categoryId = Math.floor(id / this.maxCount) || 0;
this.level = guestCategories[categoryId].level;
this.games = typeof games !== "undefined" ? games : 0;
@@ -83,20 +83,26 @@ export class Team {
export class Game extends Switch {
constructor(id, status, teamOne, teamTwo) {
- super(id, "Game", status);
+ super(id, status);
this.teamOne = teamOne;
this.teamTwo = teamTwo;
}
print() {
- const teamOne = this.teamOne.playerOne.firstName + " and " + this.teamOne.playerTwo.firstName;
- const teamTwo = this.teamTwo.playerOne.firstName + " and " + this.teamTwo.playerTwo.firstName;
+ const teamOne =
+ this.teamOne.playerOne.firstName +
+ " and " +
+ this.teamOne.playerTwo.firstName;
+ const teamTwo =
+ this.teamTwo.playerOne.firstName +
+ " and " +
+ this.teamTwo.playerTwo.firstName;
console.log(
"Game " + this.id + ": " + teamOne + " is playing against " + teamTwo
);
}
render() {
const blockedState = this.teamOne.playerOne.firstName === "RESERVED";
- const playerState = this.teamOne.render() + "
"+ this.teamTwo.render();
+ const playerState = this.teamOne.render() + "
" + this.teamTwo.render();
const type = blockedState ? `Reserved
` : playerState;
return `
Court ${this.id + 1}
--
cgit v1.3.1