Added AdjustPlayertElo method to increment/decrement the Elo's of individual players at the end of a game. Currently calling the new method in AnnounceEnd.

This commit is contained in:
Joseph Prezioso Jr 2016-03-31 12:49:22 -04:00
parent b1c29a4fa6
commit cbb9798c35
2 changed files with 95 additions and 1 deletions

View File

@ -18,4 +18,9 @@ public class EloPlayer
_division = newDivision;
}
public void addRating(int toAdd)
{
Rating += toAdd;
}
}

View File

@ -320,7 +320,7 @@ public abstract class Game implements Listener
public EloSettings EloSetting = new EloSettings(0);
public boolean EloRanking = false;
public int EloStart = 1000;
public int EloStart = 1400;
public boolean CanAddStats = true;
public boolean CanGiveLoot = true;
@ -1272,10 +1272,99 @@ public abstract class Game implements Listener
}
UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20);
AdjustPlayerElo(places);
if (AnnounceSilence.GetOption())
Manager.GetChat().Silence(5000, false);
}
public void AdjustPlayerElo(List<Player> places)
{
for (Player player : UtilServer.getPlayers())
{
int currentElo = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
int lossMultiplier = 1;
int sizeModifier = 3;
//nobody won, add 10 points to all players
//Profitable enough see the match through to the end, but not enough for a stale-mate to be a more desirable outcome than 3rd place
if (places == null || places.isEmpty())
{
int newElo = currentElo + 10;
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
//Top 3 players get 25, 20, and 15 points, respectively
else
{
if (places.size() >= 1)
{
if (player.getUniqueId() == places.get(0).getUniqueId())
{
int newElo = currentElo + 25;
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() >= 5)
{
if (player.getUniqueId() == places.get(1).getUniqueId())
{
int newElo = currentElo + 20;
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() >= 6)
{
if (player.getUniqueId() == places.get(2).getUniqueId())
{
int newElo = currentElo + 15;
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() > 6 && places.size() <= 7)
{
if (player.getUniqueId() == places.get(5).getUniqueId())
{
int newElo = currentElo - 5;
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() == 7)
{
if (player.getUniqueId() == places.get(6).getUniqueId())
{
int newElo = currentElo - 10;
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
}
}
if (places.size() >= 8)
{
//for games with 8+ players, this if statement is just going to run 3 times to check 3 different places
while(lossMultiplier != 0)
{
if (player.getUniqueId() == places.get(places.size() - sizeModifier).getUniqueId())
{
int newElo = currentElo - (5 * lossMultiplier);
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
if(sizeModifier >= 1)
{
lossMultiplier++;
sizeModifier--;
}
else
{
lossMultiplier = 0;
}
}
}
}
}
}
}
public void Announce(String message)
{