I have 6 players, each player has a field called Karma. It can go from -1000 to 1000. If the player has 0 karma, their chances are normal, 1000 is very likely. Here is my current method of picking a special player.
List<String> players = new ArrayList<String>();
for (Player p : getOnlinePlayers() {
players.add(p.getName());
}
Player p = getPlayer(players.get(new Random().nextInt(players
.size())));
while (sherrifs.contains(p.getName())) {
p = Bukkit.getPlayer(players.get(new Random().nextInt(players
.size())));
}
special = p;
This currently does not include the karma but I was thinking of adding the player 1 time for each karma they have, but that would be really inefficient if all 6 players had 1000 karma which would mean, each name is entered 1000 times. Also this wouldn't work with -1000 karma since the name has to be entered at least once. How can I increase and decreasing the chances of a player being picked depending on their karma?