Dieser Commit ist enthalten in:
Ursprung
350ac8b66f
Commit
9a0b3a41b9
@ -32,14 +32,18 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class FightEndsHandler implements SpigotHandler {
|
public class FightEndsHandler implements SpigotHandler {
|
||||||
|
|
||||||
private Map<String, List<Game>> gameModeGames = new HashMap<>();
|
private Map<String, LinkedList<Game>> gameModeGames = new HashMap<>();
|
||||||
|
|
||||||
private int K = 20;
|
private int K = 20;
|
||||||
|
|
||||||
private long defaultFightRange = 1000 /* Milliseconds */ * 60 /* Seconds */ * 15L /* Minutes */;
|
private long defaultFightRange = 1000 /* Milliseconds */ * 60 /* Seconds */ * 15L /* Minutes */;
|
||||||
private Map<String, Long> fightRanges = new HashMap<>();
|
private Map<String, Long> fightRanges = new HashMap<>();
|
||||||
|
private long defaultFightCount = 1;
|
||||||
|
private Map<String, Long> fightCounts = new HashMap<>();
|
||||||
|
|
||||||
{
|
{
|
||||||
fightRanges.put("miniwargear", 1000 /* Milliseconds */ * 60 /* Seconds */ * 10L /* Minutes */);
|
fightRanges.put("miniwargear", 1000 /* Milliseconds */ * 60 /* Seconds */ * 30L /* Minutes */);
|
||||||
|
fightCounts.put("miniwargear", 3L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,6 +77,8 @@ public class FightEndsHandler implements SpigotHandler {
|
|||||||
blueResult = 0;
|
blueResult = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Die nächsten Zeilen filtern ein Fight innerhalb eines Teams nicht gewertet wird, bzw auch wenn nur Teile beider Teams im
|
||||||
|
// gleichen Team sind dieser ungewertet ist.
|
||||||
Set<Integer> teamsIds = fightEndsPacket.getBluePlayers().stream().map(SteamwarUser::get).map(SteamwarUser::getTeam).collect(Collectors.toSet());
|
Set<Integer> teamsIds = fightEndsPacket.getBluePlayers().stream().map(SteamwarUser::get).map(SteamwarUser::getTeam).collect(Collectors.toSet());
|
||||||
for (int redPlayer : fightEndsPacket.getRedPlayers()) {
|
for (int redPlayer : fightEndsPacket.getRedPlayers()) {
|
||||||
if (teamsIds.contains(SteamwarUser.get(redPlayer).getTeam())) {
|
if (teamsIds.contains(SteamwarUser.get(redPlayer).getTeam())) {
|
||||||
@ -85,7 +91,7 @@ public class FightEndsHandler implements SpigotHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
gameModeGames.computeIfAbsent(fightEndsPacket.getGameMode(), s -> new ArrayList<>()).add(new Game(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers()));
|
gameModeGames.computeIfAbsent(fightEndsPacket.getGameMode(), s -> new LinkedList<>()).add(new Game(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
|
int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
|
||||||
@ -126,7 +132,7 @@ public class FightEndsHandler implements SpigotHandler {
|
|||||||
List<Game> games = gameModeGames.get(gameMode);
|
List<Game> games = gameModeGames.get(gameMode);
|
||||||
long lifetime = fightRanges.getOrDefault(gameMode, defaultFightRange);
|
long lifetime = fightRanges.getOrDefault(gameMode, defaultFightRange);
|
||||||
games.removeIf(game -> game.livedMillis() > lifetime);
|
games.removeIf(game -> game.livedMillis() > lifetime);
|
||||||
return games.stream().anyMatch(game -> game.isSame(bluePlayers, redPlayers));
|
return games.stream().filter(game -> game.isSame(bluePlayers, redPlayers)).count() > fightCounts.getOrDefault(gameMode, defaultFightCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren