diff options
Diffstat (limited to 'src/data.js')
| -rw-r--r-- | src/data.js | 32 |
1 files changed, 19 insertions, 13 deletions
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() + "<hr>"+ this.teamTwo.render(); + const playerState = this.teamOne.render() + "<hr>" + this.teamTwo.render(); const type = blockedState ? `<h5>Reserved</p>` : playerState; return `<article> <h4>Court ${this.id + 1}</h4><hr> |
