Increase coalition condition to 2/3 share to avoid three-way-tie case

This commit is contained in:
Mattia Migliorini
2026-03-09 13:26:32 +01:00
parent a484f6a3fc
commit b5f4af23b9
2 changed files with 9 additions and 1 deletions
+4 -1
View File
@@ -180,7 +180,10 @@ export function computeClanTeamName(players: PlayerInfo[]): string | null {
// Coalition: top two clans cover the majority of humans
if (sorted.length >= 2) {
const [secondTag, secondCount] = sorted[1];
if ((topCount + secondCount) / total > 0.5) {
if (
(topCount + secondCount) / total > 2 / 3 &&
secondCount / total >= 0.25
) {
return `${topTag} / ${secondTag}`;
}
}
+5
View File
@@ -218,6 +218,11 @@ describe("computeClanTeamName", () => {
expect(computeClanTeamName(players)).toBe("ALPHA / BETA");
});
it("returns null when three distinct clans each hold one player", () => {
const players = [human("1", "ALPHA"), human("2", "BETA"), human("3", "GAMMA")];
expect(computeClanTeamName(players)).toBeNull();
});
it("returns null when no players have clan tags", () => {
const players = [human("1"), human("2"), human("3")];
expect(computeClanTeamName(players)).toBeNull();