Skip to content

Commit

Permalink
✨ feat: add stubs for scheduling to tournament class
Browse files Browse the repository at this point in the history
  • Loading branch information
fwestling committed Mar 23, 2024
1 parent f3f7192 commit 398e4d8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-monkeys-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@first-australia/latitude-scheduler": patch
---

Set up stubs for creating the schedule inside the tournament class
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
28 changes: 28 additions & 0 deletions src/v8/tournament.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,6 +17,7 @@ export default class Tournament {
activities: Activity[];
options: TournamentOptions;
config: TournamentConfig;
timetable: Timetable;

constructor({
name = "Tournament",
Expand All @@ -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);
}
}

0 comments on commit 398e4d8

Please sign in to comment.