Set oldElo equal to new elo on new row.

This commit is contained in:
Jonathan Williams 2016-04-22 05:04:13 -05:00
parent d73b720323
commit e28621ae26

View File

@ -36,7 +36,7 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
public int getElo(Player player, int gameType) public int getElo(Player player, int gameType)
{ {
if (!Get(player).Elos.containsKey(gameType)) if (!Get(player).Elos.containsKey(gameType))
Get(player).Elos.put(gameType, 1000); return 1000;
return Get(player).Elos.get(gameType); return Get(player).Elos.get(gameType);
} }
@ -190,12 +190,24 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
// Use teams to calculate Elo // Use teams to calculate Elo
for (EloPlayer eloPlayer : teamWinnerNew.getPlayers()) for (EloPlayer eloPlayer : teamWinnerNew.getPlayers())
{ {
saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, teamWinner.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating(), eloPlayer.getRating()); int oldElo = teamWinner.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating();
// If this is the first time.
if (!Get(eloPlayer.getPlayer()).Elos.containsKey(gameId))
oldElo = eloPlayer.getRating();
saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, oldElo, eloPlayer.getRating());
} }
for (EloPlayer eloPlayer : teamLoserNew.getPlayers()) for (EloPlayer eloPlayer : teamLoserNew.getPlayers())
{ {
saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, teamLoser.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating(), eloPlayer.getRating()); int oldElo = teamLoser.getPlayer(eloPlayer.getPlayer().getUniqueId().toString()).getRating();
// If this is the first time.
if (!Get(eloPlayer.getPlayer()).Elos.containsKey(gameId))
oldElo = eloPlayer.getRating();
saveElo(eloPlayer.getPlayer(), eloPlayer.getAccountId(), gameId, oldElo, eloPlayer.getRating());
} }
_eloTeams.clear(); _eloTeams.clear();