Elo updates
EloRanking turned on for Domination, Team Deathmatch, Turf Wars, CTF Database QoL changes made to EloManager and EloRepository --Unfortunately, Database still seems to not be updating properly --Something on my end, or something to do with the queries? Unsure.
This commit is contained in:
parent
59001bdef6
commit
9e8a7b582b
@ -1,11 +1,15 @@
|
|||||||
package mineplex.core.elo;
|
package mineplex.core.elo;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
public class EloDivision
|
public class EloDivision
|
||||||
{
|
{
|
||||||
private byte _divisionPercentile;
|
private byte _divisionPercentile;
|
||||||
|
private int _playerElo;
|
||||||
|
private UUID _uuid;
|
||||||
private String _divisionName;
|
private String _divisionName;
|
||||||
|
|
||||||
//If I understand MaterialData objects correctly,
|
//If I understand MaterialData objects correctly,
|
||||||
@ -13,24 +17,37 @@ public class EloDivision
|
|||||||
private byte _divisionMaterialValue;
|
private byte _divisionMaterialValue;
|
||||||
private MaterialData _divisionMaterialData;
|
private MaterialData _divisionMaterialData;
|
||||||
|
|
||||||
public EloDivision(byte divPercent)
|
public EloDivision(UUID userID, byte divPercent, int pElo)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated constructor stub
|
_uuid = userID;
|
||||||
_divisionPercentile = divPercent;
|
_divisionPercentile = divPercent;
|
||||||
_divisionName = CalculateDivision(divPercent);
|
_playerElo = pElo;
|
||||||
|
_divisionName = calculateDivision(divPercent, _playerElo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String CalculateDivision(double divPercent)
|
public String calculateDivision(double divPercent, int _playerElo)
|
||||||
{
|
{
|
||||||
if (divPercent == 100) return "Diamond";
|
|
||||||
if (divPercent <= 99 && divPercent >= 81) return "Emerald";
|
if (divPercent > 99 && _playerElo > 3500) { return "Diamond"; }
|
||||||
if (divPercent <= 80 && divPercent >= 61) return "Lapis";
|
if (_playerElo >= 3500) { return "Emerald 3"; }
|
||||||
if (divPercent <= 60 && divPercent >= 41) return "Gold";
|
if (_playerElo < 3500 && _playerElo >= 3300) { return "Emerald 2"; }
|
||||||
if (divPercent <= 40 && divPercent >= 21) return "Iron";
|
if (_playerElo < 3300 && _playerElo >= 3100) { return "Emerald 1"; }
|
||||||
|
if (_playerElo < 3100 && _playerElo >= 2900) { return "Lapis 3"; }
|
||||||
|
if (_playerElo < 2900 && _playerElo >= 2700) { return "Lapis 2"; }
|
||||||
|
if (_playerElo < 2700 && _playerElo >= 2500) { return "Lapis 1"; }
|
||||||
|
if (_playerElo < 2500 && _playerElo >= 2300) { return "Gold 3"; }
|
||||||
|
if (_playerElo < 2300 && _playerElo >= 2100) { return "Gold 2"; }
|
||||||
|
if (_playerElo < 2100 && _playerElo >= 1900) { return "Gold 1"; }
|
||||||
|
if (_playerElo < 1900 && _playerElo >= 1700) { return "Iron 3"; }
|
||||||
|
if (_playerElo < 1700 && _playerElo >= 1500) { return "Iron 2"; }
|
||||||
|
if (_playerElo < 1500 && _playerElo >= 1300) { return "Iron 1"; }
|
||||||
|
if (_playerElo < 1300 && _playerElo >= 800) { return "Coal 3"; }
|
||||||
|
if (_playerElo < 800 && _playerElo >= 600) { return "Coal 2"; }
|
||||||
|
if (_playerElo < 600) { return "Coal 1"; }
|
||||||
|
|
||||||
//if none of the above are true, a player is in the bottom 20%
|
//if none of the above are true, a player is in the bottom 20%
|
||||||
return "Coal";
|
return "Coal 1";
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
|
@ -2,11 +2,15 @@ package mineplex.core.elo;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mineplex.core.MiniDbClientPlugin;
|
import mineplex.core.MiniDbClientPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.serverdata.database.column.ColumnInt;
|
||||||
|
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -18,6 +22,9 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
|||||||
private EloRepository _repository;
|
private EloRepository _repository;
|
||||||
private EloRatingSystem _ratingSystem;
|
private EloRatingSystem _ratingSystem;
|
||||||
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
|
private NautHashMap<String, NautHashMap<String, Integer>> _playerElos;
|
||||||
|
private NautHashMap<String, NautHashMap<String, String>> _playerDivisions;
|
||||||
|
|
||||||
|
private EloDivision _division;
|
||||||
|
|
||||||
public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
|
public EloManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||||
{
|
{
|
||||||
@ -26,6 +33,7 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
|||||||
_repository = new EloRepository(plugin);
|
_repository = new EloRepository(plugin);
|
||||||
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
|
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
|
||||||
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
|
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getElo(UUID uuid, String gameType)
|
public int getElo(UUID uuid, String gameType)
|
||||||
@ -76,7 +84,9 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
|||||||
|
|
||||||
public void saveElo(UUID uuid, String gameType, int elo)
|
public void saveElo(UUID uuid, String gameType, int elo)
|
||||||
{
|
{
|
||||||
|
String playerDiv = getPlayerDivision(uuid, gameType);
|
||||||
saveElo(uuid.toString(), gameType, elo);
|
saveElo(uuid.toString(), gameType, elo);
|
||||||
|
saveDivision(uuid.toString(), gameType, playerDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveElo(final String uuid, final String gameType, final int elo)
|
public void saveElo(final String uuid, final String gameType, final int elo)
|
||||||
@ -85,7 +95,12 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
|||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
_repository.saveElo(uuid, gameType, elo);
|
try {
|
||||||
|
_repository.saveElo(uuid, gameType, elo);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (_playerEloLock)
|
synchronized (_playerEloLock)
|
||||||
{
|
{
|
||||||
@ -101,6 +116,83 @@ public class EloManager extends MiniDbClientPlugin<EloClientData>
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//save divisons the same way that we're saving Elos
|
||||||
|
public void saveDivision(final String uuid, final String gameType, final String division)
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
_repository.saveDivision(uuid, gameType, division);
|
||||||
|
|
||||||
|
synchronized (_playerEloLock)
|
||||||
|
{
|
||||||
|
if (_playerDivisions.containsKey(uuid))
|
||||||
|
{
|
||||||
|
if (_playerDivisions.get(uuid).containsKey(gameType))
|
||||||
|
{
|
||||||
|
_playerDivisions.get(uuid).put(gameType, division);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//get a player's Division
|
||||||
|
public String getPlayerDivision(UUID uuid, String gameType)
|
||||||
|
{
|
||||||
|
//get playerElo for gameType (need to store this to check it against other Elo's)
|
||||||
|
int playerElo = getElo(uuid, gameType);
|
||||||
|
//this list will be filled with ELO's from other players (but only for the same game type
|
||||||
|
ArrayList<Integer> allElos = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
for(int i = 0; i < _playerElos.size(); i++)
|
||||||
|
{
|
||||||
|
//we're only concerned with this Game Type
|
||||||
|
if(_playerElos.containsKey(gameType))
|
||||||
|
{
|
||||||
|
//add elo's to the list
|
||||||
|
allElos.add(_playerElos.get(uuid.toString()).get(gameType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//sort list of Elos (needed for percentile calculations)
|
||||||
|
Collections.sort(allElos);
|
||||||
|
|
||||||
|
//Calculate how much going up one spot is worth
|
||||||
|
double individualValue = (100/allElos.size());
|
||||||
|
|
||||||
|
/* lastIndexOf gets the last instance of player's Elo
|
||||||
|
* Consequently, it should be easier for rank to go up than down
|
||||||
|
* and everyone at the same Elo should be in the same division
|
||||||
|
*/
|
||||||
|
double percentile = allElos.lastIndexOf(playerElo) * individualValue;
|
||||||
|
|
||||||
|
return CalculateDivision(playerElo, percentile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String CalculateDivision(int playerElo, double divPercent)
|
||||||
|
{
|
||||||
|
if (playerElo >= 3500 && divPercent > 99) return "Diamond";
|
||||||
|
if (playerElo >= 3500) return "Emerald 3";
|
||||||
|
if (playerElo < 3500 && playerElo >= 3300) return "Emerald 2";
|
||||||
|
if (playerElo < 3300 && playerElo >= 3100) return "Emerald 1";
|
||||||
|
if (playerElo < 3100 && playerElo >= 2900) return "Lapis 3";
|
||||||
|
if (playerElo < 2900 && playerElo >= 2700) return "Lapis 2";
|
||||||
|
if (playerElo < 2700 && playerElo >= 2500) return "Lapis 1";
|
||||||
|
if (playerElo < 2500 && playerElo >= 2300) return "Gold 3";
|
||||||
|
if (playerElo < 2300 && playerElo >= 2100) return "Gold 2";
|
||||||
|
if (playerElo < 2100 && playerElo >= 1900) return "Gold 1";
|
||||||
|
if (playerElo < 1900 && playerElo >= 1700) return "Iron 3";
|
||||||
|
if (playerElo < 1700 && playerElo >= 1500) return "Iron 2";
|
||||||
|
if (playerElo < 1500 && playerElo >= 1300) return "Iron 1";
|
||||||
|
if (playerElo < 1300 && playerElo >= 800) return "Coal 3";
|
||||||
|
if (playerElo < 800 && playerElo >= 600) return "Coal 2";
|
||||||
|
if (playerElo < 600 && playerElo >= 400) return "Coal 1";
|
||||||
|
|
||||||
|
return "Result not found";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected EloClientData AddPlayer(String player)
|
protected EloClientData AddPlayer(String player)
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package mineplex.core.elo;
|
package mineplex.core.elo;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import mineplex.core.database.MinecraftRepository;
|
import mineplex.core.database.MinecraftRepository;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.mysql.jdbc.Statement;
|
||||||
|
|
||||||
import mineplex.serverdata.database.DBPool;
|
import mineplex.serverdata.database.DBPool;
|
||||||
import mineplex.serverdata.database.RepositoryBase;
|
import mineplex.serverdata.database.RepositoryBase;
|
||||||
import mineplex.serverdata.database.column.ColumnInt;
|
import mineplex.serverdata.database.column.ColumnInt;
|
||||||
@ -13,8 +16,9 @@ import mineplex.serverdata.database.column.ColumnVarChar;
|
|||||||
|
|
||||||
public class EloRepository extends MinecraftRepository
|
public class EloRepository extends MinecraftRepository
|
||||||
{
|
{
|
||||||
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, division VARCHAR(256), PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
||||||
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
||||||
|
private static String INSERT_DIVISION = "INSERT INTO eloRating (uuid, gameType, division) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE division=VALUES(division);";
|
||||||
|
|
||||||
public EloRepository(JavaPlugin plugin)
|
public EloRepository(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
@ -28,9 +32,34 @@ public class EloRepository extends MinecraftRepository
|
|||||||
//executeUpdate(CREATE_ELO_TABLE);
|
//executeUpdate(CREATE_ELO_TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveElo(String uuid, String gameType, int elo)
|
public void saveElo(String uuid, String gameType, int elo) throws SQLException
|
||||||
{
|
{
|
||||||
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo));
|
Connection con = getConnection();
|
||||||
|
java.sql.Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_UPDATABLE);
|
||||||
|
String selectQuery = "SELECT gameType, elo FROM eloRating WHERE uuid = '" + uuid + "';";
|
||||||
|
ResultSet rs = stmt.executeQuery(selectQuery);
|
||||||
|
|
||||||
|
boolean contains = false;
|
||||||
|
|
||||||
|
while (rs.next())
|
||||||
|
{
|
||||||
|
contains = true;
|
||||||
|
//update elo
|
||||||
|
String updateQuery = "UPDATE eloRating SET elo='" + elo + "';";
|
||||||
|
executeQuery(updateQuery, null, new ColumnVarChar("elo", 100, uuid));
|
||||||
|
}
|
||||||
|
if(!contains)
|
||||||
|
{
|
||||||
|
//insert elo
|
||||||
|
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnInt("elo", elo));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveDivision(String uuid, String gameType, String division)
|
||||||
|
{
|
||||||
|
executeUpdate(INSERT_ELO, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("gameType", 100, gameType), new ColumnVarChar("division", 100, division));
|
||||||
}
|
}
|
||||||
|
|
||||||
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
|
public EloClientData loadClientInformation(ResultSet resultSet) throws SQLException
|
||||||
|
@ -55,6 +55,7 @@ import mineplex.core.common.util.UtilTabTitle;
|
|||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
|
import mineplex.core.elo.EloSettings;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.packethandler.IPacketHandler;
|
import mineplex.core.packethandler.IPacketHandler;
|
||||||
import mineplex.core.packethandler.PacketInfo;
|
import mineplex.core.packethandler.PacketInfo;
|
||||||
@ -310,6 +311,9 @@ public abstract class Game implements Listener
|
|||||||
public String Winner = "Nobody";
|
public String Winner = "Nobody";
|
||||||
public GameTeam WinnerTeam = null;
|
public GameTeam WinnerTeam = null;
|
||||||
|
|
||||||
|
//EloSetting - (0 = disabled, 1 = background, 2 = full)
|
||||||
|
public EloSettings EloSetting = new EloSettings(0);
|
||||||
|
|
||||||
public boolean EloRanking = false;
|
public boolean EloRanking = false;
|
||||||
public int EloStart = 1000;
|
public int EloStart = 1000;
|
||||||
|
|
||||||
@ -1264,6 +1268,9 @@ public abstract class Game implements Listener
|
|||||||
|
|
||||||
UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20);
|
UtilTextMiddle.display(winnerText, subColor + "won the game", 20, 120, 20);
|
||||||
|
|
||||||
|
//call adjustPlayerElo
|
||||||
|
adjustPlayerElo(places);
|
||||||
|
|
||||||
if (AnnounceSilence)
|
if (AnnounceSilence)
|
||||||
Manager.GetChat().Silence(5000, false);
|
Manager.GetChat().Silence(5000, false);
|
||||||
}
|
}
|
||||||
@ -1289,6 +1296,169 @@ public abstract class Game implements Listener
|
|||||||
System.out.println("[Announcement] " + message);
|
System.out.println("[Announcement] " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//calculate the elo multiplier for a player based on the average elo of all players
|
||||||
|
public int calculateEloMultiplier(int currentElo, int averageElo)
|
||||||
|
{
|
||||||
|
|
||||||
|
int eloDifference = averageElo - currentElo;
|
||||||
|
|
||||||
|
if (Math.abs(eloDifference) <= 50)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (eloDifference >= 200)
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
if (eloDifference >= 100)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (eloDifference > 50)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (eloDifference <= -200)
|
||||||
|
{
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
if (eloDifference <= -100)
|
||||||
|
{
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
if (eloDifference < -50)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//adjust the elo's of every player, depending on their ranking in the game mode
|
||||||
|
public void adjustPlayerElo(List<Player> places)
|
||||||
|
{
|
||||||
|
int averageElo = 0;
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
averageElo += Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||||
|
}
|
||||||
|
//average Elo of all players
|
||||||
|
averageElo = averageElo/places.size();
|
||||||
|
|
||||||
|
//update Elos of all players
|
||||||
|
assignEloPoints(places, averageElo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//method to loop through every player and assign their new Elo
|
||||||
|
public void assignEloPoints(List<Player> places, int averageElo)
|
||||||
|
{
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
int currentElo = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||||
|
int lossMultiplier = 1;
|
||||||
|
int sizeModifier = 3;
|
||||||
|
int eloMultiplier = calculateEloMultiplier(currentElo, averageElo);
|
||||||
|
|
||||||
|
//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 + (5 * eloMultiplier);
|
||||||
|
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (places.size() >= 5)
|
||||||
|
{
|
||||||
|
if (player.getUniqueId() == places.get(1).getUniqueId())
|
||||||
|
{
|
||||||
|
int newElo = currentElo + 20 + (5 * eloMultiplier);
|
||||||
|
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (places.size() >= 6)
|
||||||
|
{
|
||||||
|
if (player.getUniqueId() == places.get(2).getUniqueId())
|
||||||
|
{
|
||||||
|
if (eloMultiplier < -2)
|
||||||
|
{
|
||||||
|
eloMultiplier = -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newElo = currentElo + 15 + (5 * eloMultiplier);
|
||||||
|
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (places.size() > 6 && places.size() <= 7)
|
||||||
|
{
|
||||||
|
if (player.getUniqueId() == places.get(5).getUniqueId())
|
||||||
|
{
|
||||||
|
if(eloMultiplier > 1)
|
||||||
|
{
|
||||||
|
eloMultiplier = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newElo = currentElo - 5 + (5 * eloMultiplier);
|
||||||
|
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (places.size() == 7)
|
||||||
|
{
|
||||||
|
if (player.getUniqueId() == places.get(6).getUniqueId())
|
||||||
|
{
|
||||||
|
if(eloMultiplier > 2)
|
||||||
|
{
|
||||||
|
eloMultiplier = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newElo = currentElo - 10 + (5 * eloMultiplier);
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
if(eloMultiplier > lossMultiplier)
|
||||||
|
{
|
||||||
|
eloMultiplier = lossMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newElo = currentElo - (5 * lossMultiplier) + (5 * eloMultiplier);
|
||||||
|
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), newElo);
|
||||||
|
|
||||||
|
if(sizeModifier >= 1)
|
||||||
|
{
|
||||||
|
lossMultiplier++;
|
||||||
|
sizeModifier--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lossMultiplier = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage)
|
public boolean AdvertiseText(GameLobbyManager gameLobbyManager, int _advertiseStage)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -86,6 +86,8 @@ public class Domination extends TeamGame
|
|||||||
this.WorldTimeSet = 2000;
|
this.WorldTimeSet = 2000;
|
||||||
|
|
||||||
this.DeathSpectateSecs = 10;
|
this.DeathSpectateSecs = 10;
|
||||||
|
this.EloRanking = true;
|
||||||
|
this.EloSetting.setEloSetting(2);
|
||||||
|
|
||||||
//this.QuitOut = false;
|
//this.QuitOut = false;
|
||||||
}
|
}
|
||||||
@ -330,6 +332,9 @@ public class Domination extends TeamGame
|
|||||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||||
|
|
||||||
|
//Increment Elo (in case it isn't being incremented already)
|
||||||
|
eloPlayer.Rating += 20;
|
||||||
|
|
||||||
teamWinner.addPlayer(eloPlayer);
|
teamWinner.addPlayer(eloPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,6 +346,9 @@ public class Domination extends TeamGame
|
|||||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||||
|
|
||||||
|
//Decrement Elo (in case it isn't being decremented already)
|
||||||
|
eloPlayer.Rating -= 10;
|
||||||
|
|
||||||
teamLoser.addPlayer(eloPlayer);
|
teamLoser.addPlayer(eloPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -348,11 +356,14 @@ public class Domination extends TeamGame
|
|||||||
|
|
||||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
|
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
|
||||||
{
|
{
|
||||||
|
eloPlayer.Rating += 20;
|
||||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
|
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
|
||||||
{
|
{
|
||||||
|
eloPlayer.Rating -= 10;
|
||||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.common;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -78,6 +79,8 @@ public class TeamDeathmatch extends TeamGame
|
|||||||
this.HungerSet = 20;
|
this.HungerSet = 20;
|
||||||
this.WorldTimeSet = 2000;
|
this.WorldTimeSet = 2000;
|
||||||
this.CompassEnabled = true;
|
this.CompassEnabled = true;
|
||||||
|
this.EloRanking = true;
|
||||||
|
this.EloSetting.setEloSetting(2);
|
||||||
|
|
||||||
this.Manager.GetDamage().UseSimpleWeaponDamage = false;
|
this.Manager.GetDamage().UseSimpleWeaponDamage = false;
|
||||||
|
|
||||||
@ -366,6 +369,14 @@ public class TeamDeathmatch extends TeamGame
|
|||||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||||
|
|
||||||
teamWinner.addPlayer(eloPlayer);
|
teamWinner.addPlayer(eloPlayer);
|
||||||
|
|
||||||
|
eloPlayer.Rating += 25;
|
||||||
|
|
||||||
|
Bukkit.broadcastMessage(player.getName() + " GetTeamList Elo: " + eloPlayer.Rating);
|
||||||
|
|
||||||
|
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), eloPlayer.Rating);
|
||||||
|
Bukkit.broadcastMessage(player.getName() + " Post-Save Elo: " + eloPlayer.Rating);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -373,23 +384,35 @@ public class TeamDeathmatch extends TeamGame
|
|||||||
for (Player player : team.GetPlayers(false))
|
for (Player player : team.GetPlayers(false))
|
||||||
{
|
{
|
||||||
EloPlayer eloPlayer = new EloPlayer();
|
EloPlayer eloPlayer = new EloPlayer();
|
||||||
eloPlayer.UniqueId = player.getUniqueId().toString();
|
eloPlayer.UniqueId = player.getUniqueId().toString();;
|
||||||
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||||
|
|
||||||
teamLoser.addPlayer(eloPlayer);
|
teamLoser.addPlayer(eloPlayer);
|
||||||
|
|
||||||
|
eloPlayer.Rating -= 15;
|
||||||
|
|
||||||
|
Bukkit.broadcastMessage(player.getName() + " GetTeamList Elo: " + eloPlayer.Rating);
|
||||||
|
|
||||||
|
Manager.getEloManager().saveElo(player.getUniqueId(), GetName(), eloPlayer.Rating);
|
||||||
|
Bukkit.broadcastMessage(player.getName() + " Post-Save Elo: " + eloPlayer.Rating);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
|
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
|
||||||
{
|
{
|
||||||
|
eloPlayer.Rating += 20;
|
||||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||||
|
Bukkit.broadcastMessage(eloPlayer.UniqueId + "Post-Save Elo: " + eloPlayer.Rating);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
|
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
|
||||||
{
|
{
|
||||||
|
eloPlayer.Rating -= 10;
|
||||||
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||||
|
Bukkit.broadcastMessage(eloPlayer.UniqueId + "Post-Save Elo: " + eloPlayer.Rating);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
//End
|
//End
|
||||||
|
@ -44,6 +44,9 @@ import mineplex.core.common.util.UtilGear;
|
|||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.elo.EloPlayer;
|
||||||
|
import mineplex.core.elo.EloTeam;
|
||||||
|
import mineplex.core.elo.GameResult;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -150,6 +153,8 @@ public class TurfForts extends TeamGame
|
|||||||
this.ItemPickup = false;
|
this.ItemPickup = false;
|
||||||
this.DamageSelf = false;
|
this.DamageSelf = false;
|
||||||
this.DeathSpectateSecs = 4;
|
this.DeathSpectateSecs = 4;
|
||||||
|
this.EloRanking = true;
|
||||||
|
this.EloSetting.setEloSetting(2);
|
||||||
|
|
||||||
_breakStatTracker = new BlockBreakStatTracker(this, false);
|
_breakStatTracker = new BlockBreakStatTracker(this, false);
|
||||||
|
|
||||||
@ -851,10 +856,56 @@ public class TurfForts extends TeamGame
|
|||||||
AddGems(player, 10, "Participation", false, false);
|
AddGems(player, 10, "Participation", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (EloRanking)
|
||||||
|
{
|
||||||
|
EloTeam teamWinner = new EloTeam();
|
||||||
|
EloTeam teamLoser = new EloTeam();
|
||||||
|
|
||||||
|
for (GameTeam team : GetTeamList())
|
||||||
|
{
|
||||||
|
if (WinnerTeam != null && team.equals(WinnerTeam))
|
||||||
|
{
|
||||||
|
for (Player player : WinnerTeam.GetPlayers(false))
|
||||||
|
{
|
||||||
|
EloPlayer eloPlayer = new EloPlayer();
|
||||||
|
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||||
|
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||||
|
|
||||||
|
teamWinner.addPlayer(eloPlayer);
|
||||||
|
Bukkit.broadcastMessage(player.getName() + "'s old Elo: " + eloPlayer.Rating);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Player player : team.GetPlayers(false))
|
||||||
|
{
|
||||||
|
EloPlayer eloPlayer = new EloPlayer();
|
||||||
|
eloPlayer.UniqueId = player.getUniqueId().toString();
|
||||||
|
eloPlayer.Rating = Manager.getEloManager().getElo(player.getUniqueId(), GetName());
|
||||||
|
|
||||||
|
teamLoser.addPlayer(eloPlayer);
|
||||||
|
Bukkit.broadcastMessage(player.getName() + "'s old Elo: " + eloPlayer.Rating);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamWinner, teamLoser, GameResult.Win).getPlayers())
|
||||||
|
{
|
||||||
|
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||||
|
Bukkit.broadcastMessage(eloPlayer.UniqueId + "'s new Elo: " + eloPlayer.Rating);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (EloPlayer eloPlayer : Manager.getEloManager().getNewRatings(teamLoser, teamWinner, GameResult.Loss).getPlayers())
|
||||||
|
{
|
||||||
|
Manager.getEloManager().saveElo(eloPlayer.UniqueId, GetName(), eloPlayer.Rating);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//End
|
//End
|
||||||
SetState(GameState.End);
|
SetState(GameState.End);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Long getEnemyTurfEntranceTime(Player player)
|
public Long getEnemyTurfEntranceTime(Player player)
|
||||||
{
|
{
|
||||||
return _enemyTurf.get(player);
|
return _enemyTurf.get(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user