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:
parent
a10607092b
commit
ce7297afb8
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user