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".
This commit is contained in:
Teriuihi 2025-03-01 01:15:48 +01:00
parent a10607092b
commit ce7297afb8
2 changed files with 9 additions and 8 deletions

View File

@ -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;

View File

@ -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