浏览代码

BETA: Olympiad:
* Noblesse characters are now bound by a set number of matches they can join per week:
* Maximum number of matches a Noblesse character can join per week: 70
* Maximum number of Class-Irrelevant Individual matches a character can join per week: 60
* Maximum number of Class Individual matches a character can join per week: 30
* Maximum number of Class-Irrelevant Team matches a character can join per week: 10
* This maximum number resets at the beginning of each Olympiad cycle.
'''Note:'''
* Thanks '''osiride'''.
* Minor fixes by Zoey76:
1. olympiad_nobles and olympiad_nobles_eom fields changed from decimal to integer;
1. less code for some SystemMessages.
1. cleanup and code refactoring.

Zoey76 13 年之前
父节点
当前提交
21eb12e83b

+ 17 - 1
L2J_Server_BETA/dist/game/config/olympiad.properties

@@ -141,4 +141,20 @@ AltOlyWaitTime = 120
 # Divider for points in classed and non-classed games
 # Default: 5, 5
 AltOlyDividerClassed = 5
-AltOlyDividerNonClassed = 5
+AltOlyDividerNonClassed = 5
+
+# Maximum number of matches a Noblesse character can join per week
+# Default: 70
+AltOlyMaxWeeklyMatches = 70
+
+# Maximum number of Class-Irrelevant Individual matches a character can join per week
+# Default: 60
+AltOlyMaxWeeklyMatchesNonClassed = 60
+
+# Maximum number of Class Individual matches a character can join per week
+# Default: 30
+AltOlyMaxWeeklyMatchesClassed = 30
+
+# Maximum number of Class-Irrelevant Team matches a character can join per week
+# Default: 10
+AltOlyMaxWeeklyMatchesTeam = 10

+ 8 - 0
L2J_Server_BETA/java/com/l2jserver/Config.java

@@ -562,6 +562,10 @@ public final class Config
 	public static int ALT_OLY_MAX_POINTS;
 	public static int ALT_OLY_DIVIDER_CLASSED;
 	public static int ALT_OLY_DIVIDER_NON_CLASSED;
+	public static int ALT_OLY_MAX_WEEKLY_MATCHES;
+	public static int ALT_OLY_MAX_WEEKLY_MATCHES_NON_CLASSED;
+	public static int ALT_OLY_MAX_WEEKLY_MATCHES_CLASSED;
+	public static int ALT_OLY_MAX_WEEKLY_MATCHES_TEAM;
 	public static boolean ALT_OLY_LOG_FIGHTS;
 	public static boolean ALT_OLY_SHOW_MONTHLY_WINNERS;
 	public static boolean ALT_OLY_ANNOUNCE_GAMES;
@@ -2697,6 +2701,10 @@ public final class Config
 					ALT_OLY_MAX_POINTS = Integer.parseInt(olympiad.getProperty("AltOlyMaxPoints","10"));
 					ALT_OLY_DIVIDER_CLASSED = Integer.parseInt(olympiad.getProperty("AltOlyDividerClassed","5"));
 					ALT_OLY_DIVIDER_NON_CLASSED = Integer.parseInt(olympiad.getProperty("AltOlyDividerNonClassed","5"));
+					ALT_OLY_MAX_WEEKLY_MATCHES = Integer.parseInt(olympiad.getProperty("AltOlyMaxWeeklyMatches","70"));
+					ALT_OLY_MAX_WEEKLY_MATCHES_NON_CLASSED = Integer.parseInt(olympiad.getProperty("AltOlyMaxWeeklyMatchesNonClassed","60"));
+					ALT_OLY_MAX_WEEKLY_MATCHES_CLASSED = Integer.parseInt(olympiad.getProperty("AltOlyMaxWeeklyMatchesClassed","30"));
+					ALT_OLY_MAX_WEEKLY_MATCHES_TEAM = Integer.parseInt(olympiad.getProperty("AltOlyMaxWeeklyMatchesTeam","10"));
 					ALT_OLY_LOG_FIGHTS = Boolean.parseBoolean(olympiad.getProperty("AltOlyLogFights","false"));
 					ALT_OLY_SHOW_MONTHLY_WINNERS = Boolean.parseBoolean(olympiad.getProperty("AltOlyShowMonthlyWinners","true"));
 					ALT_OLY_ANNOUNCE_GAMES = Boolean.parseBoolean(olympiad.getProperty("AltOlyAnnounceGames","true"));

+ 6 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/AbstractOlympiadGame.java

@@ -57,6 +57,10 @@ public abstract class AbstractOlympiadGame
 	protected static final String COMP_WON = "competitions_won";
 	protected static final String COMP_LOST = "competitions_lost";
 	protected static final String COMP_DRAWN = "competitions_drawn";
+	protected static final String COMP_DONE_WEEK = "competitions_done_week";
+	protected static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+	protected static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+	protected static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
 
 	protected long _startTime = 0;
 	protected boolean _aborted = false;
@@ -453,4 +457,6 @@ public abstract class AbstractOlympiadGame
 	protected abstract int getDivider();
 
 	protected abstract int[][] getReward();
+	
+	protected abstract String getWeeklyMatchType();
 }

+ 172 - 73
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/Olympiad.java

@@ -70,13 +70,14 @@ public class Olympiad
 		+ "validation_end=?, next_weekly_change=?";
 	private static final String OLYMPIAD_LOAD_NOBLES = "SELECT olympiad_nobles.charId, olympiad_nobles.class_id, "
 		+ "characters.char_name, olympiad_nobles.olympiad_points, olympiad_nobles.competitions_done, "
-		+ "olympiad_nobles.competitions_won, olympiad_nobles.competitions_lost, olympiad_nobles.competitions_drawn "
+		+ "olympiad_nobles.competitions_won, olympiad_nobles.competitions_lost, olympiad_nobles.competitions_drawn, "
+		+ "olympiad_nobles.competitions_done_week, olympiad_nobles.competitions_done_week_classed, olympiad_nobles.competitions_done_week_non_classed, olympiad_nobles.competitions_done_week_team "
 		+ "FROM olympiad_nobles, characters WHERE characters.charId = olympiad_nobles.charId";
 	private static final String OLYMPIAD_SAVE_NOBLES = "INSERT INTO olympiad_nobles "
 		+ "(`charId`,`class_id`,`olympiad_points`,`competitions_done`,`competitions_won`,`competitions_lost`,"
-		+ "`competitions_drawn`) VALUES (?,?,?,?,?,?,?)";
+		+ "`competitions_drawn`, `competitions_done_week`, `competitions_done_week_classed`, `competitions_done_week_non_classed`, `competitions_done_week_team`) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
 	private static final String OLYMPIAD_UPDATE_NOBLES = "UPDATE olympiad_nobles SET "
-		+ "olympiad_points = ?, competitions_done = ?, competitions_won = ?, competitions_lost = ?, competitions_drawn = ? WHERE charId = ?";
+		+ "olympiad_points = ?, competitions_done = ?, competitions_won = ?, competitions_lost = ?, competitions_drawn = ?, competitions_done_week = ?, competitions_done_week_classed = ?, competitions_done_week_non_classed = ?, competitions_done_week_team = ? WHERE charId = ?";
 	private static final String OLYMPIAD_GET_HEROS = "SELECT olympiad_nobles.charId, characters.char_name "
 		+ "FROM olympiad_nobles, characters WHERE characters.charId = olympiad_nobles.charId "
 		+ "AND olympiad_nobles.class_id = ? AND olympiad_nobles.competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " AND olympiad_nobles.competitions_won > 0 "
@@ -102,7 +103,7 @@ public class Olympiad
 	
 	private static final String OLYMPIAD_DELETE_ALL = "TRUNCATE olympiad_nobles";
 	private static final String OLYMPIAD_MONTH_CLEAR = "TRUNCATE olympiad_nobles_eom";
-	private static final String OLYMPIAD_MONTH_CREATE = "INSERT INTO olympiad_nobles_eom SELECT * FROM olympiad_nobles";
+	private static final String OLYMPIAD_MONTH_CREATE = "INSERT INTO olympiad_nobles_eom SELECT charId, class_id, olympiad_points, competitions_done, competitions_won, competitions_lost, competitions_drawn FROM olympiad_nobles";
 	private static final int[] HERO_IDS = { 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
 		104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 131, 132, 133, 134 };
 	
@@ -123,6 +124,10 @@ public class Olympiad
 	public static final String COMP_WON = "competitions_won";
 	public static final String COMP_LOST = "competitions_lost";
 	public static final String COMP_DRAWN = "competitions_drawn";
+	public static final String COMP_DONE_WEEK = "competitions_done_week";
+	public static final String COMP_DONE_WEEK_CLASSED = "competitions_done_week_classed";
+	public static final String COMP_DONE_WEEK_NON_CLASSED = "competitions_done_week_non_classed";
+	public static final String COMP_DONE_WEEK_TEAM = "competitions_done_week_team";
 	
 	protected long _olympiadEnd;
 	protected long _validationEnd;
@@ -275,6 +280,10 @@ public class Olympiad
 				statData.set(COMP_WON, rset.getInt(COMP_WON));
 				statData.set(COMP_LOST, rset.getInt(COMP_LOST));
 				statData.set(COMP_DRAWN, rset.getInt(COMP_DRAWN));
+				statData.set(COMP_DONE_WEEK, rset.getInt(COMP_DONE_WEEK));
+				statData.set(COMP_DONE_WEEK_CLASSED, rset.getInt(COMP_DONE_WEEK_CLASSED));
+				statData.set(COMP_DONE_WEEK_NON_CLASSED, rset.getInt(COMP_DONE_WEEK_NON_CLASSED));
+				statData.set(COMP_DONE_WEEK_TEAM, rset.getInt(COMP_DONE_WEEK_TEAM));
 				statData.set("to_save", false);
 				
 				_nobles.put(charId, statData);
@@ -641,6 +650,8 @@ public class Olympiad
 			{
 				addWeeklyPoints();
 				_log.info("Olympiad System: Added weekly points to nobles");
+				resetWeeklyMatches();
+				_log.info("Olympiad System: Reset weekly matches to nobles");
 				
 				Calendar nextChange = Calendar.getInstance();
 				_nextWeeklyChange = nextChange.getTimeInMillis() + WEEKLY_PERIOD;
@@ -664,6 +675,26 @@ public class Olympiad
 		}
 	}
 	
+	/**
+	 * Resets number of matches, classed matches, non classed matches, team matches done by noble characters in the week.
+	 */
+	protected synchronized void resetWeeklyMatches()
+	{
+		if (_period == 1)
+			return;
+		
+		for (Integer nobleId : _nobles.keySet())
+		{
+			StatsSet nobleInfo = _nobles.get(nobleId);
+			nobleInfo.set(COMP_DONE_WEEK, 0);
+			nobleInfo.set(COMP_DONE_WEEK_CLASSED, 0);
+			nobleInfo.set(COMP_DONE_WEEK_NON_CLASSED, 0);
+			nobleInfo.set(COMP_DONE_WEEK_TEAM, 0);
+			
+			updateNobleStats(nobleId, nobleInfo);
+		}
+	}
+	
 	public int getCurrentCycle()
 	{
 		return _currentCycle;
@@ -687,8 +718,7 @@ public class Olympiad
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement;
-			
-			for (Integer nobleId : _nobles.keySet())
+			for (int nobleId : _nobles.keySet())
 			{
 				StatsSet nobleInfo = _nobles.get(nobleId);
 				
@@ -702,6 +732,10 @@ public class Olympiad
 				int compWon = nobleInfo.getInteger(COMP_WON);
 				int compLost = nobleInfo.getInteger(COMP_LOST);
 				int compDrawn = nobleInfo.getInteger(COMP_DRAWN);
+				int compDoneWeek = nobleInfo.getInteger(COMP_DONE_WEEK);
+				int compDoneWeekClassed = nobleInfo.getInteger(COMP_DONE_WEEK_CLASSED);
+				int compDoneWeekNonClassed = nobleInfo.getInteger(COMP_DONE_WEEK_NON_CLASSED);
+				int compDoneWeekTeam = nobleInfo.getInteger(COMP_DONE_WEEK_TEAM);
 				boolean toSave = nobleInfo.getBool("to_save");
 				
 				if (toSave)
@@ -714,6 +748,10 @@ public class Olympiad
 					statement.setInt(5, compWon);
 					statement.setInt(6, compLost);
 					statement.setInt(7, compDrawn);
+					statement.setInt(8, compDoneWeek);
+					statement.setInt(9, compDoneWeekClassed);
+					statement.setInt(10, compDoneWeekNonClassed);
+					statement.setInt(11, compDoneWeekTeam);
 					
 					nobleInfo.set("to_save", false);
 					
@@ -727,7 +765,11 @@ public class Olympiad
 					statement.setInt(3, compWon);
 					statement.setInt(4, compLost);
 					statement.setInt(5, compDrawn);
-					statement.setInt(6, charId);
+					statement.setInt(6, compDoneWeek);
+					statement.setInt(7, compDoneWeekClassed);
+					statement.setInt(8, compDoneWeekNonClassed);
+					statement.setInt(9, compDoneWeekTeam);
+					statement.setInt(10, charId);
 				}
 				statement.execute();
 				statement.close();
@@ -754,7 +796,7 @@ public class Olympiad
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(OLYMPIAD_SAVE_DATA);
+			final PreparedStatement statement = con.prepareStatement(OLYMPIAD_SAVE_DATA);
 			
 			statement.setInt(1, _currentCycle);
 			statement.setInt(2, _period);
@@ -814,9 +856,7 @@ public class Olympiad
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement;
-			
-			statement = con.prepareStatement(OLYMPIAD_MONTH_CLEAR);
+			PreparedStatement statement = con.prepareStatement(OLYMPIAD_MONTH_CLEAR);
 			statement.execute();
 			statement.close();
 			statement = con.prepareStatement(OLYMPIAD_MONTH_CREATE);
@@ -865,7 +905,6 @@ public class Olympiad
 		_heroesToBe = new L2FastList<StatsSet>();
 		
 		Connection con = null;
-		
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
@@ -976,22 +1015,17 @@ public class Olympiad
 		{
 			L2DatabaseFactory.close(con);
 		}
-		
 	}
 	
 	public L2FastList<String> getClassLeaderBoard(int classId)
 	{
 		// if (_period != 1) return;
-		
-		L2FastList<String> names = new L2FastList<String>();
-		
+		final L2FastList<String> names = new L2FastList<>();
 		Connection con = null;
-		
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement;
-			ResultSet rset;
+			final PreparedStatement statement;
 			if (Config.ALT_OLY_SHOW_MONTHLY_WINNERS)
 			{
 				if(classId == 132)
@@ -1007,45 +1041,39 @@ public class Olympiad
 					statement = con.prepareStatement(GET_EACH_CLASS_LEADER_CURRENT);
 			}
 			statement.setInt(1, classId);
-			rset = statement.executeQuery();
-			
+			final ResultSet rset = statement.executeQuery();
 			while (rset.next())
 			{
 				names.add(rset.getString(CHAR_NAME));
 			}
-			
 			statement.close();
 			rset.close();
-			
-			return names;
 		}
 		catch (SQLException e)
 		{
-			_log.warning("Olympiad System: Couldnt load olympiad leaders from DB");
+			_log.warning("Olympiad System: Couldn't load olympiad leaders from DB!");
 		}
 		finally
 		{
 			L2DatabaseFactory.close(con);
 		}
-		
 		return names;
-		
 	}
 	
 	public int getNoblessePasses(L2PcInstance player, boolean clear)
 	{
-		if (_period != 1 || _noblesRank.isEmpty())
+		if ((player == null) || (_period != 1) || _noblesRank.isEmpty())
 			return 0;
 		
-		int objId = player.getObjectId();
+		final int objId = player.getObjectId();
 		if (!_noblesRank.containsKey(objId))
 			return 0;
 		
-		StatsSet noble = _nobles.get(objId);
-		if (noble.getInteger(POINTS) == 0)
+		final StatsSet noble = _nobles.get(objId);
+		if ((noble == null) || (noble.getInteger(POINTS) == 0))
 			return 0;
 		
-		int rank = _noblesRank.get(objId);
+		final int rank = _noblesRank.get(objId);
 		int points = (player.isHero() ? Config.ALT_OLY_HERO_POINTS : 0);
 		switch (rank)
 		{
@@ -1070,23 +1098,15 @@ public class Olympiad
 			noble.set(POINTS, 0);
 			updateNobleStats(objId, noble);
 		}
-		
 		points *= Config.ALT_OLY_GP_PER_POINT;
-		
 		return points;
 	}
 	
 	public int getNoblePoints(int objId)
 	{
-		if (_nobles.isEmpty())
-			return 0;
-		
-		StatsSet noble = _nobles.get(objId);
-		if (noble == null)
+		if ((_nobles == null) || !_nobles.containsKey(objId))
 			return 0;
-		int points = noble.getInteger(POINTS);
-		
-		return points;
+		return _nobles.get(objId).getInteger(POINTS);
 	}
 	
 	public int getLastNobleOlympiadPoints(int objId)
@@ -1096,10 +1116,9 @@ public class Olympiad
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement;
-			statement = con.prepareStatement("SELECT olympiad_points FROM olympiad_nobles_eom WHERE charId = ?");
+			final PreparedStatement statement = con.prepareStatement("SELECT olympiad_points FROM olympiad_nobles_eom WHERE charId = ?");
 			statement.setInt(1, objId);
-			ResultSet rs = statement.executeQuery();
+			final ResultSet rs = statement.executeQuery();
 			if (rs.first())
 				result = rs.getInt(1);
 			rs.close();
@@ -1113,71 +1132,151 @@ public class Olympiad
 		{
 			L2DatabaseFactory.close(con);
 		}
-		
 		return result;
 	}
 	
 	public int getCompetitionDone(int objId)
 	{
-		if (_nobles.isEmpty())
-			return 0;
-		
-		StatsSet noble = _nobles.get(objId);
-		if (noble == null)
+		if ((_nobles == null) || !_nobles.containsKey(objId))
 			return 0;
-		int points = noble.getInteger(COMP_DONE);
-		
-		return points;
+		return _nobles.get(objId).getInteger(COMP_DONE);
 	}
 	
 	public int getCompetitionWon(int objId)
 	{
-		if (_nobles.isEmpty())
+		if ((_nobles == null) || !_nobles.containsKey(objId))
 			return 0;
-		
-		StatsSet noble = _nobles.get(objId);
-		if (noble == null)
-			return 0;
-		int points = noble.getInteger(COMP_WON);
-		
-		return points;
+		return _nobles.get(objId).getInteger(COMP_WON);
 	}
 	
 	public int getCompetitionLost(int objId)
 	{
-		if (_nobles.isEmpty())
+		if ((_nobles == null) || !_nobles.containsKey(objId))
 			return 0;
-		
-		StatsSet noble = _nobles.get(objId);
-		if (noble == null)
+		return _nobles.get(objId).getInteger(COMP_LOST);
+	}
+	
+	/**
+	 * Gets how many matches a noble character did in the week
+	 * @param objId		id of a noble character
+	 * @return			number of weekly competitions done
+	 * @see				#getRemainingWeeklyMatches(int)
+	 */
+	public int getCompetitionDoneWeek(int objId)
+	{
+		if ((_nobles == null) || !_nobles.containsKey(objId))
 			return 0;
-		int points = noble.getInteger(COMP_LOST);
-		
-		return points;
+		return _nobles.get(objId).getInteger(COMP_DONE_WEEK);
+	}
+	
+	/**
+	 * Gets how many classed matches a noble character did in the week
+	 * @param objId		id of a noble character
+	 * @return			number of weekly <i>classed</i> competitions done
+	 * @see				#getRemainingWeeklyMatchesClassed(int)
+	 */
+	public int getCompetitionDoneWeekClassed(int objId)
+	{
+		if ((_nobles == null) || !_nobles.containsKey(objId))
+			return 0;
+		return _nobles.get(objId).getInteger(COMP_DONE_WEEK_CLASSED);
+	}
+	
+	/**
+	 * Gets how many non classed matches a noble character did in the week
+	 * @param objId		id of a noble character
+	 * @return			number of weekly <i>non classed</i> competitions done
+	 * @see				#getRemainingWeeklyMatchesNonClassed(int)
+	 */
+	public int getCompetitionDoneWeekNonClassed(int objId)
+	{
+		if ((_nobles == null) || !_nobles.containsKey(objId))
+			return 0;
+		return _nobles.get(objId).getInteger(COMP_DONE_WEEK_NON_CLASSED);
+	}
+	
+	/**
+	 * Gets how many team matches a noble character did in the week
+	 * @param objId		id of a noble character
+	 * @return			number of weekly <i>team</i> competitions done
+	 * @see				#getRemainingWeeklyMatchesTeam(int)
+	 */
+	public int getCompetitionDoneWeekTeam(int objId)
+	{
+		if ((_nobles == null) || !_nobles.containsKey(objId))
+			return 0;
+		return _nobles.get(objId).getInteger(COMP_DONE_WEEK_TEAM);
+	}
+	
+	/**
+	 * Number of remaining matches a noble character can join in the week
+	 * @param objId		id of a noble character
+	 * @return 			difference between maximum allowed weekly matches and currently done weekly matches.
+	 * @see				#getCompetitionDoneWeek(int)
+	 * @see				Config#ALT_OLY_MAX_WEEKLY_MATCHES
+	 */
+	public int getRemainingWeeklyMatches(int objId)
+	{
+		return Math.max(Config.ALT_OLY_MAX_WEEKLY_MATCHES - getCompetitionDoneWeek(objId), 0);
+	}
+	
+	/**
+	 * Number of remaining <i>classed</i> matches a noble character can join in the week 
+	 * @param objId		id of a noble character
+	 * @return			difference between maximum allowed weekly classed matches and currently done weekly classed matches.
+	 * @see				#getCompetitionDoneWeekClassed(int)
+	 * @see				Config#ALT_OLY_MAX_WEEKLY_MATCHES_CLASSED
+	 */
+	public int getRemainingWeeklyMatchesClassed(int objId)
+	{
+		return Math.max(Config.ALT_OLY_MAX_WEEKLY_MATCHES_CLASSED - getCompetitionDoneWeekClassed(objId), 0);
+	}
+	
+	/**
+	 * Number of remaining <i>non classed</i> matches a noble character can join in the week
+	 * @param objId		id of a noble character
+	 * @return			difference between maximum allowed weekly non classed matches and currently done weekly non classed matches.
+	 * @see				#getCompetitionDoneWeekNonClassed(int) 
+	 * @see				Config#ALT_OLY_MAX_WEEKLY_MATCHES_NON_CLASSED
+	 */
+	public int getRemainingWeeklyMatchesNonClassed(int objId)
+	{
+		return Math.max(Config.ALT_OLY_MAX_WEEKLY_MATCHES_NON_CLASSED - getCompetitionDoneWeekNonClassed(objId), 0);
+	}
+	
+	/**
+	 * Number of remaining <i>team</i> matches a noble character can join in the week
+	 * @param objId		id of a noble character
+	 * @return			difference between maximum allowed weekly team matches and currently done weekly team matches.
+	 * @see				#getCompetitionDoneWeekTeam(int)
+	 * @see				Config#ALT_OLY_MAX_WEEKLY_MATCHES_TEAM
+	 */
+	public int getRemainingWeeklyMatchesTeam(int objId)
+	{
+		return Math.max(Config.ALT_OLY_MAX_WEEKLY_MATCHES_TEAM - getCompetitionDoneWeekTeam(objId), 0);
 	}
 	
 	protected void deleteNobles()
 	{
 		Connection con = null;
-		
 		try
 		{
 			con = L2DatabaseFactory.getInstance().getConnection();
-			PreparedStatement statement = con.prepareStatement(OLYMPIAD_DELETE_ALL);
+			final PreparedStatement statement = con.prepareStatement(OLYMPIAD_DELETE_ALL);
 			statement.execute();
 			statement.close();
 		}
 		catch (SQLException e)
 		{
-			_log.warning("Olympiad System: Couldnt delete nobles from DB");
+			_log.warning("Olympiad System: Couldn't delete nobles from DB!");
 		}
 		finally
 		{
 			L2DatabaseFactory.close(con);
 		}
-		
 		_nobles.clear();
 	}
+	
 	@SuppressWarnings("synthetic-access")
 	private static class SingletonHolder
 	{

+ 6 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadGameClassed.java

@@ -48,6 +48,12 @@ public class OlympiadGameClassed extends OlympiadGameNormal
 	{
 		return Config.ALT_OLY_CLASSED_REWARD;
 	}
+	
+	@Override
+	protected final String getWeeklyMatchType()
+	{
+		return COMP_DONE_WEEK_CLASSED;
+	}
 
 	protected static final OlympiadGameClassed createGame(int id, List<List<Integer>> classList)
 	{

+ 6 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadGameNonClassed.java

@@ -48,6 +48,12 @@ public class OlympiadGameNonClassed extends OlympiadGameNormal
 		return Config.ALT_OLY_NONCLASSED_REWARD;
 	}
 
+	@Override
+	protected final String getWeeklyMatchType()
+	{
+		return COMP_DONE_WEEK_NON_CLASSED;
+	}
+	
 	protected static final OlympiadGameNonClassed createGame(int id, List<Integer> list)
 	{
 		final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);

+ 8 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadGameNormal.java

@@ -420,6 +420,10 @@ abstract public class OlympiadGameNormal extends AbstractOlympiadGame
 
 				_playerOne.updateStat(COMP_DONE, 1);
 				_playerTwo.updateStat(COMP_DONE, 1);
+				_playerOne.updateStat(COMP_DONE_WEEK, 1);
+				_playerTwo.updateStat(COMP_DONE_WEEK, 1);
+				_playerOne.updateStat(getWeeklyMatchType(), 1);
+				_playerTwo.updateStat(getWeeklyMatchType(), 1);
 				
 				_playerOne.updateNobleStats();
 				_playerTwo.updateNobleStats();
@@ -523,6 +527,10 @@ abstract public class OlympiadGameNormal extends AbstractOlympiadGame
 
 			_playerOne.updateStat(COMP_DONE, 1);
 			_playerTwo.updateStat(COMP_DONE, 1);
+			_playerOne.updateStat(COMP_DONE_WEEK, 1);
+			_playerTwo.updateStat(COMP_DONE_WEEK, 1);
+			_playerOne.updateStat(getWeeklyMatchType(), 1);
+			_playerTwo.updateStat(getWeeklyMatchType(), 1);
 			
 			_playerOne.updateNobleStats();
 			_playerTwo.updateNobleStats();

+ 14 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadGameTeams.java

@@ -184,6 +184,12 @@ public class OlympiadGameTeams extends AbstractOlympiadGame
 	{
 		return Config.ALT_OLY_TEAM_REWARD;
 	}
+	
+	@Override
+	protected final String getWeeklyMatchType()
+	{
+		return COMP_DONE_WEEK_TEAM;
+	}
 
 	@Override
 	public final boolean containsParticipant(int playerId)
@@ -676,6 +682,8 @@ public class OlympiadGameTeams extends AbstractOlympiadGame
 				{
 					par = _teamOne[i];
 					par.updateStat(COMP_DONE, 1);
+					par.updateStat(COMP_DONE_WEEK, 1);
+					par.updateStat(getWeeklyMatchType(), 1);
 					par.updateNobleStats();
 				}
 
@@ -683,6 +691,8 @@ public class OlympiadGameTeams extends AbstractOlympiadGame
 				{
 					par = _teamTwo[i];
 					par.updateStat(COMP_DONE, 1);
+					par.updateStat(COMP_DONE_WEEK, 1);
+					par.updateStat(getWeeklyMatchType(), 1);
 					par.updateNobleStats();
 				}
 			}
@@ -804,6 +814,8 @@ public class OlympiadGameTeams extends AbstractOlympiadGame
 			{
 				par = _teamOne[i];
 				par.updateStat(COMP_DONE, 1);
+				par.updateStat(COMP_DONE_WEEK, 1);
+				par.updateStat(getWeeklyMatchType(), 1);
 				par.updateNobleStats();
 			}
 
@@ -811,6 +823,8 @@ public class OlympiadGameTeams extends AbstractOlympiadGame
 			{
 				par = _teamTwo[i];
 				par.updateStat(COMP_DONE, 1);
+				par.updateStat(COMP_DONE_WEEK, 1);
+				par.updateStat(getWeeklyMatchType(), 1);
 				par.updateNobleStats();
 			}
 		}

+ 42 - 27
L2J_Server_BETA/java/com/l2jserver/gameserver/model/olympiad/OlympiadManager.java

@@ -34,9 +34,7 @@ import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.templates.StatsSet;
 
 /**
- * 
  * @author DS
- *
  */
 public class OlympiadManager
 {
@@ -208,27 +206,36 @@ public class OlympiadManager
 
 	public final boolean registerNoble(L2PcInstance player, CompetitionType type)
 	{
-		SystemMessage sm;
 		if (!Olympiad._inCompPeriod)
 		{
-			sm = SystemMessage.getSystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
-			player.sendPacket(sm);
+			player.sendPacket(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
 			return false;
 		}
 		
 		if (Olympiad.getInstance().getMillisToCompEnd() < 600000)
 		{
-			sm = SystemMessage.getSystemMessage(SystemMessageId.GAME_REQUEST_CANNOT_BE_MADE);
-			player.sendPacket(sm);
+			player.sendPacket(SystemMessageId.GAME_REQUEST_CANNOT_BE_MADE);
 			return false;
 		}
 		
+		if (Olympiad.getInstance().getRemainingWeeklyMatches(player.getObjectId()) < 1)
+		{
+			player.sendPacket(SystemMessageId.MAX_OLY_WEEKLY_MATCHES_REACHED);
+			return false;
+		}
+
 		switch (type)
 		{
 			case CLASSED:
 			{
 				if (!checkNoble(player, player))
 					return false;
+				
+				if (Olympiad.getInstance().getRemainingWeeklyMatchesClassed(player.getObjectId()) < 1)
+				{
+					player.sendPacket(SystemMessageId.MAX_OLY_WEEKLY_MATCHES_REACHED_60_NON_CLASSED_30_CLASSED_10_TEAM);
+					return false;
+				}
 
 				List<Integer> classed = _classBasedRegisters.get(player.getBaseClass());
 				if (classed != null)
@@ -239,19 +246,23 @@ public class OlympiadManager
 					classed.add(player.getObjectId());
 					_classBasedRegisters.put(player.getBaseClass(), classed);
 				}
-
-				sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_CLASSIFIED_GAMES);
-				player.sendPacket(sm);
+				
+				player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_CLASSIFIED_GAMES);
 				break;
 			}
 			case NON_CLASSED:
 			{
 				if (!checkNoble(player, player))
 					return false;
+				
+				if (Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed(player.getObjectId()) < 1)
+				{
+					player.sendPacket(SystemMessageId.MAX_OLY_WEEKLY_MATCHES_REACHED_60_NON_CLASSED_30_CLASSED_10_TEAM);
+					return false;
+				}
 
 				_nonClassBasedRegisters.add(player.getObjectId());
-				sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_NO_CLASS_GAMES);
-				player.sendPacket(sm);
+				player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_NO_CLASS_GAMES);
 				break;
 			}
 			case TEAMS:
@@ -259,14 +270,12 @@ public class OlympiadManager
 				final L2Party party = player.getParty();
 				if (party == null || party.getMemberCount() != 3)
 				{
-					sm = SystemMessage.getSystemMessage(SystemMessageId.PARTY_REQUIREMENTS_NOT_MET);
-					player.sendPacket(sm);
+					player.sendPacket(SystemMessageId.PARTY_REQUIREMENTS_NOT_MET);
 					return false;
 				}
 				if (!party.isLeader(player))
 				{
-					sm = SystemMessage.getSystemMessage(SystemMessageId.ONLY_PARTY_LEADER_CAN_REQUEST_TEAM_MATCH);
-					player.sendPacket(sm);
+					player.sendPacket(SystemMessageId.ONLY_PARTY_LEADER_CAN_REQUEST_TEAM_MATCH);
 					return false;
 				}
 
@@ -286,7 +295,13 @@ public class OlympiadManager
 
 								AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, unreg);		
 							}
-						}						
+						}
+						return false;
+					}
+					
+					if (Olympiad.getInstance().getRemainingWeeklyMatchesTeam(noble.getObjectId()) < 1)
+					{
+						player.sendPacket(SystemMessageId.MAX_OLY_WEEKLY_MATCHES_REACHED_60_NON_CLASSED_30_CLASSED_10_TEAM);
 						return false;
 					}
 					team.add(noble.getObjectId());
@@ -315,17 +330,15 @@ public class OlympiadManager
 	
 	public final boolean unRegisterNoble(L2PcInstance noble)
 	{
-		SystemMessage sm;
 		if (!Olympiad._inCompPeriod)
 		{
-			sm = SystemMessage.getSystemMessage(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
-			noble.sendPacket(sm);
+			noble.sendPacket(SystemMessageId.THE_OLYMPIAD_GAME_IS_NOT_CURRENTLY_IN_PROGRESS);
 			return false;
 		}
 		
 		if (!noble.isNoble())
 		{
-			sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_REQUIREMENTS_ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
+			final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_REQUIREMENTS_ONLY_NOBLESS_CAN_PARTICIPATE_IN_THE_OLYMPIAD);
 			sm.addString(noble.getName());
 			noble.sendPacket(sm);
 			return false;
@@ -333,22 +346,20 @@ public class OlympiadManager
 		
 		if (!isRegistered(noble, noble, false))
 		{
-			sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_NOT_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_A_GAME);
-			noble.sendPacket(sm);
+			noble.sendPacket(SystemMessageId.YOU_HAVE_NOT_BEEN_REGISTERED_IN_A_WAITING_LIST_OF_A_GAME);
 			return false;
 		}
 
 		if (isInCompetition(noble, noble, false))
 			return false;
-
-		sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_BEEN_DELETED_FROM_THE_WAITING_LIST_OF_A_GAME);
+		
 		Integer objId = Integer.valueOf(noble.getObjectId());
 		if (_nonClassBasedRegisters.remove(objId))
 		{
 			if (Config.L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
 				AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, noble);		
 
-			noble.sendPacket(sm);
+			noble.sendPacket(SystemMessageId.YOU_HAVE_BEEN_DELETED_FROM_THE_WAITING_LIST_OF_A_GAME);
 			return true;
 		}
 
@@ -361,7 +372,7 @@ public class OlympiadManager
 			if (Config.L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
 				AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, noble);		
 
-			noble.sendPacket(sm);
+			noble.sendPacket(SystemMessageId.YOU_HAVE_BEEN_DELETED_FROM_THE_WAITING_LIST_OF_A_GAME);
 			return true;
 		}
 
@@ -467,6 +478,10 @@ public class OlympiadManager
 			statDat.set(Olympiad.COMP_WON, 0);
 			statDat.set(Olympiad.COMP_LOST, 0);
 			statDat.set(Olympiad.COMP_DRAWN, 0);
+			statDat.set(Olympiad.COMP_DONE_WEEK, 0);
+			statDat.set(Olympiad.COMP_DONE_WEEK_CLASSED, 0);
+			statDat.set(Olympiad.COMP_DONE_WEEK_NON_CLASSED, 0);
+			statDat.set(Olympiad.COMP_DONE_WEEK_TEAM, 0);
 			statDat.set("to_save", true);
 			Olympiad.updateNobleStats(noble.getObjectId(), statDat);
 		}

+ 21 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/network/SystemMessageId.java

@@ -14793,6 +14793,18 @@ public final class SystemMessageId
 	 */
 	public static final SystemMessageId CONTACT_LIST_LIMIT_REACHED;
 	
+	/**
+	 * ID: 3224<br>
+	 * Message: The maximum matches you can participate in 1 week is 70.
+	 */
+	public static final SystemMessageId MAX_OLY_WEEKLY_MATCHES_REACHED;
+	
+	/***
+	 * ID: 3225
+	 * Message: The total number of matches that can be entered in 1 week is 60 class irrelevant individual matches, 30 specific matches, and 10 team matches.
+	 */
+	public static final SystemMessageId MAX_OLY_WEEKLY_MATCHES_REACHED_60_NON_CLASSED_30_CLASSED_10_TEAM;
+	
 	/**
 	 * ID: 3255<br>
 	 * Message: Arcane Shield decreased your MP by $1 instead of HP.
@@ -14805,6 +14817,12 @@ public final class SystemMessageId
 	 */
 	public static final SystemMessageId MP_BECAME_0_ARCANE_SHIELD_DISAPPEARING;
 	
+	/**
+	 * ID: 3261<br>
+	 * Message: You have $s1 match(es) remaining that you can participate in this week ($s2 1 vs 1 Class matches, $s3 1 vs 1 matches, & $s4 3 vs 3 Team matches).
+	 */
+	public static final SystemMessageId YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTECIPATE_IN_THIS_WEEK_S2_CLASSED_S3_NON_CLASSED_S4_TEAM;
+	
 	/**
 	 * ID: 6501<br>
 	 * Message: You cannot bookmark this location because you do not have a My Teleport Flag.
@@ -17270,8 +17288,11 @@ public final class SystemMessageId
 		S1_SUCCESFULLY_DELETED_FROM_CONTACT_LIST = new SystemMessageId(3219);
 		CANNOT_ADD_YOUR_NAME_ON_CONTACT_LIST = new SystemMessageId(3221);
 		CONTACT_LIST_LIMIT_REACHED = new SystemMessageId(3222);
+		MAX_OLY_WEEKLY_MATCHES_REACHED = new SystemMessageId(3224);
+		MAX_OLY_WEEKLY_MATCHES_REACHED_60_NON_CLASSED_30_CLASSED_10_TEAM = new SystemMessageId(3225);		
 		ARCANE_SHIELD_DECREASED_YOUR_MP_BY_S1_INSTEAD_OF_HP = new SystemMessageId(3255);
 		MP_BECAME_0_ARCANE_SHIELD_DISAPPEARING = new SystemMessageId(3256);
+		YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTECIPATE_IN_THIS_WEEK_S2_CLASSED_S3_NON_CLASSED_S4_TEAM = new SystemMessageId(3261);
 		YOU_CANNOT_BOOKMARK_THIS_LOCATION_BECAUSE_YOU_DO_NOT_HAVE_A_MY_TELEPORT_FLAG = new SystemMessageId(6501);
 		THOMAS_D_TURKEY_APPEARED = new SystemMessageId(6503);
 		THOMAS_D_TURKEY_DEFETED = new SystemMessageId(6504);