use of com.faforever.client.main.event.Open1v1Event in project downlords-faf-client by FAForever.
the class MainController method onMatchmakerMessage.
private void onMatchmakerMessage(MatchmakerMessage message) {
if (message.getQueues() == null || gameService.gameRunningProperty().get() || !preferencesService.getPreferences().getNotification().getLadder1v1ToastEnabled() || !playerService.getCurrentPlayer().isPresent()) {
return;
}
Player currentPlayer = playerService.getCurrentPlayer().get();
int deviationFor80PercentQuality = (int) (ratingBeta / 2.5f);
int deviationFor75PercentQuality = (int) (ratingBeta / 1.25f);
float leaderboardRatingDeviation = currentPlayer.getLeaderboardRatingDeviation();
Function<MatchmakerMessage.MatchmakerQueue, List<RatingRange>> ratingRangesSupplier;
if (leaderboardRatingDeviation <= deviationFor80PercentQuality) {
ratingRangesSupplier = MatchmakerMessage.MatchmakerQueue::getBoundary80s;
} else if (leaderboardRatingDeviation <= deviationFor75PercentQuality) {
ratingRangesSupplier = MatchmakerMessage.MatchmakerQueue::getBoundary75s;
} else {
return;
}
float leaderboardRatingMean = currentPlayer.getLeaderboardRatingMean();
boolean showNotification = false;
for (MatchmakerMessage.MatchmakerQueue matchmakerQueue : message.getQueues()) {
if (!Objects.equals("ladder1v1", matchmakerQueue.getQueueName())) {
continue;
}
List<RatingRange> ratingRanges = ratingRangesSupplier.apply(matchmakerQueue);
for (RatingRange ratingRange : ratingRanges) {
if (ratingRange.getMin() <= leaderboardRatingMean && leaderboardRatingMean <= ratingRange.getMax()) {
showNotification = true;
break;
}
}
}
if (!showNotification) {
return;
}
notificationService.addNotification(new TransientNotification(i18n.get("ranked1v1.notification.title"), i18n.get("ranked1v1.notification.message"), uiService.getThemeImage(UiService.LADDER_1V1_IMAGE), event -> eventBus.post(new Open1v1Event())));
}
Aggregations