From 1f1f99f8f318944b008b843b6533f4f63fec4613 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Thu, 26 Jun 2025 23:38:19 +0200 Subject: [PATCH] Adjust advancing team logic in EventRelation to fix `fromPlace` handling --- CommonCore/SQL/src/de/steamwar/sql/EventRelation.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/EventRelation.java b/CommonCore/SQL/src/de/steamwar/sql/EventRelation.java index 28c756ee..d9fde245 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/EventRelation.java +++ b/CommonCore/SQL/src/de/steamwar/sql/EventRelation.java @@ -133,7 +133,7 @@ public class EventRelation { public Optional getAdvancingTeam() { if (fromType == FromType.FIGHT) { - if (fromPlace == 1) { + if (fromPlace == 0) { return getFromFight().flatMap(EventFight::getWinner); } else { return getFromFight().flatMap(EventFight::getLosser); @@ -141,7 +141,9 @@ public class EventRelation { } else if (fromType == FromType.GROUP) { return getFromGroup().map(EventGroup::calculatePoints) .flatMap(points -> points.entrySet().stream() - .max(Map.Entry.comparingByValue()) + .sorted(Map.Entry.comparingByValue()) + .skip(fromPlace) + .findFirst() .map(Map.Entry::getKey)); } else { return Optional.empty();