@@ -0,0 +1,1562 @@
+package core.util;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport core.Database;%0Aimport net.dv8tion.jda.core.entities.User;%0A%0Apublic class MatchMaker %7B%0A%09%0A%09String guildId;%0A%09List%3CRanking%3E rankings = new ArrayList%3CRanking%3E();%0A%09%0A%09public MatchMaker(String guildId, List%3CUser%3E players)%7B%0A%09%09this.guildId = guildId;%0A%09%09for(User p : players)%7B%0A%09%09%09rankings.add(new Ranking(p));%0A%09%09%7D%0A%09%09calcRank();%0A%09%7D%0A%09%0A%09private void calcRank()%7B%0A%09%09for(Ranking ranking : rankings)%7B%0A%09%09%09double score = 0.0;%0A%09%09%09for(Ranking r : rankings)%7B%0A%09%09%09%09if(r != ranking)%7B%0A%09%09%09%09%09Double pickDiff = Database.queryGetPickOrderDiff(Long.valueOf(guildId), ranking.player.getIdLong(), r.player.getIdLong());%0A%0A%09%09%09%09%09if(pickDiff %3E 0)%7B%0A%09%09%09%09%09%09score += pickDiff;%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09ranking.score = (int)(score * 100);%0A%09%09%7D%0A%09%7D%0A%09%0A%09public User getMatch(User captain)%7B%0A%09%09Ranking captainRanking = getRanking(captain);%0A%09%09Ranking closestMatch = null;%0A%09%09%0A%09%09for(Ranking r : rankings)%7B%0A%09%09%09if(r != captainRanking)%7B%0A%09%09%09%09if(closestMatch != null)%7B%0A%09%09%09%09%09if(captainRanking.getDifference(r) %3E r.score)%7B%0A%09%09%09%09%09%09closestMatch = r;%0A%09%09%09%09%09%7D%0A%09%09%09%09%7Delse%7B%0A%09%09%09%09%09closestMatch = r;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return closestMatch.player;%0A%09%7D%0A%09%0A%09private Ranking getRanking(User player)%7B%0A%09%09for(Ranking ranking : rankings)%7B%0A%09%09%09if(ranking.player == player)%7B%0A%09%09%09%09return ranking;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return null;%0A%09%7D%0A%09%0A%09private class Ranking%7B%0A%09%09private User player;%0A%09%09private Integer score;%0A%09%09%0A%09%09public Ranking(User player)%7B%0A%09%09%09this.player = player;%0A%09%09%09this.score = 0;%0A%09%09%7D%0A%09%09%0A%09%09private Integer getDifference(Ranking r)%7B%0A%09%09%09return Math.abs(score - r.score);%0A%09%09%7D%0A%09%7D%0A%7D%0A

Create first matchmaking implementation for captains