@taipeistudio/gamekit-competition
v0.3.0
Published
Sports competition engine: brackets, leagues, groups, two-legged ties, best-of-N series, play-in, divisional schedules, draft lottery, rolling rankings, Elo.
Downloads
431
Maintainers
Readme
@taipeistudio/gamekit-competition
Sports competition engine as plain, save-friendly data.
Installation
npm install @taipeistudio/gamekit-competitionAPI
- Knockouts:
seedOrder,seedBracket(byes to top seeds),knockout,pairs,playRound(ko, decide, override)(override = the human's match),playOut,champion,exitRound,reached(W/F/SF/QF/R16…),roundLabel,roundCodes. - Leagues:
roundRobin(teams, { double, rand })(circle method, balanced home/away, rest days for odd counts),table,record,standings(t, tiebreaks)with points, goal difference, goals for, wins and head-to-head mini-leagues;FOOTBALL_POINTS. - Groups:
drawGroups(pots, n, rand, conflict)(backtracking, e.g. no same country),groupStage,qualifiers,crossOver(A1 v B2…). - League phase (Swiss):
swissDraw(pots, rand, { perPot, conflict, attempts })— the 2024+ Champions League draw:perPotopponents from every pot (own included), half at home, no repeats or conflicts, laid out asperPot * pots.lengthmatchdays where everyone plays once. Pots must be equal size; throws if no draw is found. Rank it withtable(). - Pyramids:
promoteRelegate(tiers, moves)(a count per boundary, sizes preserved; new tier = survivors, then promoted-in, then relegated-in),allocate(order, slots)(split a final table into{ cl, el, down… }). - Results:
expected/eloUpdate/eloWinner,poisson,scoreline(football-like scores from two ratings, home edge),twoLegs(aggregate, then your decider),penalties. - Series and play-in:
series(a, b, bestOf, pattern)(default 2-2-1-1-1 home court fora;HOME_2_3_2),nextGame,recordGame,playSeries(s, play),seriesWinner,seriesLoser,seriesStatus("A lead 3-1"),playIn([s7, s8, s9, s10], play). UseplaySeriesas thedecideofplayRoundfor a playoff bracket. - Divisional schedules:
planDivisional(shape, counts, rand)(pair counts;NBA_COUNTSgives 82 games for 2 x 3 x 5 teams),gamesPerTeam,expandMatchups(balanced home and away),scheduleDays(fixtures, rand, { days, noThreeInThree, load })(one list per day, no doubles, even spread),backToBacks. Win-loss tables:table(teams, WIN_LOSS),winPct,gamesBehind,winLoss. - Drafts:
draftLottery(worstFirst, rand, odds, drawn)(NBA_LOTTERY_ODDS, weighted draws without replacement, reports jumps),draftOrder(firstRound, rounds, laterRounds, owner)(traded picks),runDraft(picks, board, pick). - High scores:
highScore(rand, ra, rb, { avgPoints, spread, perPoint, homeEdge, overtime })returns[a, b, overtimes], never tied (basketball, handball). - Rankings:
rank(entries, now, { window, best, include })(rolling best-N, e.g. 52 weeks / best 10),prune,memoRanking,TOUR_SHARES(points/prize by round).
See the football career example in the gamekit README.
License
MIT with attribution. Part of gamekit. Copyright © 2026 Rosdyana Kusuma. See LICENSE; products using this package must credit the author (e.g. "gamekit by Rosdyana Kusuma - https://github.com/rosdyana/gamekit").
