restarting brackets
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
import { BracketData, Match } from "../types";
|
||||
|
||||
export interface BracketMaps {
|
||||
matchByLid: Map<number, Match>;
|
||||
matchByOrder: Map<number, Match>;
|
||||
allMatches: Match[];
|
||||
}
|
||||
|
||||
export function createBracketMaps(bracketData: BracketData): BracketMaps {
|
||||
const matchByLid = new Map<number, Match>();
|
||||
const matchByOrder = new Map<number, Match>();
|
||||
const allMatches: Match[] = [];
|
||||
|
||||
[...bracketData.winners, ...bracketData.losers].forEach((round) => {
|
||||
round.forEach((match) => {
|
||||
matchByLid.set(match.lid, match);
|
||||
|
||||
if (match.order !== null && match.order !== undefined) {
|
||||
matchByOrder.set(match.order, match);
|
||||
}
|
||||
|
||||
allMatches.push(match);
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
matchByLid,
|
||||
matchByOrder,
|
||||
allMatches,
|
||||
};
|
||||
}
|
||||
|
||||
export function getMatchByLid(
|
||||
maps: BracketMaps,
|
||||
lid: number
|
||||
): Match | undefined {
|
||||
return maps.matchByLid.get(lid);
|
||||
}
|
||||
|
||||
export function getMatchByOrder(
|
||||
maps: BracketMaps,
|
||||
order: number
|
||||
): Match | undefined {
|
||||
return maps.matchByOrder.get(order);
|
||||
}
|
||||
Reference in New Issue
Block a user