Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions apps/server/src/modules/scores/scores.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const tinCanRallyValidator = z.object({
present: z.boolean(),
disqualified: z.boolean(),
actions: z.string().regex(/^[CIX]*$/, "Invalid actions format"),
})
}),
),
});

Expand All @@ -24,7 +24,7 @@ const nuclearCleanupValidator = z.object({
teamId: z.string(),
present: z.boolean(),
leftStartingZone: z.boolean(),
})
}),
),
zoneTokenCounts: z.object({
outerWest: z.number(),
Expand Down Expand Up @@ -54,20 +54,20 @@ export const scoresRouter = router({

for (const action of team.actions) {
if (action === "C") {
accumulatedScore--;
accumulatedScore += 3;
} else if (action === "X") {
lineDeficit++;
} else if (action === "I") {
if (lineDeficit > 0) {
lineDeficit--;
} else {
accumulatedScore += 2;
accumulatedScore++;
}
}
}

return [team.teamId, Math.max(0, accumulatedScore)];
})
}),
);

let leaguePoints: Record<string, number>;
Expand All @@ -80,7 +80,7 @@ export const scoresRouter = router({
.map(([teamId], idx) => [
teamId,
data.teams.find((team) => team.teamId === teamId)?.present ? 2 * idx + 2 : 0,
])
]),
);
}

Expand All @@ -100,7 +100,7 @@ export const scoresRouter = router({
},
{
where: eq(matchScoreEntries.matchId, match.id),
}
},
);
}
}),
Expand All @@ -125,7 +125,7 @@ export const scoresRouter = router({
(idx === 0
? 3 * data.zoneTokenCounts.outerEast + data.zoneTokenCounts.innerEast
: 3 * data.zoneTokenCounts.outerWest + data.zoneTokenCounts.innerWest),
])
]),
);

const leaguePoints = Object.fromEntries(
Expand All @@ -134,7 +134,7 @@ export const scoresRouter = router({
.map(([teamId], idx) => [
teamId,
data.teams.find((team) => team.teamId === teamId)?.present ? 2 * idx + 2 : 0,
])
]),
);

if (!match.scoreEntry) {
Expand All @@ -153,7 +153,7 @@ export const scoresRouter = router({
},
{
where: eq(matchScoreEntries.matchId, match.id),
}
},
);
}
}),
Expand Down
Loading