mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-10 04:40:46 -05:00
* Got something going * Style overwrites * width != height * More playing with lines * Migrations * Start bracket initial * Unhardcode stage generation params * Link to match page * Matches page initial * Support directly adding seed to map list generator * Add docs * Maps in matches page * Add invariant about tie breaker map pool * Fix PICNIC lacking tie breaker maps * Only link in bracket when tournament has started * Styled tournament roster inputs * Prefer IGN in tournament match page * ModeProgressIndicator * Some conditional rendering * Match action initial + better error display * Persist bestOf in DB * Resolve best of ahead of time * Move brackets-manager to core * Score reporting works * Clear winner on score report * ModeProgressIndicator: highlight winners * Fix inconsistent input * Better text when submitting match * mapCountPlayedInSetWithCertainty that works * UNDO_REPORT_SCORE implemented * Permission check when starting tournament * Remove IGN from upsert * View match results page * Source in DB * Match page waiting for teams * Move tournament bracket to feature folder * REOPEN_MATCH initial * Handle proper resetting of match * Inline bracket-manager * Syncify * Transactions * Handle match is locked gracefully * Match page auto refresh * Fix match refresh called "globally" * Bracket autoupdate * Move fillWithNullTillPowerOfTwo to utils with testing * Fix map lists not visible after tournament started * Optimize match events * Show UI while in progress to members * Fix start tournament alert not being responsive * Teams can check in * Fix map list 400 * xxx -> TODO * Seeds page * Remove map icons for team page * Don't display link to seeds after tournament has started * Admin actions initial * Change captain admin action * Make all hooks ts * Admin actions functioning * Fix validate error not displaying in CatchBoundary * Adjust validate args order * Remove admin loader * Make delete team button menancing * Only include checked in teams to bracket * Optimize to.id route loads * Working show map list generator toggle * Update full tournaments flow * Make full tournaments work with many start times * Handle undefined in crud * Dynamic stage banner * Handle default strat if map list generation fails * Fix crash on brackets if less than 2 teams * Add commented out test for reference * Add TODO * Add players from team during register * TrustRelationship * Prefers not to host feature * Last before merge * Rename some vars * More renames
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { suite } from "uvu";
|
|
import * as assert from "uvu/assert";
|
|
import {
|
|
fillWithNullTillPowerOfTwo,
|
|
mapCountPlayedInSetWithCertainty,
|
|
} from "./tournament-bracket-utils";
|
|
|
|
const MapCountPlayedInSetWithCertainty = suite(
|
|
"mapCountPlayedInSetWithCertainty()"
|
|
);
|
|
const FillWithNullTillPowerOfTwo = suite("fillWithNullTillPowerOfTwo()");
|
|
|
|
const mapCountParamsToResult: {
|
|
bestOf: number;
|
|
scores: [number, number];
|
|
expected: number;
|
|
}[] = [
|
|
{ bestOf: 3, scores: [0, 0], expected: 2 },
|
|
{ bestOf: 3, scores: [1, 0], expected: 2 },
|
|
{ bestOf: 3, scores: [1, 1], expected: 3 },
|
|
{ bestOf: 5, scores: [0, 0], expected: 3 },
|
|
{ bestOf: 5, scores: [1, 0], expected: 3 },
|
|
{ bestOf: 5, scores: [2, 0], expected: 3 },
|
|
{ bestOf: 5, scores: [2, 1], expected: 4 },
|
|
{ bestOf: 7, scores: [0, 0], expected: 4 },
|
|
{ bestOf: 7, scores: [2, 2], expected: 6 },
|
|
];
|
|
|
|
for (const { bestOf, scores, expected } of mapCountParamsToResult) {
|
|
MapCountPlayedInSetWithCertainty(
|
|
`bestOf=${bestOf}, scores=${scores.join(",")} -> ${expected}`,
|
|
() => {
|
|
assert.equal(
|
|
mapCountPlayedInSetWithCertainty({ bestOf, scores }),
|
|
expected
|
|
);
|
|
}
|
|
);
|
|
}
|
|
|
|
const powerOfTwoParamsToResults: [
|
|
amountOfTeams: number,
|
|
expectedNullCount: number
|
|
][] = [
|
|
[32, 0],
|
|
[16, 0],
|
|
[8, 0],
|
|
[31, 1],
|
|
[0, 0],
|
|
[17, 15],
|
|
];
|
|
|
|
for (const [amountOfTeams, expectedNullCount] of powerOfTwoParamsToResults) {
|
|
FillWithNullTillPowerOfTwo(
|
|
`amountOfTeams=${amountOfTeams} -> ${expectedNullCount}`,
|
|
() => {
|
|
assert.equal(
|
|
fillWithNullTillPowerOfTwo(Array(amountOfTeams).fill("team")).filter(
|
|
(x) => x === null
|
|
).length,
|
|
expectedNullCount
|
|
);
|
|
}
|
|
);
|
|
}
|
|
|
|
MapCountPlayedInSetWithCertainty.run();
|
|
FillWithNullTillPowerOfTwo.run();
|