Explorar o código

Olympiad points and rewards after Final.

Gigiikun %!s(int64=16) %!d(string=hai) anos
pai
achega
ce9d077cdf

+ 21 - 9
L2_GameServer/java/config/General.properties

@@ -465,10 +465,6 @@ AltOlyClassedRewItemCount = 50
 # Default: 30
 AltOlyNonClassedRewItemCount = 30
 
-# Minimum points needed to to exchange noblesse gate pass.
-# Default: 50
-AltOlyMinPointForExchange = 50
-
 # ItemId for this reward.
 # Default: 13722
 AltOlyCompRewItem = 13722
@@ -478,12 +474,28 @@ AltOlyCompRewItem = 13722
 AltOlyGPPerPoint = 1000
 
 # Noblesse points awarded to Heros.
-# Default: 300
-AltOlyHeroPoints = 300
+# Default: 180
+AltOlyHeroPoints = 180
+
+# Noblesse points awarded to Rank 1 members.
+# Default: 120
+AltOlyRank1Points = 120
+
+# Noblesse points awarded to Rank 2 members.
+# Default: 80
+AltOlyRank2Points = 80
 
-# Olympiad tokens awarded to Heros.
-# Default: 180000
-AltOlyHeroTokens = 180000
+# Noblesse points awarded to Rank 3 members.
+# Default: 55
+AltOlyRank3Points = 55
+
+# Noblesse points awarded to Rank 4 members.
+# Default: 35
+AltOlyRank4Points = 35
+
+# Noblesse points awarded to Rank 5 members.
+# Default: 20
+AltOlyRank5Points = 20
 
 # Hero tables show last month's winners or current status.
 # Default: True

+ 11 - 5
L2_GameServer/java/net/sf/l2j/Config.java

@@ -446,9 +446,12 @@ public final class Config
 	public static int ALT_OLY_NONCLASSED_RITEM_C;
 	public static int ALT_OLY_COMP_RITEM;
 	public static int ALT_OLY_GP_PER_POINT;
-	public static int ALT_OLY_MIN_POINT_FOR_EXCH;
 	public static int ALT_OLY_HERO_POINTS;
-	public static int ALT_OLY_HERO_TOKENS;
+	public static int ALT_OLY_RANK1_POINTS;
+	public static int ALT_OLY_RANK2_POINTS;
+	public static int ALT_OLY_RANK3_POINTS;
+	public static int ALT_OLY_RANK4_POINTS;
+	public static int ALT_OLY_RANK5_POINTS;
 	public static boolean ALT_OLY_LOG_FIGHTS;
 	public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
 	public static boolean ALT_OLY_ANNOUNCE_GAMES;
@@ -1424,9 +1427,12 @@ public final class Config
 					ALT_OLY_NONCLASSED_RITEM_C = Integer.parseInt(General.getProperty("AltOlyNonClassedRewItemCount","30"));
 					ALT_OLY_COMP_RITEM = Integer.parseInt(General.getProperty("AltOlyCompRewItem","13722"));
 					ALT_OLY_GP_PER_POINT = Integer.parseInt(General.getProperty("AltOlyGPPerPoint","1000"));
-					ALT_OLY_MIN_POINT_FOR_EXCH = Integer.parseInt(General.getProperty("AltOlyMinPointForExchange","50"));
-					ALT_OLY_HERO_POINTS = Integer.parseInt(General.getProperty("AltOlyHeroPoints","300"));
-					ALT_OLY_HERO_TOKENS = Integer.parseInt(General.getProperty("AltOlyHeroTokens","180000"));
+					ALT_OLY_HERO_POINTS = Integer.parseInt(General.getProperty("AltOlyHeroPoints","180"));
+					ALT_OLY_RANK1_POINTS = Integer.parseInt(General.getProperty("AltOlyRank1Points","120"));
+					ALT_OLY_RANK2_POINTS = Integer.parseInt(General.getProperty("AltOlyRank2Points","80"));
+					ALT_OLY_RANK3_POINTS = Integer.parseInt(General.getProperty("AltOlyRank3Points","55"));
+					ALT_OLY_RANK4_POINTS = Integer.parseInt(General.getProperty("AltOlyRank4Points","35"));
+					ALT_OLY_RANK5_POINTS = Integer.parseInt(General.getProperty("AltOlyRank5Points","20"));
 					ALT_OLY_LOG_FIGHTS = Boolean.parseBoolean(General.getProperty("AlyOlyLogFights","false"));
 					ALT_OLY_SHOW_MONTHLY_WINNERS = Boolean.parseBoolean(General.getProperty("AltOlyShowMonthlyWinners","true"));
 					ALT_OLY_ANNOUNCE_GAMES = Boolean.parseBoolean(General.getProperty("AltOlyAnnounceGames","true"));

+ 1 - 1
L2_GameServer/java/net/sf/l2j/gameserver/model/actor/instance/L2OlympiadManagerInstance.java

@@ -104,7 +104,7 @@ public class L2OlympiadManagerInstance extends L2NpcInstance
 					Olympiad.getInstance().registerNoble(player, true);
 					break;
 				case 6:
-					int passes = Olympiad.getInstance().getNoblessePasses(player.getObjectId());
+					int passes = Olympiad.getInstance().getNoblessePasses(player);
 					if (passes > 0)
 					{
 						L2ItemInstance item = player.getInventory().addItem("Olympiad", GATE_PASS, passes, player, this);

+ 94 - 26
L2_GameServer/java/net/sf/l2j/gameserver/model/olympiad/Olympiad.java

@@ -63,6 +63,7 @@ public class Olympiad
 	protected static L2FastList<StatsSet> _heroesToBe;
 	private static L2FastList<L2PcInstance> _nonClassBasedRegisters;
 	private static Map<Integer, L2FastList<L2PcInstance>> _classBasedRegisters;
+	private static Map<Integer, Integer> _noblesRank;
 	
 	private static final String OLYMPIAD_DATA_FILE = "config/olympiad.properties";
 	public static final String OLYMPIAD_HTML_PATH = "data/html/olympiad/";
@@ -79,6 +80,8 @@ public class Olympiad
 	        + "FROM olympiad_nobles, characters WHERE characters.charId = olympiad_nobles.charId "
 	        + "AND olympiad_nobles.class_id = ? AND olympiad_nobles.competitions_done >= 9 "
 	        + "ORDER BY olympiad_nobles.olympiad_points DESC, olympiad_nobles.competitions_done DESC";
+	private static final String GET_ALL_CLASSIFIED_NOBLESS = "SELECT charId from olympiad_nobles_eom "
+			+ "WHERE competitions_done >= 9 ORDER BY olympiad_points DESC, competitions_done DESC";
 	private static final String GET_EACH_CLASS_LEADER = "SELECT characters.char_name from olympiad_nobles_eom, characters "
 	        + "WHERE characters.charId = olympiad_nobles_eom.charId AND olympiad_nobles_eom.class_id = ? "
 	        + "AND olympiad_nobles_eom.competitions_done >= 9 "
@@ -203,6 +206,7 @@ public class Olympiad
 			case 1:
 				if (_validationEnd > Calendar.getInstance().getTimeInMillis())
 				{
+					loadNoblesRank();
 					_scheduledValdationTask = ThreadPoolManager.getInstance().scheduleGeneral(new ValidationEndTask(), getMillisToValidationEnd());
 				}
 				else
@@ -286,7 +290,68 @@ public class Olympiad
 		_log.info("Olympiad System: Loaded " + _nobles.size() + " Nobles");
 		
 	}
-	
+
+	public void loadNoblesRank()
+	{
+		_noblesRank = new FastMap<Integer, Integer>();
+		Map<Integer, Integer> tmpPlace = new FastMap<Integer, Integer>();
+
+		Connection con = null;
+		try
+		{
+			con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement statement = con.prepareStatement(GET_ALL_CLASSIFIED_NOBLESS);
+			ResultSet rset = statement.executeQuery();
+
+			int place = 1;
+			while (rset.next())
+			{
+				tmpPlace.put(rset.getInt(CHAR_ID), place++);
+			}
+
+			rset.close();
+			statement.close();
+		}
+		catch (Exception e)
+		{
+			_log.log(Level.WARNING, "Olympiad System: Error loading noblesse data from database for Ranking: ", e);
+		}
+		finally
+		{
+			try
+			{
+				con.close();
+			}
+			catch (Exception e)
+			{
+			}
+		}
+		int rank1 = (int) Math.round(tmpPlace.size() * 0.01);
+		int rank2 = (int) Math.round(tmpPlace.size() * 0.10);
+		int rank3 = (int) Math.round(tmpPlace.size() * 0.25);
+		int rank4 = (int) Math.round(tmpPlace.size() * 0.50);
+		if (rank1 == 0)
+		{
+			rank1 = 1;
+			rank2 ++;
+			rank3 ++;
+			rank4 ++;
+		}
+		for (int charId : tmpPlace.keySet())
+		{
+			if (tmpPlace.get(charId) <= rank1)
+				_noblesRank.put(charId, 1);
+			else if (tmpPlace.get(charId) <= rank2)
+				_noblesRank.put(charId, 2);
+			else if (tmpPlace.get(charId) <= rank3)
+				_noblesRank.put(charId, 3);
+			else if (tmpPlace.get(charId) <= rank4)
+				_noblesRank.put(charId, 4);
+			else
+				_noblesRank.put(charId, 5);
+		}
+	}
+
 	protected void init()
 	{
 		if (_period == 1)
@@ -325,7 +390,6 @@ public class Olympiad
 			
 			_period = 1;
 			sortHerosToBe();
-			giveHeroBonus();
 			Hero.getInstance().computeNewHeroes(_heroesToBe);
 			
 			saveOlympiadStatus();
@@ -334,6 +398,7 @@ public class Olympiad
 			Calendar validationEnd = Calendar.getInstance();
 			_validationEnd = validationEnd.getTimeInMillis() + VALIDATION_PERIOD;
 			
+			loadNoblesRank();
 			_scheduledValdationTask = ThreadPoolManager.getInstance().scheduleGeneral(new ValidationEndTask(), getMillisToValidationEnd());
 		}
 	}
@@ -1268,36 +1333,39 @@ public class Olympiad
 		
 	}
 	
-	protected void giveHeroBonus()
+	public int getNoblessePasses(L2PcInstance player)
 	{
-		if (_heroesToBe.isEmpty())
-			return;
+		if (_period != 1 || _noblesRank.isEmpty())
+			return 0;
 		
-		for (StatsSet hero : _heroesToBe)
-		{
-			int charId = hero.getInteger(CHAR_ID);
-			
-			StatsSet noble = _nobles.get(charId);
-			int currentPoints = noble.getInteger(POINTS);
-			currentPoints += Config.ALT_OLY_HERO_POINTS;
-			noble.set(POINTS, currentPoints);
-			
-			updateNobleStats(charId, noble);
-		}
-	}
-	
-	public int getNoblessePasses(int objId)
-	{
-		if (_period != 1 || _nobles.isEmpty())
+		int objId = player.getObjectId();
+		if (!_noblesRank.containsKey(objId))
 			return 0;
 		
 		StatsSet noble = _nobles.get(objId);
-		if (noble == null)
-			return 0;
-		int points = noble.getInteger(POINTS);
-		if (points <= Config.ALT_OLY_MIN_POINT_FOR_EXCH)
+		if (noble.getInteger(POINTS) == 0)
 			return 0;
-		
+
+		int rank = _noblesRank.get(objId);
+		int points = (player.isHero() ? Config.ALT_OLY_HERO_POINTS : 0);
+		switch(rank)
+		{
+			case 1:
+				points += Config.ALT_OLY_RANK1_POINTS;
+				break;
+			case 2:
+				points += Config.ALT_OLY_RANK2_POINTS;
+				break;
+			case 3:
+				points += Config.ALT_OLY_RANK3_POINTS;
+				break;
+			case 4:
+				points += Config.ALT_OLY_RANK4_POINTS;
+				break;
+			default:
+				points += Config.ALT_OLY_RANK5_POINTS;
+		}
+
 		noble.set(POINTS, 0);
 		updateNobleStats(objId, noble);