diff options
| author | Karan Jayachandra <mail@karanjayachandra.com> | 2026-08-30 22:43:21 +0200 |
|---|---|---|
| committer | Karan Jayachandra <mail@karanjayachandra.com> | 2026-08-30 22:43:21 +0200 |
| commit | fc8d8ab8d0da95ec79056f59e14a150df6fcea89 (patch) | |
| tree | 33f8050b2f2920c0f1b884a205a8aa4c81d7687c /src/lib/logic/players.js | |
| parent | d37ebfda883bcd03b146a85bc3e5a4657d0abd73 (diff) | |
Moved to sveltemain
Diffstat (limited to 'src/lib/logic/players.js')
| -rw-r--r-- | src/lib/logic/players.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/lib/logic/players.js b/src/lib/logic/players.js new file mode 100644 index 0000000..e11c32f --- /dev/null +++ b/src/lib/logic/players.js @@ -0,0 +1,73 @@ +export function createCourt(id, status = false) { + return { + id, + status, + description: "Court", + name: `Court ${id + 1}`, + }; +} + +export const guestCategories = { + 0: { description: "Beginner", level: 1 }, + 1: { description: "Novice", level: 3 }, + 2: { description: "Intermediate", level: 6 }, +}; + +export const GUESTS_PER_CATEGORY = 6; + +export function createRegular( + id, + status = false, + level = 1, + games = 0, + firstName = "Regular", + lastName = id + 1 +) { + return { + id, + status, + description: "Regular", + level, + games, + firstName, + lastName, + name: `${firstName} ${lastName}`, + }; +} + +export function createGuest(id, status = false, games = 0) { + const categoryId = Math.floor(id / GUESTS_PER_CATEGORY) || 0; + const category = guestCategories[categoryId]; + const guestNumber = (id % GUESTS_PER_CATEGORY) + 1; + const firstName = category.description; + const lastName = guestNumber; + return { + id, + status, + description: "Guest", + level: category.level, + games, + firstName, + lastName, + name: `${firstName} ${lastName}`, + }; +} + +export function createTeam(playerOne, playerTwo) { + return { playerOne, playerTwo }; +} + +export function createGame(id, status, teamOne, teamTwo) { + return { + id, + status, + description: "Game", + teamOne, + teamTwo, + name: `Game ${id + 1}`, + }; +} + +export function isReserved(game) { + return game.teamOne.playerOne.firstName === "RESERVED"; +} |
