@lovebowls/leaguejs
Version:
A framework-agnostic JavaScript library for managing leagues, teams, and matches
36 lines (35 loc) • 2.06 kB
TypeScript
/**
* Initialise fixtures for the league using a round-robin algorithm.
* Each team plays once per match day. Fixtures are scheduled according to the provided scheduling parameters.
* Teams will play each other `this.settings.timesTeamsPlayOther` times, with home and away fixtures balanced
* as per the cycles of the round-robin generation (e.g., first cycle A vs B, second cycle B vs A).
*
* @param {object} league - The league instance
* @param {Date} [startDate] - The start date for the first round of matches. If null, matches will have null dates.
* @param {Object} [schedulingParams] - Advanced scheduling parameters
* @param {string} [schedulingParams.schedulingPattern='interval'] - 'interval' or 'dayOfWeek'
* @param {number} [schedulingParams.intervalNumber=1] - Number of interval units between match days
* @param {string} [schedulingParams.intervalUnit='weeks'] - 'days' or 'weeks'
* @param {Array<number>} [schedulingParams.selectedDays] - Array of day numbers (0=Sunday, 1=Monday, etc.) for dayOfWeek pattern
* @param {number} [schedulingParams.maxMatchesPerDay] - Maximum matches per day (defaults to maxRinksPerSession if not provided)
* @returns {boolean} - True if fixtures were successfully created, false if there are fewer than 2 teams or if a match fails to be added.
*/
export function initialiseFixtures(league: object, startDate?: Date, schedulingParams?: {
schedulingPattern?: string | undefined;
intervalNumber?: number | undefined;
intervalUnit?: string | undefined;
selectedDays?: number[] | undefined;
maxMatchesPerDay?: number | undefined;
}): boolean;
/**
* Returns a set of match IDs that are in scheduling conflict.
* @param {object} league - The league instance
* @returns {Set<string>}
*/
export function getConflictingMatchIds(league: object): Set<string>;
/**
* Returns the filtered list of matches requiring attention, sorted by priority.
* @param {object} league - The league instance
* @returns {Array}
*/
export function getMatchesRequiringAttention(league: object): any[];