From 398e4d8fe4a02b510963a99281c8ca5f50e1b7b4 Mon Sep 17 00:00:00 2001 From: Fred Westling Date: Sun, 24 Mar 2024 09:35:16 +1100 Subject: [PATCH] :sparkles: feat: add stubs for scheduling to tournament class --- .changeset/silly-monkeys-unite.md | 5 +++++ src/index.ts | 15 +++++++++++++++ src/v8/tournament.ts | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 .changeset/silly-monkeys-unite.md diff --git a/.changeset/silly-monkeys-unite.md b/.changeset/silly-monkeys-unite.md new file mode 100644 index 0000000..9f13ef2 --- /dev/null +++ b/.changeset/silly-monkeys-unite.md @@ -0,0 +1,5 @@ +--- +"@first-australia/latitude-scheduler": patch +--- + +Set up stubs for creating the schedule inside the tournament class diff --git a/src/index.ts b/src/index.ts index fb97bb1..ae0759f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import Timeslot from "./v8/timeslot"; import Timetable from "./v8/timetable"; +import Tournament from "./v8/tournament"; export function add(a: number, b: number): number { return a + b; @@ -9,8 +10,22 @@ export function subtract(a: number, b: number): number { return a - b; } +console.log("Timetable test:"); const timetable = new Timetable(); for (let i = 0; i < 4; i++) { timetable.timeslots.push(new Timeslot(9 * 60 + i * 45, 45, 4)); } timetable.print(); + +console.log("\nTournament test:"); + +// Initialise a tournament +const tournament = new Tournament({ + name: "My Tournament", + numberOfDays: 1, + numberOfTeams: 24, + preset: "ausFLL" +}); +tournament.construct(); +tournament.populate(); +tournament.export(); \ No newline at end of file diff --git a/src/v8/tournament.ts b/src/v8/tournament.ts index f16dbfa..1ffd2f9 100644 --- a/src/v8/tournament.ts +++ b/src/v8/tournament.ts @@ -2,6 +2,7 @@ import { getPreset, type Preset } from "../presets"; import type Activity from "./activity"; import type { TournamentConfig, TournamentOptions } from "./config"; import Team from "./team"; +import Timetable from "./timetable"; type TournamentInitialProps = { name?: string; @@ -16,6 +17,7 @@ export default class Tournament { activities: Activity[]; options: TournamentOptions; config: TournamentConfig; + timetable: Timetable; constructor({ name = "Tournament", @@ -35,5 +37,31 @@ export default class Tournament { ...config, numberOfDays: numberOfDays ?? config.numberOfDays, }; + this.timetable = new Timetable(); + } + + /** Given the current functional config, generate a timetable */ + construct() { + + } + + /** Given the current functional config and a populated timetable, populate the timetable. */ + populate() { + + } + + /** Given the current functional config and a populated timetable, export the timetable to a file */ + export() { + + } + + static fromJSON(json: string) { + const obj = JSON.parse(json); + const tournament = new Tournament(obj); + return tournament; + } + + toJSON() { + return JSON.stringify(this); } }