From ce7297afb8b8df72198fd8077dd99a151c2f5210 Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Sat, 1 Mar 2025 01:15:48 +0100 Subject: [PATCH] Refactor flag point update logic for winning team. Fixed the logic for updating flag point. Ensures correct handling of winning and losing teams by directly iterating through entries. This way points are reduced if a team is no longer "winning". --- src/main/java/com/alttd/ctf/flag/Flag.java | 13 +++++++------ version.properties | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/alttd/ctf/flag/Flag.java b/src/main/java/com/alttd/ctf/flag/Flag.java index 6bc987f..4019fe0 100644 --- a/src/main/java/com/alttd/ctf/flag/Flag.java +++ b/src/main/java/com/alttd/ctf/flag/Flag.java @@ -324,12 +324,13 @@ public class Flag implements Runnable { } Team winningTeam = teamLongEntry.getKey(); - teamCounts.forEach((team, count) -> { - teamFlagPointCount.merge(team.getId(), team.equals(winningTeam) ? 1 : -1, (oldValue, delta) -> { - int updatedValue = oldValue + delta; - log.debug("Set count to {} for team {}", updatedValue, team.getId()); - return Math.max(updatedValue, 0); - }); + teamFlagPointCount.putIfAbsent(winningTeam.getId(), 0); + teamFlagPointCount.entrySet().forEach(entry -> { + if (entry.getKey().equals(winningTeam.getId())) { + entry.setValue(entry.getValue() + 1); + } else { + entry.setValue(Math.max(0, entry.getValue() - 1)); + } }); nearbyPlayers.forEach(teamPlayer -> teamPlayer.increaseStat(Stat.TIME_SPEND_CAPTURING_FLAG)); return true; diff --git a/version.properties b/version.properties index c0426d6..06fd47f 100644 --- a/version.properties +++ b/version.properties @@ -1,3 +1,3 @@ -#Sat Mar 01 00:39:55 CET 2025 -buildNumber=91 +#Sat Mar 01 01:12:24 CET 2025 +buildNumber=95 version=0.1