I want to make a java application, which is addressed for an esports competition. Specifically this application will be for a teamspeak server.
I want users on a channel to be sorted into groups of 5 (they will be identified by a uniqid and a number representing the skill level).
Thus, when 5 users are between skill levels 1 - 3 to be placed in one group, the next ones in another group (each of 5), and until that list / map will no longer be able to be made groups of 5.
Can you help me with an idea? I know how to get the uniqid from the teamspeak server, as well as the skill level, but I don't know how to randomly group them and meet that skill level condition.
I tried a hashmap but it failed.
HashMap<Integer, Integer> teams = new HashMap<>();
for(Client c : api.getClients()){
if(c.getChannelId() == 2170){
if(api.getChannelByNameExact("[LOBBY] Cauta echipa",true).getTotalClients() >= 5) {
if (c.isInServerGroup(Integer.parseInt(Configuration.info().getProperty("SILVER1")))) {
teams.put(c.getId(), 1);
}
if (c.isInServerGroup(Integer.parseInt(Configuration.info().getProperty("SILVER2")))) {
teams.put(c.getId(), 2);
}
if (c.isInServerGroup(Integer.parseInt(Configuration.info().getProperty("SILVER3")))) {
teams.put(c.getId(), 3);
}
if (c.isInServerGroup(Integer.parseInt(Configuration.info().getProperty("SILVER4")))) {
teams.put(c.getId(), 4);
}
if (c.isInServerGroup(Integer.parseInt(Configuration.info().getProperty("SILVERE")))) {
teams.put(c.getId(), 5);
}
while(teams.size() >= 5){
teams.forEach((key, value) -> {
System.out.println("Key : " + key + " Value : " +value);
if(value > 1 && value < 5){
teams.
}
});
}
teams.clear();
}
}
}
Exemple:
If on a teamspeak channel there are 20 people with skill level in 1 lvl -18 lvl, the robot will build teams of 5 members with similar skill level (with a margin of + - 1 level). For example, if I have skill level 5, and on the channel there are at least 4 people with skill level between 3-5, the 5 people (including myself) will be added to a list or array or whatever. After we made the team of 5 people, the program will continue to run and form teams of 5 people with similar skill level, until it will no longer be possible (there will be no 5 people in the main room).
Also you can try to manage with databases MongoDB: 1.Create two datas: high and low level 2. With Pagebale create page items on page 5; number of page will be your group number. Use method unsorted