Olympiad rework.
Contributed by facab.
This commit is contained in:
@ -507,9 +507,8 @@ public final class Config
|
||||
public static int ALT_OLY_CLASSED;
|
||||
public static int ALT_OLY_NONCLASSED;
|
||||
public static int ALT_OLY_REG_DISPLAY;
|
||||
public static List<ItemHolder> ALT_OLY_CLASSED_REWARD;
|
||||
public static List<ItemHolder> ALT_OLY_NONCLASSED_REWARD;
|
||||
public static List<ItemHolder> ALT_OLY_TEAM_REWARD;
|
||||
public static List<ItemHolder> ALT_OLY_WINNER_REWARD;
|
||||
public static List<ItemHolder> ALT_OLY_LOSER_REWARD;
|
||||
public static int ALT_OLY_COMP_RITEM;
|
||||
public static int ALT_OLY_MIN_MATCHES;
|
||||
public static int ALT_OLY_MARK_PER_POINT;
|
||||
@ -520,12 +519,8 @@ public final class Config
|
||||
public static int ALT_OLY_RANK4_POINTS;
|
||||
public static int ALT_OLY_RANK5_POINTS;
|
||||
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_DIVIDER;
|
||||
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;
|
||||
@ -2310,20 +2305,19 @@ public final class Config
|
||||
// Load Olympiad config file (if exists)
|
||||
final PropertiesParser Olympiad = new PropertiesParser(OLYMPIAD_CONFIG_FILE);
|
||||
|
||||
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 18);
|
||||
ALT_OLY_START_TIME = Olympiad.getInt("AltOlyStartTime", 20);
|
||||
ALT_OLY_MIN = Olympiad.getInt("AltOlyMin", 0);
|
||||
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 21600000);
|
||||
ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 300000);
|
||||
ALT_OLY_CPERIOD = Olympiad.getLong("AltOlyCPeriod", 14400000);
|
||||
ALT_OLY_BATTLE = Olympiad.getLong("AltOlyBattle", 360000);
|
||||
ALT_OLY_WPERIOD = Olympiad.getLong("AltOlyWPeriod", 604800000);
|
||||
ALT_OLY_VPERIOD = Olympiad.getLong("AltOlyVPeriod", 86400000);
|
||||
ALT_OLY_START_POINTS = Olympiad.getInt("AltOlyStartPoints", 10);
|
||||
ALT_OLY_WEEKLY_POINTS = Olympiad.getInt("AltOlyWeeklyPoints", 10);
|
||||
ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 11);
|
||||
ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 11);
|
||||
ALT_OLY_CLASSED = Olympiad.getInt("AltOlyClassedParticipants", 10);
|
||||
ALT_OLY_NONCLASSED = Olympiad.getInt("AltOlyNonClassedParticipants", 20);
|
||||
ALT_OLY_REG_DISPLAY = Olympiad.getInt("AltOlyRegistrationDisplayNumber", 100);
|
||||
ALT_OLY_CLASSED_REWARD = parseItemsList(Olympiad.getString("AltOlyClassedReward", "13722,50"));
|
||||
ALT_OLY_NONCLASSED_REWARD = parseItemsList(Olympiad.getString("AltOlyNonClassedReward", "13722,40"));
|
||||
ALT_OLY_TEAM_REWARD = parseItemsList(Olympiad.getString("AltOlyTeamReward", "13722,85"));
|
||||
ALT_OLY_WINNER_REWARD = parseItemsList(Olympiad.getString("AltOlyWinReward", "45584,12"));
|
||||
ALT_OLY_LOSER_REWARD = parseItemsList(Olympiad.getString("AltOlyLoserReward", "45584,7"));
|
||||
ALT_OLY_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
|
||||
ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
|
||||
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
|
||||
@ -2334,12 +2328,8 @@ public final class Config
|
||||
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 40);
|
||||
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 30);
|
||||
ALT_OLY_MAX_POINTS = Olympiad.getInt("AltOlyMaxPoints", 10);
|
||||
ALT_OLY_DIVIDER_CLASSED = Olympiad.getInt("AltOlyDividerClassed", 5);
|
||||
ALT_OLY_DIVIDER_NON_CLASSED = Olympiad.getInt("AltOlyDividerNonClassed", 5);
|
||||
ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 70);
|
||||
ALT_OLY_MAX_WEEKLY_MATCHES_NON_CLASSED = Olympiad.getInt("AltOlyMaxWeeklyMatchesNonClassed", 60);
|
||||
ALT_OLY_MAX_WEEKLY_MATCHES_CLASSED = Olympiad.getInt("AltOlyMaxWeeklyMatchesClassed", 30);
|
||||
ALT_OLY_MAX_WEEKLY_MATCHES_TEAM = Olympiad.getInt("AltOlyMaxWeeklyMatchesTeam", 10);
|
||||
ALT_OLY_DIVIDER = Olympiad.getInt("AltOlyDivider", 5);
|
||||
ALT_OLY_MAX_WEEKLY_MATCHES = Olympiad.getInt("AltOlyMaxWeeklyMatches", 30);
|
||||
ALT_OLY_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
|
||||
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
|
||||
ALT_OLY_ANNOUNCE_GAMES = Olympiad.getBoolean("AltOlyAnnounceGames", true);
|
||||
@ -2350,12 +2340,12 @@ public final class Config
|
||||
LIST_OLY_RESTRICTED_ITEMS.add(Integer.parseInt(id));
|
||||
}
|
||||
ALT_OLY_ENCHANT_LIMIT = Olympiad.getInt("AltOlyEnchantLimit", -1);
|
||||
ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 60);
|
||||
ALT_OLY_WAIT_TIME = Olympiad.getInt("AltOlyWaitTime", 120);
|
||||
ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS = Olympiad.getBoolean("AltOlyUseCustomPeriodSettings", false);
|
||||
ALT_OLY_PERIOD = Olympiad.getString("AltOlyPeriod", "MONTH");
|
||||
ALT_OLY_PERIOD_MULTIPLIER = Olympiad.getInt("AltOlyPeriodMultiplier", 1);
|
||||
ALT_OLY_COMPETITION_DAYS = new ArrayList<>();
|
||||
for (String s : Olympiad.getString("AltOlyCompetitionDays", "1,2,3,4,5,6,7").split(","))
|
||||
for (String s : Olympiad.getString("AltOlyCompetitionDays", "6,7").split(","))
|
||||
{
|
||||
ALT_OLY_COMPETITION_DAYS.add(Integer.parseInt(s));
|
||||
}
|
||||
|
@ -56,9 +56,6 @@ public abstract class AbstractOlympiadGame
|
||||
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;
|
||||
@ -478,12 +475,6 @@ public abstract class AbstractOlympiadGame
|
||||
|
||||
protected abstract void validateWinner(OlympiadStadium stadium);
|
||||
|
||||
protected abstract int getDivider();
|
||||
|
||||
protected abstract List<ItemHolder> getReward();
|
||||
|
||||
protected abstract String getWeeklyMatchType();
|
||||
|
||||
protected abstract void healPlayers();
|
||||
|
||||
protected abstract void untransformPlayers();
|
||||
|
@ -67,9 +67,9 @@ public class Olympiad extends ListenersContainer
|
||||
public static final String OLYMPIAD_HTML_PATH = "data/html/olympiad/";
|
||||
private static final String OLYMPIAD_LOAD_DATA = "SELECT current_cycle, period, olympiad_end, validation_end, next_weekly_change FROM olympiad_data WHERE id = 0";
|
||||
private static final String OLYMPIAD_SAVE_DATA = "INSERT INTO olympiad_data (id, current_cycle, period, olympiad_end, validation_end, next_weekly_change) VALUES (0,?,?,?,?,?) ON DUPLICATE KEY UPDATE current_cycle=?, period=?, olympiad_end=?, 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_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`, `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 = ?, competitions_done_week = ?, competitions_done_week_classed = ?, competitions_done_week_non_classed = ?, competitions_done_week_team = ? WHERE charId = ?";
|
||||
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_done_week 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`, `competitions_done_week`) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
|
||||
private static final String OLYMPIAD_UPDATE_NOBLES = "UPDATE olympiad_nobles SET olympiad_points = ?, competitions_done = ?, competitions_won = ?, competitions_lost = ?, competitions_drawn = ?, competitions_done_week = ? 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 ORDER BY olympiad_nobles.olympiad_points DESC, olympiad_nobles.competitions_done DESC, olympiad_nobles.competitions_won DESC";
|
||||
private static final String GET_ALL_CLASSIFIED_NOBLESS = "SELECT charId from olympiad_nobles_eom WHERE competitions_done >= " + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_points DESC, competitions_done DESC, competitions_won 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 >= " + Config.ALT_OLY_MIN_MATCHES + " ORDER BY olympiad_nobles_eom.olympiad_points DESC, olympiad_nobles_eom.competitions_done DESC, olympiad_nobles_eom.competitions_won DESC LIMIT 10";
|
||||
@ -105,9 +105,6 @@ public class Olympiad extends ListenersContainer
|
||||
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;
|
||||
@ -241,9 +238,6 @@ public class Olympiad extends ListenersContainer
|
||||
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);
|
||||
|
||||
addNobleStats(rset.getInt(CHAR_ID), statData);
|
||||
@ -398,39 +392,7 @@ public class Olympiad extends ListenersContainer
|
||||
return;
|
||||
}
|
||||
|
||||
_compStart = Calendar.getInstance();
|
||||
if (Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
|
||||
{
|
||||
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
|
||||
boolean dayFound = false;
|
||||
int dayCounter = 0;
|
||||
for (int i = currentDay; i < 8; i++)
|
||||
{
|
||||
if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
|
||||
{
|
||||
dayFound = true;
|
||||
break;
|
||||
}
|
||||
dayCounter++;
|
||||
}
|
||||
if (!dayFound)
|
||||
{
|
||||
for (int i = 1; i < 8; i++)
|
||||
{
|
||||
if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
|
||||
{
|
||||
break;
|
||||
}
|
||||
dayCounter++;
|
||||
}
|
||||
}
|
||||
if (dayCounter > 0)
|
||||
{
|
||||
_compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
|
||||
}
|
||||
}
|
||||
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
|
||||
_compStart.set(Calendar.MINUTE, COMP_MIN);
|
||||
prepareCompStart();
|
||||
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
|
||||
|
||||
if (_scheduledOlympiadEnd != null)
|
||||
@ -443,6 +405,40 @@ public class Olympiad extends ListenersContainer
|
||||
updateCompStatus();
|
||||
}
|
||||
|
||||
private void prepareCompStart()
|
||||
{
|
||||
_compStart = Calendar.getInstance();
|
||||
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
|
||||
boolean dayFound = false;
|
||||
int dayCounter = 0;
|
||||
for (int i = currentDay; i < 8; i++)
|
||||
{
|
||||
if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
|
||||
{
|
||||
dayFound = true;
|
||||
break;
|
||||
}
|
||||
dayCounter++;
|
||||
}
|
||||
if (!dayFound)
|
||||
{
|
||||
for (int i = 1; i < 8; i++)
|
||||
{
|
||||
if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
|
||||
{
|
||||
break;
|
||||
}
|
||||
dayCounter++;
|
||||
}
|
||||
}
|
||||
if (dayCounter > 0)
|
||||
{
|
||||
_compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
|
||||
}
|
||||
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
|
||||
_compStart.set(Calendar.MINUTE, COMP_MIN);
|
||||
}
|
||||
|
||||
protected class OlympiadEndTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
@ -720,39 +716,7 @@ public class Olympiad extends ListenersContainer
|
||||
|
||||
private long setNewCompBegin()
|
||||
{
|
||||
_compStart = Calendar.getInstance();
|
||||
if (Config.ALT_OLY_USE_CUSTOM_PERIOD_SETTINGS)
|
||||
{
|
||||
final int currentDay = _compStart.get(Calendar.DAY_OF_WEEK);
|
||||
boolean dayFound = false;
|
||||
int dayCounter = 0;
|
||||
for (int i = currentDay; i < 8; i++)
|
||||
{
|
||||
if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
|
||||
{
|
||||
dayFound = true;
|
||||
break;
|
||||
}
|
||||
dayCounter++;
|
||||
}
|
||||
if (!dayFound)
|
||||
{
|
||||
for (int i = 1; i < 8; i++)
|
||||
{
|
||||
if (Config.ALT_OLY_COMPETITION_DAYS.contains(i))
|
||||
{
|
||||
break;
|
||||
}
|
||||
dayCounter++;
|
||||
}
|
||||
}
|
||||
if (dayCounter > 0)
|
||||
{
|
||||
_compStart.add(Calendar.DAY_OF_MONTH, dayCounter);
|
||||
}
|
||||
}
|
||||
_compStart.set(Calendar.HOUR_OF_DAY, COMP_START);
|
||||
_compStart.set(Calendar.MINUTE, COMP_MIN);
|
||||
prepareCompStart();
|
||||
_compStart.add(Calendar.HOUR_OF_DAY, 24);
|
||||
_compEnd = _compStart.getTimeInMillis() + COMP_PERIOD;
|
||||
|
||||
@ -819,9 +783,6 @@ public class Olympiad extends ListenersContainer
|
||||
for (StatsSet nobleInfo : NOBLES.values())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -869,9 +830,6 @@ public class Olympiad extends ListenersContainer
|
||||
final int compLost = nobleInfo.getInt(COMP_LOST);
|
||||
final int compDrawn = nobleInfo.getInt(COMP_DRAWN);
|
||||
final int compDoneWeek = nobleInfo.getInt(COMP_DONE_WEEK);
|
||||
final int compDoneWeekClassed = nobleInfo.getInt(COMP_DONE_WEEK_CLASSED);
|
||||
final int compDoneWeekNonClassed = nobleInfo.getInt(COMP_DONE_WEEK_NON_CLASSED);
|
||||
final int compDoneWeekTeam = nobleInfo.getInt(COMP_DONE_WEEK_TEAM);
|
||||
final boolean toSave = nobleInfo.getBoolean("to_save");
|
||||
|
||||
try (PreparedStatement statement = con.prepareStatement(toSave ? OLYMPIAD_SAVE_NOBLES : OLYMPIAD_UPDATE_NOBLES))
|
||||
@ -886,9 +844,6 @@ public class Olympiad extends ListenersContainer
|
||||
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);
|
||||
}
|
||||
@ -900,10 +855,7 @@ public class Olympiad extends ListenersContainer
|
||||
statement.setInt(4, compLost);
|
||||
statement.setInt(5, compDrawn);
|
||||
statement.setInt(6, compDoneWeek);
|
||||
statement.setInt(7, compDoneWeekClassed);
|
||||
statement.setInt(8, compDoneWeekNonClassed);
|
||||
statement.setInt(9, compDoneWeekTeam);
|
||||
statement.setInt(10, charId);
|
||||
statement.setInt(7, charId);
|
||||
}
|
||||
statement.execute();
|
||||
}
|
||||
@ -1132,9 +1084,6 @@ public class Olympiad extends ListenersContainer
|
||||
statDat.set(COMP_LOST, 0);
|
||||
statDat.set(COMP_DRAWN, 0);
|
||||
statDat.set(COMP_DONE_WEEK, 0);
|
||||
statDat.set(COMP_DONE_WEEK_CLASSED, 0);
|
||||
statDat.set(COMP_DONE_WEEK_NON_CLASSED, 0);
|
||||
statDat.set(COMP_DONE_WEEK_TEAM, 0);
|
||||
statDat.set("to_save", true);
|
||||
addNobleStats(player.getObjectId(), statDat);
|
||||
}
|
||||
@ -1204,48 +1153,6 @@ public class Olympiad extends ListenersContainer
|
||||
return NOBLES.get(objId).getInt(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
|
||||
*/
|
||||
public int getCompetitionDoneWeekClassed(int objId)
|
||||
{
|
||||
if ((NOBLES == null) || !NOBLES.containsKey(objId))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return NOBLES.get(objId).getInt(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
|
||||
*/
|
||||
public int getCompetitionDoneWeekNonClassed(int objId)
|
||||
{
|
||||
if ((NOBLES == null) || !NOBLES.containsKey(objId))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return NOBLES.get(objId).getInt(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
|
||||
*/
|
||||
public int getCompetitionDoneWeekTeam(int objId)
|
||||
{
|
||||
if ((NOBLES == null) || !NOBLES.containsKey(objId))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return NOBLES.get(objId).getInt(COMP_DONE_WEEK_TEAM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of remaining matches a noble character can join in the week
|
||||
* @param objId id of a noble character
|
||||
@ -1256,36 +1163,6 @@ public class Olympiad extends ListenersContainer
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public int getRemainingWeeklyMatchesTeam(int objId)
|
||||
{
|
||||
return Math.max(Config.ALT_OLY_MAX_WEEKLY_MATCHES_TEAM - getCompetitionDoneWeekTeam(objId), 0);
|
||||
}
|
||||
|
||||
protected void deleteNobles()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
|
@ -19,9 +19,7 @@ package org.l2jmobius.gameserver.model.olympiad;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author DS
|
||||
@ -39,24 +37,6 @@ public class OlympiadGameClassed extends OlympiadGameNormal
|
||||
return CompetitionType.CLASSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final int getDivider()
|
||||
{
|
||||
return Config.ALT_OLY_DIVIDER_CLASSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final List<ItemHolder> getReward()
|
||||
{
|
||||
return Config.ALT_OLY_CLASSED_REWARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final String getWeeklyMatchType()
|
||||
{
|
||||
return COMP_DONE_WEEK_CLASSED;
|
||||
}
|
||||
|
||||
protected static OlympiadGameClassed createGame(int id, List<Set<Integer>> classList)
|
||||
{
|
||||
if ((classList == null) || classList.isEmpty())
|
||||
|
@ -16,12 +16,8 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.olympiad;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author DS
|
||||
*/
|
||||
@ -38,24 +34,6 @@ public class OlympiadGameNonClassed extends OlympiadGameNormal
|
||||
return CompetitionType.NON_CLASSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final int getDivider()
|
||||
{
|
||||
return Config.ALT_OLY_DIVIDER_NON_CLASSED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final List<ItemHolder> getReward()
|
||||
{
|
||||
return Config.ALT_OLY_NONCLASSED_REWARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final String getWeeklyMatchType()
|
||||
{
|
||||
return COMP_DONE_WEEK_NON_CLASSED;
|
||||
}
|
||||
|
||||
protected static OlympiadGameNonClassed createGame(int id, Set<Integer> list)
|
||||
{
|
||||
final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
|
||||
|
@ -214,12 +214,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
@Override
|
||||
protected final void cleanEffects()
|
||||
{
|
||||
if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
|
||||
if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
|
||||
{
|
||||
cleanEffects(_playerOne.getPlayer());
|
||||
}
|
||||
|
||||
if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
|
||||
if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
|
||||
{
|
||||
cleanEffects(_playerTwo.getPlayer());
|
||||
}
|
||||
@ -228,11 +228,11 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
@Override
|
||||
protected final void portPlayersBack()
|
||||
{
|
||||
if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected())
|
||||
if (checkOnline(_playerTwo))
|
||||
{
|
||||
portPlayerBack(_playerOne.getPlayer());
|
||||
}
|
||||
if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected())
|
||||
if (checkOnline(_playerTwo))
|
||||
{
|
||||
portPlayerBack(_playerTwo.getPlayer());
|
||||
}
|
||||
@ -241,17 +241,22 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
@Override
|
||||
protected final void playersStatusBack()
|
||||
{
|
||||
if ((_playerOne.getPlayer() != null) && !_playerOne.isDefaulted() && !_playerOne.isDisconnected() && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
|
||||
if (checkOnline(_playerTwo) && (_playerOne.getPlayer().getOlympiadGameId() == _stadiumId))
|
||||
{
|
||||
playerStatusBack(_playerOne.getPlayer());
|
||||
}
|
||||
|
||||
if ((_playerTwo.getPlayer() != null) && !_playerTwo.isDefaulted() && !_playerTwo.isDisconnected() && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
|
||||
if (checkOnline(_playerTwo) && (_playerTwo.getPlayer().getOlympiadGameId() == _stadiumId))
|
||||
{
|
||||
playerStatusBack(_playerTwo.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkOnline(Participant player)
|
||||
{
|
||||
return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void clearPlayers()
|
||||
{
|
||||
@ -353,7 +358,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
final int playerOnePoints = _playerOne.getStats().getInt(POINTS);
|
||||
final int playerTwoPoints = _playerTwo.getStats().getInt(POINTS);
|
||||
int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / getDivider();
|
||||
int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / Config.ALT_OLY_DIVIDER;
|
||||
if (pointDiff <= 0)
|
||||
{
|
||||
pointDiff = 1;
|
||||
@ -367,6 +372,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
SystemMessage sm;
|
||||
|
||||
// Check for if a player defaulted before battle started
|
||||
// TODO Is this really official?
|
||||
if (_playerOne.isDefaulted() || _playerTwo.isDefaulted())
|
||||
{
|
||||
try
|
||||
@ -457,7 +463,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
winside = 1;
|
||||
|
||||
rewardParticipant(_playerOne.getPlayer(), getReward());
|
||||
rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
|
||||
|
||||
if (Config.ALT_OLY_LOG_FIGHTS)
|
||||
{
|
||||
@ -483,7 +489,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
winside = 2;
|
||||
|
||||
rewardParticipant(_playerTwo.getPlayer(), getReward());
|
||||
rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
|
||||
|
||||
if (Config.ALT_OLY_LOG_FIGHTS)
|
||||
{
|
||||
@ -516,8 +522,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
_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);
|
||||
|
||||
if (winside == 1)
|
||||
{
|
||||
@ -599,7 +603,11 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
// Save Fight Result
|
||||
saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
|
||||
rewardParticipant(_playerOne.getPlayer(), getReward());
|
||||
rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
|
||||
if ((_playerTwo.getPlayer() != null) && _playerTwo.getPlayer().isOnline())
|
||||
{
|
||||
rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
|
||||
@ -624,7 +632,11 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
// Save Fight Result
|
||||
saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
|
||||
rewardParticipant(_playerTwo.getPlayer(), getReward());
|
||||
rewardParticipant(_playerTwo.getPlayer(), Config.ALT_OLY_WINNER_REWARD);
|
||||
if ((_playerOne.getPlayer() != null) && _playerOne.getPlayer().isOnline())
|
||||
{
|
||||
rewardParticipant(_playerOne.getPlayer(), Config.ALT_OLY_LOSER_REWARD);
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
|
||||
@ -637,12 +649,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.THERE_IS_NO_VICTOR_THE_MATCH_ENDS_IN_A_TIE);
|
||||
stadium.broadcastPacket(sm);
|
||||
|
||||
int value = Math.min(playerOnePoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
|
||||
int value = Math.min(playerOnePoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
|
||||
|
||||
removePointsFromParticipant(_playerOne, value);
|
||||
list1.add(new OlympiadInfo(_playerOne.getName(), _playerOne.getClanName(), _playerOne.getClanId(), _playerOne.getBaseClass(), _damageP1, playerOnePoints - value, -value));
|
||||
|
||||
value = Math.min(playerTwoPoints / getDivider(), Config.ALT_OLY_MAX_POINTS);
|
||||
value = Math.min(playerTwoPoints / Config.ALT_OLY_DIVIDER, Config.ALT_OLY_MAX_POINTS);
|
||||
removePointsFromParticipant(_playerTwo, value);
|
||||
list2.add(new OlympiadInfo(_playerTwo.getName(), _playerTwo.getClanName(), _playerTwo.getClanId(), _playerTwo.getBaseClass(), _damageP2, playerTwoPoints - value, -value));
|
||||
|
||||
@ -653,8 +665,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
_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);
|
||||
|
||||
if (winside == 1)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ public class OlympiadManager
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Olympiad.getInstance().getMillisToCompEnd() < 600000)
|
||||
if (Olympiad.getInstance().getMillisToCompEnd() < 1200000)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.PARTICIPATION_REQUESTS_ARE_NO_LONGER_BEING_ACCEPTED);
|
||||
return false;
|
||||
@ -204,6 +204,8 @@ public class OlympiadManager
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO Class fights are only 1st week
|
||||
|
||||
if ((Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0) && !AntiFeedManager.getInstance().tryAddPlayer(AntiFeedManager.OLYMPIAD_ID, player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP))
|
||||
{
|
||||
final NpcHtmlMessage message = new NpcHtmlMessage(player.getLastHtmlActionOriginId());
|
||||
@ -213,12 +215,6 @@ public class OlympiadManager
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Olympiad.getInstance().getRemainingWeeklyMatchesClassed(charId) < 1)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_MAY_PARTICIPATE_IN_UP_TO_30_MATCHES_PER_WEEK);
|
||||
return false;
|
||||
}
|
||||
|
||||
_classBasedRegisters.computeIfAbsent(getClassGroup(player), k -> ConcurrentHashMap.newKeySet()).add(charId);
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REGISTERED_FOR_THE_OLYMPIAD_WAITING_LIST_FOR_A_CLASS_BATTLE);
|
||||
break;
|
||||
@ -240,12 +236,6 @@ public class OlympiadManager
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed(charId) < 1)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_MAY_PARTICIPATE_IN_UP_TO_30_MATCHES_PER_WEEK);
|
||||
return false;
|
||||
}
|
||||
|
||||
_nonClassBasedRegisters.add(charId);
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user