From fc8d8ab8d0da95ec79056f59e14a150df6fcea89 Mon Sep 17 00:00:00 2001
From: Karan Jayachandra
Date: Sun, 30 Aug 2026 22:43:21 +0200
Subject: Moved to svelte
---
src/data.js | 111 ------------------------------------------------------------
1 file changed, 111 deletions(-)
delete mode 100644 src/data.js
(limited to 'src/data.js')
diff --git a/src/data.js b/src/data.js
deleted file mode 100644
index 0b0c9ab..0000000
--- a/src/data.js
+++ /dev/null
@@ -1,111 +0,0 @@
-class Switch {
- constructor(id, description, status) {
- this.id = id;
- this.status = typeof status !== "undefined" ? status : false;
- this.description = description;
- this.name = this.description + " " + (id + 1);
- }
- toggle() {
- this.status = !this.status;
- this.print();
- }
- print() {
- let status = this.status ? "active" : "inactive";
- console.log(this.name + " is currently " + status);
- }
- render() {
- let color = this.status ? `` : `class="outline secondary"`;
- let id = this.description + "_" + this.id;
- return ``;
- }
-}
-
-export class Court extends Switch {
- constructor(id, status) {
- super(id, "Court", status);
- }
-}
-
-export class Regular extends Switch {
- constructor(id, status, level, games, firstName, lastName) {
- super(id, "Regular", 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.name = this.firstName + " " + this.lastName;
- }
-}
-
-const guestCategories = {
- 0: { description: "Beginner", level: 1 },
- 1: { description: "Novice", level: 3 },
- 2: { description: "Intermediate", level: 6 },
-};
-
-export class Guest extends Switch {
- maxCount = 6;
- categoryCount = 3;
-
- constructor(id, status, games) {
- super(id, "Guest", status);
- const categoryId = Math.floor(id / this.maxCount) || 0;
- this.level = guestCategories[categoryId].level;
- this.games = typeof games !== "undefined" ? games : 0;
- const guestNumber = (id % this.maxCount) + 1;
- this.firstName = guestCategories[categoryId].description;
- this.lastName = guestNumber;
- this.name = this.firstName + " " + this.lastName;
- }
-}
-
-function renderPlayerName(player) {
- return `${player.firstName} ${player.lastName}`;
-}
-
-export class Team {
- constructor(playerOne, playerTwo) {
- this.playerOne = playerOne;
- this.playerTwo = playerTwo;
- }
- print() {
- console.log("Team consists of:");
- this.playerOne.print();
- this.playerTwo.print();
- }
- render() {
- const p1 = renderPlayerName(this.playerOne);
- const p2 = renderPlayerName(this.playerTwo);
- return p1 + `
` + p2;
- }
-}
-
-export class Game extends Switch {
- constructor(id, status, teamOne, teamTwo) {
- super(id, "Game", 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;
- 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 type = blockedState ? `Reserved
` : playerState;
- return `
- ${type}
- `;
- }
-}
--
cgit v1.3.1