fix: reject unfinishable first-to rules

This commit is contained in:
dahyeon committed 2026-07-12 20:01:22 +00:00
1 parent 0c2c7b59fc
commit 78a2c7cf0d
4 files changed
+47 -5

No files matched your search

@@ -324,7 +324,7 @@ function validateDefinition(definition: SeriesDefinitionLike): void {
assertCompetitionInvariant(
Number.isInteger(definition.rule.winsRequired) &&
definition.rule.winsRequired > 0 &&
definition.rule.winsRequired <= definition.rule.maxGames,
definition.rule.maxGames >= definition.rule.winsRequired * 2 - 1,
'SERIES_DEFINITION_INVALID',
`Series ${definition.id} has an invalid first-to threshold`,
);
@@ -543,9 +543,7 @@ function assertNoSeriesActivity(
if (fact.seriesId === seriesId) activeAdjudications.add(fact.id);
break;
case 'adjudication-reversed':
if (
adjudicationSeriesById.get(fact.adjudicationFactId) === seriesId
) {
if (adjudicationSeriesById.get(fact.adjudicationFactId) === seriesId) {
assertCompetitionInvariant(
activeAdjudications.delete(fact.adjudicationFactId),
'FACT_ALREADY_REVERSED',