Olympiad rework.
Contributed by facab.
This commit is contained in:
@@ -7,7 +7,6 @@ CREATE TABLE IF NOT EXISTS `olympiad_fights` (
|
||||
`winner` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`start` bigint(13) unsigned NOT NULL DEFAULT '0',
|
||||
`time` bigint(13) unsigned NOT NULL DEFAULT '0',
|
||||
`classed` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
KEY `charOneId` (`charOneId`),
|
||||
KEY `charTwoId` (`charTwoId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
@@ -8,8 +8,5 @@ CREATE TABLE IF NOT EXISTS `olympiad_nobles` (
|
||||
`competitions_lost` smallint(3) unsigned NOT NULL DEFAULT 0,
|
||||
`competitions_drawn` smallint(3) unsigned NOT NULL DEFAULT 0,
|
||||
`competitions_done_week` tinyint(3) unsigned NOT NULL DEFAULT 0,
|
||||
`competitions_done_week_classed` tinyint(3) unsigned NOT NULL DEFAULT 0,
|
||||
`competitions_done_week_non_classed` tinyint(3) unsigned NOT NULL DEFAULT 0,
|
||||
`competitions_done_week_team` tinyint(3) unsigned NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`charId`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
@@ -9,24 +9,22 @@
|
||||
# Also please understand what you are changing before you do so on a live server.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Olympiad Start Time in Military hours Default 6pm (18)
|
||||
# Default: 18
|
||||
# Classic: 20
|
||||
# Olympiad Start Time in Military hours Default 8pm (20)
|
||||
# Default: 20
|
||||
AltOlyStartTime = 20
|
||||
|
||||
# Olympiad Start Time for Min's, Default 00 so at the start of the hour.
|
||||
# Default: 00
|
||||
AltOlyMin = 00
|
||||
|
||||
# Olympiad Competition Period, Default 6 hours.
|
||||
# Olympiad Competition Period, Default 4 hours.
|
||||
# (If set different, should be increment by 10mins)
|
||||
# Default: 21600000
|
||||
# Classic: 14400000
|
||||
# Default: 14400000
|
||||
AltOlyCPeriod = 14400000
|
||||
|
||||
# Olympiad Battle Period, Default 5 minutes.
|
||||
# Default: 300000
|
||||
AltOlyBattle = 300000
|
||||
# Olympiad Battle Period, Default 6 minutes.
|
||||
# Default: 360000
|
||||
AltOlyBattle = 360000
|
||||
|
||||
# Olympiad Weekly Period, Default 1 week
|
||||
# Used for adding points to nobles
|
||||
@@ -35,7 +33,7 @@ AltOlyWPeriod = 604800000
|
||||
|
||||
# Olympiad Validation Period, Default 24 Hours.
|
||||
# Default: 86400000
|
||||
AltOlyVPeriod = 43200000
|
||||
AltOlyVPeriod = 86400000
|
||||
|
||||
# Points for reaching Noblesse for the first time
|
||||
# Default: 10
|
||||
@@ -45,38 +43,15 @@ AltOlyStartPoints = 10
|
||||
# Default: 10
|
||||
AltOlyWeeklyPoints = 10
|
||||
|
||||
# Required number of participants for the class based games
|
||||
# Default: 11
|
||||
AltOlyClassedParticipants = 11
|
||||
|
||||
# Required number of participants for the non-class based games
|
||||
# Default: 11
|
||||
AltOlyNonClassedParticipants = 11
|
||||
|
||||
# Required number of participants for the 3x3 teams games
|
||||
# Default: 6
|
||||
AltOlyTeamsParticipants = 6
|
||||
# Required number of participants for the games
|
||||
# Default: 20
|
||||
AltOlyParticipants = 20
|
||||
|
||||
# Number used for displaying amount of registered participants, messages "Fewer than ..." or "More than ...".
|
||||
# 0 for displaying digits instead of text phrase (old style).
|
||||
# Default: 100
|
||||
AltOlyRegistrationDisplayNumber = 100
|
||||
|
||||
# Reward for the class based games
|
||||
# Format: itemId1,itemNum1;itemId2,itemNum2...
|
||||
# Default: 13722,50
|
||||
AltOlyClassedReward = 13722,50
|
||||
|
||||
# Reward for the non-class based games
|
||||
# Format: itemId1,itemNum1;itemId2,itemNum2...
|
||||
# Default: 13722,40
|
||||
AltOlyNonClassedReward = 13722,40
|
||||
|
||||
# Reward for the 3x3 teams games
|
||||
# Format: itemId1,itemNum1;itemId2,itemNum2...
|
||||
# Default: 13722,85
|
||||
AltOlyTeamReward = 13722,85
|
||||
|
||||
# ItemId used for exchanging to the points.
|
||||
# Default: 45584
|
||||
AltOlyCompRewItem = 45584
|
||||
@@ -142,29 +117,18 @@ AltOlyLogFights = False
|
||||
# Default: 60
|
||||
AltOlyWaitTime = 60
|
||||
|
||||
# Divider for points in classed and non-classed games
|
||||
# Default: 5, 5
|
||||
AltOlyDividerClassed = 5
|
||||
AltOlyDividerNonClassed = 5
|
||||
# Divider for points in games
|
||||
# Default: 5
|
||||
AltOlyDivider = 5
|
||||
|
||||
# Maximum number of matches a Noblesse character can join per week
|
||||
# Default: 70
|
||||
# Classic: 30
|
||||
# Default: 30
|
||||
AltOlyMaxWeeklyMatches = 30
|
||||
|
||||
# Maximum number of Class-Irrelevant Individual matches a character can join per week
|
||||
# Default: 60
|
||||
# Classic: 30
|
||||
AltOlyMaxWeeklyMatchesNonClassed = 30
|
||||
|
||||
# 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
|
||||
|
||||
# Enable competitions only on specific days.
|
||||
# Default: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||
# Classic: 6,7 (FRIDAY,SATURDAY)
|
||||
AltOlyCompetitionDays = 6,7
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Custom Olympiad period settings
|
||||
@@ -190,9 +154,4 @@ AltOlyPeriod = MONTH
|
||||
# then Olympiad will occur every 2 months.
|
||||
# Default: 1
|
||||
# Note! If type = DAY, multiplier must be >= 7!
|
||||
AltOlyPeriodMultiplier = 1
|
||||
|
||||
# Enable competitions only on specific days.
|
||||
# Default: 1,2,3,4,5,6,7 (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY)
|
||||
# Classic: 6,7
|
||||
AltOlyCompetitionDays = 6,7
|
||||
AltOlyPeriodMultiplier = 1
|
@@ -30,7 +30,6 @@ import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
|
||||
@@ -124,7 +123,7 @@ public final class OlyManager extends AbstractNpcAI implements IBypassHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
OlympiadManager.getInstance().registerNoble(player, CompetitionType.NON_CLASSED);
|
||||
OlympiadManager.getInstance().registerNoble(player);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ import org.l2jmobius.gameserver.model.WorldObject;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Participant;
|
||||
@@ -91,7 +91,7 @@ public class AdminOlympiad implements IAdminCommandHandler
|
||||
final Participant[] players = new Participant[2];
|
||||
players[0] = new Participant(activeChar, 1);
|
||||
players[1] = new Participant(player, 2);
|
||||
task.attachGame(new OlympiadGameNonClassed(i, players));
|
||||
task.attachGame(new OlympiadGameNormal(i, players));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -251,9 +251,6 @@ public class AdminOlympiad implements IAdminCommandHandler
|
||||
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.addNobleStats(player.getObjectId(), statDat);
|
||||
}
|
||||
|
@@ -59,9 +59,6 @@ public class OlympiadStat implements IUserCommandHandler
|
||||
|
||||
final SystemMessage sm2 = SystemMessage.getSystemMessage(SystemMessageId.THE_MATCHES_THIS_WEEK_ARE_ALL_CLASS_BATTLES_THE_NUMBER_OF_MATCHES_THAT_ARE_ALLOWED_TO_PARTICIPATE_IS_S1);
|
||||
sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatches(nobleObjId));
|
||||
sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesClassed(nobleObjId));
|
||||
sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed(nobleObjId));
|
||||
sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesTeam(nobleObjId));
|
||||
player.sendPacket(sm2);
|
||||
return true;
|
||||
}
|
||||
|
@@ -60,7 +60,6 @@ import org.l2jmobius.commons.util.StringUtil;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.enums.IllegalActionPunishmentType;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.util.FloodProtectorConfig;
|
||||
import org.l2jmobius.gameserver.util.Util;
|
||||
|
||||
@@ -513,12 +512,9 @@ public final class Config
|
||||
public static long ALT_OLY_VPERIOD;
|
||||
public static int ALT_OLY_START_POINTS;
|
||||
public static int ALT_OLY_WEEKLY_POINTS;
|
||||
public static int ALT_OLY_CLASSED;
|
||||
public static int ALT_OLY_PARTICIPANTS;
|
||||
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 int ALT_OLY_COMP_RITEM;
|
||||
public static int ALT_OLY_MIN_MATCHES;
|
||||
public static int ALT_OLY_MARK_PER_POINT;
|
||||
@@ -529,12 +525,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;
|
||||
@@ -2152,36 +2144,28 @@ 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_PARTICIPANTS = Olympiad.getInt("AltOlyParticipants", 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_COMP_RITEM = Olympiad.getInt("AltOlyCompRewItem", 45584);
|
||||
ALT_OLY_MIN_MATCHES = Olympiad.getInt("AltOlyMinMatchesForPoints", 15);
|
||||
ALT_OLY_MARK_PER_POINT = Olympiad.getInt("AltOlyMarkPerPoint", 20);
|
||||
ALT_OLY_HERO_POINTS = Olympiad.getInt("AltOlyHeroPoints", 30);
|
||||
ALT_OLY_RANK1_POINTS = Olympiad.getInt("AltOlyRank1Points", 60);
|
||||
ALT_OLY_RANK2_POINTS = Olympiad.getInt("AltOlyRank2Points", 50);
|
||||
ALT_OLY_RANK3_POINTS = Olympiad.getInt("AltOlyRank3Points", 45);
|
||||
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 40);
|
||||
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 30);
|
||||
ALT_OLY_HERO_POINTS = Olympiad.getInt("AltOlyHeroPoints", 300);
|
||||
ALT_OLY_RANK1_POINTS = Olympiad.getInt("AltOlyRank1Points", 200);
|
||||
ALT_OLY_RANK2_POINTS = Olympiad.getInt("AltOlyRank2Points", 80);
|
||||
ALT_OLY_RANK3_POINTS = Olympiad.getInt("AltOlyRank3Points", 50);
|
||||
ALT_OLY_RANK4_POINTS = Olympiad.getInt("AltOlyRank4Points", 30);
|
||||
ALT_OLY_RANK5_POINTS = Olympiad.getInt("AltOlyRank5Points", 15);
|
||||
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_DIVIDER = Olympiad.getInt("AltOlyDivider", 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_LOG_FIGHTS = Olympiad.getBoolean("AltOlyLogFights", false);
|
||||
ALT_OLY_SHOW_MONTHLY_WINNERS = Olympiad.getBoolean("AltOlyShowMonthlyWinners", true);
|
||||
ALT_OLY_ANNOUNCE_GAMES = Olympiad.getBoolean("AltOlyAnnounceGames", true);
|
||||
@@ -3019,60 +3003,6 @@ public final class Config
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a config value from its string representation to a two-dimensional int array.<br>
|
||||
* The format of the value to be parsed should be as follows: "item1Id,item1Amount;item2Id,item2Amount;...itemNId,itemNAmount".
|
||||
* @param line the value of the parameter to parse
|
||||
* @return the parsed list or {@code null} if nothing was parsed
|
||||
*/
|
||||
private static List<ItemHolder> parseItemsList(String line)
|
||||
{
|
||||
final String[] propertySplit = line.split(";");
|
||||
if (propertySplit.length == 0)
|
||||
{
|
||||
// nothing to do here
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] valueSplit;
|
||||
final List<ItemHolder> result = new ArrayList<>(propertySplit.length);
|
||||
for (String value : propertySplit)
|
||||
{
|
||||
valueSplit = value.split(",");
|
||||
if (valueSplit.length != 2)
|
||||
{
|
||||
LOGGER.warning("parseItemsList[Config.load()]: invalid entry -> " + valueSplit[0] + ", should be itemId,itemNumber. Skipping to the next entry in the list.");
|
||||
continue;
|
||||
}
|
||||
|
||||
int itemId = -1;
|
||||
try
|
||||
{
|
||||
itemId = Integer.parseInt(valueSplit[0]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
LOGGER.warning("parseItemsList[Config.load()]: invalid itemId -> " + valueSplit[0] + ", value must be an integer. Skipping to the next entry in the list.");
|
||||
continue;
|
||||
}
|
||||
int count = -1;
|
||||
try
|
||||
{
|
||||
count = Integer.parseInt(valueSplit[1]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
LOGGER.warning("parseItemsList[Config.load()]: invalid item number -> " + valueSplit[1] + ", value must be an integer. Skipping to the next entry in the list.");
|
||||
continue;
|
||||
}
|
||||
if ((itemId > 0) && (count > 0))
|
||||
{
|
||||
result.add(new ItemHolder(itemId, count));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class IPConfigData implements IXmlReader
|
||||
{
|
||||
private static final List<String> _subnets = new ArrayList<>(5);
|
||||
|
@@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.model.events.impl.olympiad;
|
||||
|
||||
import org.l2jmobius.gameserver.model.events.EventType;
|
||||
import org.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Participant;
|
||||
|
||||
/**
|
||||
@@ -28,13 +27,11 @@ public class OnOlympiadMatchResult implements IBaseEvent
|
||||
{
|
||||
private final Participant _winner;
|
||||
private final Participant _loser;
|
||||
private final CompetitionType _type;
|
||||
|
||||
public OnOlympiadMatchResult(Participant winner, Participant looser, CompetitionType type)
|
||||
public OnOlympiadMatchResult(Participant winner, Participant looser)
|
||||
{
|
||||
_winner = winner;
|
||||
_loser = looser;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public Participant getWinner()
|
||||
@@ -47,11 +44,6 @@ public class OnOlympiadMatchResult implements IBaseEvent
|
||||
return _loser;
|
||||
}
|
||||
|
||||
public CompetitionType getCompetitionType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventType getType()
|
||||
{
|
||||
|
@@ -1,494 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.olympiad;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.Party;
|
||||
import org.l2jmobius.gameserver.model.Party.MessageType;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Summon;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author godson, GodKratos, Pere, DS
|
||||
*/
|
||||
public abstract class AbstractOlympiadGame
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(AbstractOlympiadGame.class.getName());
|
||||
protected static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
|
||||
|
||||
protected static final String POINTS = "olympiad_points";
|
||||
protected static final String COMP_DONE = "competitions_done";
|
||||
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;
|
||||
protected final int _stadiumId;
|
||||
|
||||
protected AbstractOlympiadGame(int id)
|
||||
{
|
||||
_stadiumId = id;
|
||||
}
|
||||
|
||||
public final boolean isAborted()
|
||||
{
|
||||
return _aborted;
|
||||
}
|
||||
|
||||
public final int getStadiumId()
|
||||
{
|
||||
return _stadiumId;
|
||||
}
|
||||
|
||||
protected boolean makeCompetitionStart()
|
||||
{
|
||||
_startTime = System.currentTimeMillis();
|
||||
return !_aborted;
|
||||
}
|
||||
|
||||
protected final void addPointsToParticipant(Participant par, int points)
|
||||
{
|
||||
par.updateStat(POINTS, points);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
|
||||
sm.addString(par.getName());
|
||||
sm.addInt(points);
|
||||
broadcastPacket(sm);
|
||||
}
|
||||
|
||||
protected final void removePointsFromParticipant(Participant par, int points)
|
||||
{
|
||||
par.updateStat(POINTS, -points);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
|
||||
sm.addString(par.getName());
|
||||
sm.addInt(points);
|
||||
broadcastPacket(sm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
protected static SystemMessage checkDefaulted(PlayerInstance player)
|
||||
{
|
||||
if ((player == null) || !player.isOnline())
|
||||
{
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
|
||||
if ((player.getClient() == null) || player.getClient().isDetached())
|
||||
{
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
|
||||
// safety precautions
|
||||
if (player.inObserverMode())
|
||||
{
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
|
||||
SystemMessage sm;
|
||||
if (player.isDead())
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
|
||||
sm.addPcName(player);
|
||||
player.sendPacket(sm);
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
if (player.isSubClassActive())
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
|
||||
sm.addPcName(player);
|
||||
player.sendPacket(sm);
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
if (player.isCursedWeaponEquipped())
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
|
||||
sm.addPcName(player);
|
||||
sm.addItemName(player.getCursedWeaponEquippedId());
|
||||
player.sendPacket(sm);
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
if (!player.isInventoryUnder90(true))
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
|
||||
sm.addPcName(player);
|
||||
player.sendPacket(sm);
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
|
||||
{
|
||||
final PlayerInstance player = par.getPlayer();
|
||||
if ((player == null) || !player.isOnline())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
player.setLastLocation();
|
||||
if (player.isSitting())
|
||||
{
|
||||
player.standUp();
|
||||
}
|
||||
player.setTarget(null);
|
||||
|
||||
player.setOlympiadGameId(id);
|
||||
player.setIsInOlympiadMode(true);
|
||||
player.setIsOlympiadStart(false);
|
||||
player.setOlympiadSide(par.getSide());
|
||||
player.teleToLocation(loc, instance);
|
||||
player.sendPacket(new ExOlympiadMode(2));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static void removals(PlayerInstance player, boolean removeParty)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove Buffs
|
||||
player.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
|
||||
// Remove Clan Skills
|
||||
if (player.getClan() != null)
|
||||
{
|
||||
player.getClan().removeSkillEffects(player);
|
||||
if (player.getClan().getCastleId() > 0)
|
||||
{
|
||||
CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
|
||||
}
|
||||
if (player.getClan().getFortId() > 0)
|
||||
{
|
||||
FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
|
||||
}
|
||||
}
|
||||
// Abort casting if player casting
|
||||
player.abortAttack();
|
||||
player.abortCast();
|
||||
|
||||
// Force the character to be visible
|
||||
player.setInvisible(false);
|
||||
|
||||
// Heal Player fully
|
||||
player.setCurrentCp(player.getMaxCp());
|
||||
player.setCurrentHp(player.getMaxHp());
|
||||
player.setCurrentMp(player.getMaxMp());
|
||||
|
||||
// Remove Summon's Buffs
|
||||
if (player.hasSummon())
|
||||
{
|
||||
final Summon pet = player.getPet();
|
||||
if (pet != null)
|
||||
{
|
||||
pet.unSummon(player);
|
||||
}
|
||||
|
||||
player.getServitors().values().forEach(s ->
|
||||
{
|
||||
s.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
s.abortAttack();
|
||||
s.abortCast();
|
||||
});
|
||||
}
|
||||
|
||||
// stop any cubic that has been given by other player.
|
||||
player.stopCubicsByOthers();
|
||||
|
||||
// Remove player from his party
|
||||
if (removeParty)
|
||||
{
|
||||
final Party party = player.getParty();
|
||||
if (party != null)
|
||||
{
|
||||
party.removePartyMember(player, MessageType.EXPELLED);
|
||||
}
|
||||
}
|
||||
// Remove Agathion
|
||||
if (player.getAgathionId() > 0)
|
||||
{
|
||||
player.setAgathionId(0);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
player.checkItemRestriction();
|
||||
|
||||
// Remove shot automation
|
||||
player.disableAutoShotsAll();
|
||||
|
||||
// Discharge any active shots
|
||||
player.unchargeAllShots();
|
||||
|
||||
// enable skills with cool time <= 15 minutes
|
||||
for (Skill skill : player.getAllSkills())
|
||||
{
|
||||
if (skill.getReuseDelay() <= 900000)
|
||||
{
|
||||
player.enableSkill(skill);
|
||||
}
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void cleanEffects(PlayerInstance player)
|
||||
{
|
||||
try
|
||||
{
|
||||
// prevent players kill each other
|
||||
player.setIsOlympiadStart(false);
|
||||
player.setTarget(null);
|
||||
player.abortAttack();
|
||||
player.abortCast();
|
||||
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
|
||||
if (player.isDead())
|
||||
{
|
||||
player.setIsDead(false);
|
||||
}
|
||||
|
||||
player.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
player.clearSouls();
|
||||
player.clearCharges();
|
||||
if (player.getAgathionId() > 0)
|
||||
{
|
||||
player.setAgathionId(0);
|
||||
}
|
||||
final Summon pet = player.getPet();
|
||||
if ((pet != null) && !pet.isDead())
|
||||
{
|
||||
pet.setTarget(null);
|
||||
pet.abortAttack();
|
||||
pet.abortCast();
|
||||
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
pet.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
}
|
||||
|
||||
player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
|
||||
{
|
||||
s.setTarget(null);
|
||||
s.abortAttack();
|
||||
s.abortCast();
|
||||
s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
s.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
});
|
||||
|
||||
player.setCurrentCp(player.getMaxCp());
|
||||
player.setCurrentHp(player.getMaxHp());
|
||||
player.setCurrentMp(player.getMaxMp());
|
||||
player.getStatus().startHpMpRegeneration();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void playerStatusBack(PlayerInstance player)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (player.isTransformed())
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
|
||||
player.setIsInOlympiadMode(false);
|
||||
player.setIsOlympiadStart(false);
|
||||
player.setOlympiadSide(-1);
|
||||
player.setOlympiadGameId(-1);
|
||||
player.sendPacket(new ExOlympiadMode(0));
|
||||
|
||||
// Add Clan Skills
|
||||
if (player.getClan() != null)
|
||||
{
|
||||
player.getClan().addSkillEffects(player);
|
||||
if (player.getClan().getCastleId() > 0)
|
||||
{
|
||||
CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
|
||||
}
|
||||
if (player.getClan().getFortId() > 0)
|
||||
{
|
||||
FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
|
||||
}
|
||||
player.sendSkillList();
|
||||
}
|
||||
|
||||
// heal again after adding clan skills
|
||||
player.setCurrentCp(player.getMaxCp());
|
||||
player.setCurrentHp(player.getMaxHp());
|
||||
player.setCurrentMp(player.getMaxMp());
|
||||
player.getStatus().startHpMpRegeneration();
|
||||
|
||||
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
|
||||
{
|
||||
AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "playerStatusBack()", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void portPlayerBack(PlayerInstance player)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Location loc = player.getLastLocation();
|
||||
if (loc != null)
|
||||
{
|
||||
player.setIsPendingRevive(false);
|
||||
player.teleToLocation(loc, null);
|
||||
player.unsetLastLocation();
|
||||
}
|
||||
}
|
||||
|
||||
public static void rewardParticipant(PlayerInstance player, List<ItemHolder> list)
|
||||
{
|
||||
if ((player == null) || !player.isOnline() || (list == null))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
list.forEach(holder ->
|
||||
{
|
||||
final ItemInstance item = player.getInventory().addItem("Olympiad", holder.getId(), holder.getCount(), player, null);
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
iu.addModifiedItem(item);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
|
||||
sm.addItemName(item);
|
||||
sm.addLong(holder.getCount());
|
||||
player.sendPacket(sm);
|
||||
});
|
||||
player.sendInventoryUpdate(iu);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract CompetitionType getType();
|
||||
|
||||
public abstract String[] getPlayerNames();
|
||||
|
||||
public abstract boolean containsParticipant(int playerId);
|
||||
|
||||
public abstract void sendOlympiadInfo(Creature creature);
|
||||
|
||||
public abstract void broadcastOlympiadInfo(OlympiadStadium _stadium);
|
||||
|
||||
protected abstract void broadcastPacket(IClientOutgoingPacket packet);
|
||||
|
||||
protected abstract boolean needBuffers();
|
||||
|
||||
protected abstract boolean checkDefaulted();
|
||||
|
||||
protected abstract void removals();
|
||||
|
||||
protected abstract boolean portPlayersToArena(List<Location> spawns, Instance instance);
|
||||
|
||||
protected abstract void cleanEffects();
|
||||
|
||||
protected abstract void portPlayersBack();
|
||||
|
||||
protected abstract void playersStatusBack();
|
||||
|
||||
protected abstract void clearPlayers();
|
||||
|
||||
protected abstract void handleDisconnect(PlayerInstance player);
|
||||
|
||||
protected abstract void resetDamage();
|
||||
|
||||
protected abstract void addDamage(PlayerInstance player, int damage);
|
||||
|
||||
protected abstract boolean checkBattleStatus();
|
||||
|
||||
protected abstract boolean haveWinner();
|
||||
|
||||
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();
|
||||
|
||||
protected abstract void makePlayersInvul();
|
||||
|
||||
protected abstract void removePlayersInvul();
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.olympiad;
|
||||
|
||||
/**
|
||||
* @author DS
|
||||
*/
|
||||
public enum CompetitionType
|
||||
{
|
||||
CLASSED("classed"),
|
||||
NON_CLASSED("non-classed"),
|
||||
OTHER("other");
|
||||
|
||||
private final String _name;
|
||||
|
||||
CompetitionType(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
}
|
@@ -69,9 +69,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 in (?, ?) 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";
|
||||
@@ -107,9 +107,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;
|
||||
@@ -243,9 +240,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);
|
||||
@@ -400,39 +394,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)
|
||||
@@ -445,6 +407,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
|
||||
@@ -722,39 +718,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;
|
||||
|
||||
@@ -821,9 +785,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,9 +832,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))
|
||||
@@ -888,9 +846,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);
|
||||
}
|
||||
@@ -902,10 +857,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();
|
||||
}
|
||||
@@ -1116,7 +1068,7 @@ public class Olympiad extends ListenersContainer
|
||||
}
|
||||
|
||||
// Win/no win matches point bonus
|
||||
points += getCompetitionWon(objectId) > 0 ? 10 : 5;
|
||||
points += getCompetitionWon(objectId) > 0 ? 10 : 0;
|
||||
|
||||
// This is a one time calculation.
|
||||
noble.set(POINTS, 0);
|
||||
@@ -1137,9 +1089,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);
|
||||
}
|
||||
@@ -1209,48 +1158,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
|
||||
@@ -1261,36 +1168,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();
|
||||
|
@@ -52,32 +52,14 @@ public final class OlympiadAnnouncer implements Runnable
|
||||
task = OlympiadGameManager.getInstance().getOlympiadTask(_currentStadium);
|
||||
if ((task != null) && (task.getGame() != null) && task.needAnnounce())
|
||||
{
|
||||
NpcStringId npcString;
|
||||
final String arenaId = String.valueOf(task.getGame().getStadiumId() + 1);
|
||||
switch (task.getGame().getType())
|
||||
{
|
||||
case NON_CLASSED:
|
||||
{
|
||||
npcString = NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
|
||||
break;
|
||||
}
|
||||
case CLASSED:
|
||||
{
|
||||
npcString = NpcStringId.OLYMPIAD_CLASS_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (Spawn spawn : _managers)
|
||||
{
|
||||
final Npc manager = spawn.getLastSpawn();
|
||||
if (manager != null)
|
||||
{
|
||||
manager.broadcastSay(ChatType.NPC_SHOUT, npcString, arenaId);
|
||||
manager.broadcastSay(ChatType.NPC_SHOUT, NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT, arenaId);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public class OlympiadGameClassed extends OlympiadGameNormal
|
||||
{
|
||||
private OlympiadGameClassed(int id, Participant[] opponents)
|
||||
{
|
||||
super(id, opponents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompetitionType getType()
|
||||
{
|
||||
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())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<Integer> list;
|
||||
Participant[] opponents;
|
||||
while (!classList.isEmpty())
|
||||
{
|
||||
list = classList.get(Rnd.get(classList.size()));
|
||||
if ((list == null) || (list.size() < 2))
|
||||
{
|
||||
classList.remove(list);
|
||||
continue;
|
||||
}
|
||||
|
||||
opponents = OlympiadGameNormal.createListOfParticipants(list);
|
||||
if (opponents == null)
|
||||
{
|
||||
classList.remove(list);
|
||||
continue;
|
||||
}
|
||||
|
||||
return new OlympiadGameClassed(id, opponents);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.model.olympiad;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
@@ -88,12 +87,11 @@ public class OlympiadGameManager implements Runnable
|
||||
|
||||
if (Olympiad.getInstance().inCompPeriod())
|
||||
{
|
||||
AbstractOlympiadGame newGame;
|
||||
OlympiadGameNormal newGame;
|
||||
|
||||
List<Set<Integer>> readyClassed = OlympiadManager.getInstance().hasEnoughRegisteredClassed();
|
||||
boolean readyNonClassed = OlympiadManager.getInstance().hasEnoughRegisteredNonClassed();
|
||||
|
||||
if ((readyClassed != null) || readyNonClassed)
|
||||
if (readyNonClassed)
|
||||
{
|
||||
// reset delay broadcast
|
||||
_delay = 0;
|
||||
@@ -106,23 +104,11 @@ public class OlympiadGameManager implements Runnable
|
||||
{
|
||||
if (!task.isRunning())
|
||||
{
|
||||
// Fair arena distribution
|
||||
// 0,2,4,6,8.. arenas checked for classed or teams first
|
||||
if (readyClassed != null)
|
||||
{
|
||||
newGame = OlympiadGameClassed.createGame(i, readyClassed);
|
||||
if (newGame != null)
|
||||
{
|
||||
task.attachGame(newGame);
|
||||
continue;
|
||||
}
|
||||
readyClassed = null;
|
||||
}
|
||||
// 1,3,5,7,9.. arenas used for non-classed
|
||||
// also other arenas will be used for non-classed if no classed or teams available
|
||||
if (readyNonClassed)
|
||||
{
|
||||
newGame = OlympiadGameNonClassed.createGame(i, OlympiadManager.getInstance().getRegisteredNonClassBased());
|
||||
newGame = OlympiadGameNormal.createGame(i, OlympiadManager.getInstance().getPlayerRegistered());
|
||||
if (newGame != null)
|
||||
{
|
||||
task.attachGame(newGame);
|
||||
@@ -134,7 +120,7 @@ public class OlympiadGameManager implements Runnable
|
||||
}
|
||||
|
||||
// stop generating games if no more participants
|
||||
if ((readyClassed == null) && !readyNonClassed)
|
||||
if (!readyNonClassed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -146,7 +132,7 @@ public class OlympiadGameManager implements Runnable
|
||||
_delay++;
|
||||
if (_delay >= 10) // 5min
|
||||
{
|
||||
for (Integer id : OlympiadManager.getInstance().getRegisteredNonClassBased())
|
||||
for (Integer id : OlympiadManager.getInstance().getPlayerRegistered())
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
@@ -159,24 +145,6 @@ public class OlympiadGameManager implements Runnable
|
||||
noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
|
||||
}
|
||||
}
|
||||
|
||||
for (Set<Integer> list : OlympiadManager.getInstance().getRegisteredClassBased().values())
|
||||
{
|
||||
for (Integer id : list)
|
||||
{
|
||||
if (id == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final PlayerInstance noble = World.getInstance().getPlayer(id);
|
||||
if (noble != null)
|
||||
{
|
||||
noble.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_GAMES_MAY_BE_DELAYED_DUE_TO_AN_INSUFFICIENT_NUMBER_OF_PLAYERS_WAITING));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_delay = 0;
|
||||
}
|
||||
}
|
||||
@@ -234,7 +202,7 @@ public class OlympiadGameManager implements Runnable
|
||||
return;
|
||||
}
|
||||
|
||||
final AbstractOlympiadGame game = _tasks.get(id).getTask().getGame();
|
||||
final OlympiadGameNormal game = _tasks.get(id).getTask().getGame();
|
||||
if (game != null)
|
||||
{
|
||||
game.addDamage(attacker, damage);
|
||||
|
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public class OlympiadGameNonClassed extends OlympiadGameNormal
|
||||
{
|
||||
public OlympiadGameNonClassed(int id, Participant[] opponents)
|
||||
{
|
||||
super(id, opponents);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompetitionType getType()
|
||||
{
|
||||
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);
|
||||
if (opponents == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new OlympiadGameNonClassed(id, opponents);
|
||||
}
|
||||
}
|
@@ -24,37 +24,62 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import org.l2jmobius.gameserver.instancemanager.AntiFeedManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import org.l2jmobius.gameserver.model.Location;
|
||||
import org.l2jmobius.gameserver.model.Party;
|
||||
import org.l2jmobius.gameserver.model.Party.MessageType;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Summon;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import org.l2jmobius.gameserver.model.events.impl.olympiad.OnOlympiadMatchResult;
|
||||
import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMatchResult;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadMode;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExOlympiadUserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author GodKratos, Pere, DS
|
||||
*/
|
||||
public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
public class OlympiadGameNormal
|
||||
{
|
||||
protected int _damageP1 = 0;
|
||||
protected int _damageP2 = 0;
|
||||
private int _damageP1 = 0;
|
||||
private int _damageP2 = 0;
|
||||
|
||||
protected Participant _playerOne;
|
||||
protected Participant _playerTwo;
|
||||
private Participant _playerOne;
|
||||
private Participant _playerTwo;
|
||||
|
||||
protected OlympiadGameNormal(int id, Participant[] opponents)
|
||||
private static final Logger LOGGER = Logger.getLogger(OlympiadGameNormal.class.getName());
|
||||
private static final Logger LOGGER_OLYMPIAD = Logger.getLogger("olympiad");
|
||||
|
||||
private static final String POINTS = "olympiad_points";
|
||||
private static final String COMP_DONE = "competitions_done";
|
||||
private static final String COMP_WON = "competitions_won";
|
||||
private static final String COMP_LOST = "competitions_lost";
|
||||
private static final String COMP_DRAWN = "competitions_drawn";
|
||||
private static final String COMP_DONE_WEEK = "competitions_done_week";
|
||||
|
||||
private long _startTime = 0;
|
||||
private final boolean _aborted = false;
|
||||
private final int _stadiumId;
|
||||
|
||||
public OlympiadGameNormal(int id, Participant[] opponents)
|
||||
{
|
||||
super(id);
|
||||
_stadiumId = id;
|
||||
|
||||
_playerOne = opponents[0];
|
||||
_playerTwo = opponents[1];
|
||||
@@ -63,6 +88,17 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
_playerTwo.getPlayer().setOlympiadGameId(id);
|
||||
}
|
||||
|
||||
protected static OlympiadGameNormal createGame(int id, Set<Integer> list)
|
||||
{
|
||||
final Participant[] opponents = OlympiadGameNormal.createListOfParticipants(list);
|
||||
if (opponents == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new OlympiadGameNormal(id, opponents);
|
||||
}
|
||||
|
||||
protected static Participant[] createListOfParticipants(Set<Integer> set)
|
||||
{
|
||||
if ((set == null) || set.isEmpty() || (set.size() < 2))
|
||||
@@ -122,27 +158,23 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean containsParticipant(int playerId)
|
||||
{
|
||||
return ((_playerOne != null) && (_playerOne.getObjectId() == playerId)) || ((_playerTwo != null) && (_playerTwo.getObjectId() == playerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void sendOlympiadInfo(Creature creature)
|
||||
{
|
||||
creature.sendPacket(new ExOlympiadUserInfo(_playerOne));
|
||||
creature.sendPacket(new ExOlympiadUserInfo(_playerTwo));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void broadcastOlympiadInfo(OlympiadStadium stadium)
|
||||
{
|
||||
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerOne));
|
||||
stadium.broadcastPacket(new ExOlympiadUserInfo(_playerTwo));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void broadcastPacket(IClientOutgoingPacket packet)
|
||||
{
|
||||
if (_playerOne.updatePlayer())
|
||||
@@ -156,7 +188,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean portPlayersToArena(List<Location> spawns, Instance instance)
|
||||
{
|
||||
boolean result = true;
|
||||
@@ -173,13 +204,11 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needBuffers()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void removals()
|
||||
{
|
||||
if (_aborted)
|
||||
@@ -191,14 +220,8 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
removals(_playerTwo.getPlayer(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean makeCompetitionStart()
|
||||
{
|
||||
if (!super.makeCompetitionStart())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
|
||||
{
|
||||
return false;
|
||||
@@ -211,48 +234,49 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
return true;
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
private boolean checkOnline(Participant player)
|
||||
{
|
||||
return (player.getPlayer() != null) && !player.isDefaulted() && !player.isDisconnected();
|
||||
}
|
||||
|
||||
protected final void clearPlayers()
|
||||
{
|
||||
_playerOne.setPlayer(null);
|
||||
@@ -261,7 +285,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
_playerTwo = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void handleDisconnect(PlayerInstance player)
|
||||
{
|
||||
if (player.getObjectId() == _playerOne.getObjectId())
|
||||
@@ -274,7 +297,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean checkBattleStatus()
|
||||
{
|
||||
if (_aborted)
|
||||
@@ -295,7 +317,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean haveWinner()
|
||||
{
|
||||
if (!checkBattleStatus())
|
||||
@@ -332,7 +353,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
return playerOneLost || playerTwoLost;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateWinner(OlympiadStadium stadium)
|
||||
{
|
||||
if (_aborted)
|
||||
@@ -353,7 +373,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;
|
||||
@@ -383,7 +403,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
if (Config.ALT_OLY_LOG_FIGHTS)
|
||||
{
|
||||
LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
|
||||
LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -410,7 +430,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
if (Config.ALT_OLY_LOG_FIGHTS)
|
||||
{
|
||||
LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
|
||||
LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -457,15 +477,13 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
winside = 1;
|
||||
|
||||
rewardParticipant(_playerOne.getPlayer(), getReward());
|
||||
|
||||
if (Config.ALT_OLY_LOG_FIGHTS)
|
||||
{
|
||||
LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
|
||||
LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
|
||||
}
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
|
||||
}
|
||||
else if (_pOneCrash && !_pTwoCrash)
|
||||
{
|
||||
@@ -483,14 +501,12 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
winside = 2;
|
||||
|
||||
rewardParticipant(_playerTwo.getPlayer(), getReward());
|
||||
|
||||
if (Config.ALT_OLY_LOG_FIGHTS)
|
||||
{
|
||||
LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
|
||||
LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff);
|
||||
}
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
|
||||
}
|
||||
else if (_pOneCrash && _pTwoCrash)
|
||||
{
|
||||
@@ -508,7 +524,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
if (Config.ALT_OLY_LOG_FIGHTS)
|
||||
{
|
||||
LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff + "," + getType());
|
||||
LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,8 +532,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)
|
||||
{
|
||||
@@ -530,8 +544,8 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
stadium.broadcastPacket(result);
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne, getType()), Olympiad.getInstance());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo, getType()), Olympiad.getInstance());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerOne), Olympiad.getInstance());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(null, _playerTwo), Olympiad.getInstance());
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -598,11 +612,10 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
winside = 1;
|
||||
|
||||
// Save Fight Result
|
||||
saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime, getType());
|
||||
rewardParticipant(_playerOne.getPlayer(), getReward());
|
||||
saveResults(_playerOne, _playerTwo, 1, _startTime, _fightTime);
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo, getType()), Olympiad.getInstance());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerOne, _playerTwo), Olympiad.getInstance());
|
||||
}
|
||||
else if ((_playerOne.getPlayer() == null) || !_playerOne.getPlayer().isOnline() || ((playerOneHp == 0) && (playerTwoHp != 0)) || ((_damageP2 > _damageP1) && (playerOneHp != 0) && (playerTwoHp != 0)))
|
||||
{
|
||||
@@ -623,26 +636,25 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
winside = 2;
|
||||
|
||||
// Save Fight Result
|
||||
saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime, getType());
|
||||
rewardParticipant(_playerTwo.getPlayer(), getReward());
|
||||
saveResults(_playerOne, _playerTwo, 2, _startTime, _fightTime);
|
||||
|
||||
// Notify to scripts
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne), Olympiad.getInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save Fight Result
|
||||
saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime, getType());
|
||||
saveResults(_playerOne, _playerTwo, 0, _startTime, _fightTime);
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -668,7 +678,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
|
||||
if (Config.ALT_OLY_LOG_FIGHTS)
|
||||
{
|
||||
LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff + "," + getType());
|
||||
LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -677,7 +687,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void addDamage(PlayerInstance player, int damage)
|
||||
{
|
||||
if ((_playerOne.getPlayer() == null) || (_playerTwo.getPlayer() == null))
|
||||
@@ -694,7 +703,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String[] getPlayerNames()
|
||||
{
|
||||
return new String[]
|
||||
@@ -704,7 +712,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkDefaulted()
|
||||
{
|
||||
SystemMessage reason;
|
||||
@@ -734,17 +741,16 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
return _playerOne.isDefaulted() || _playerTwo.isDefaulted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void resetDamage()
|
||||
{
|
||||
_damageP1 = 0;
|
||||
_damageP2 = 0;
|
||||
}
|
||||
|
||||
protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type)
|
||||
protected static void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time, classed) values(?,?,?,?,?,?,?,?)"))
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO olympiad_fights (charOneId, charTwoId, charOneClass, charTwoClass, winner, start, time) values(?,?,?,?,?,?,?)"))
|
||||
{
|
||||
statement.setInt(1, one.getObjectId());
|
||||
statement.setInt(2, two.getObjectId());
|
||||
@@ -753,7 +759,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
statement.setInt(5, winner);
|
||||
statement.setLong(6, startTime);
|
||||
statement.setLong(7, fightTime);
|
||||
statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0));
|
||||
statement.execute();
|
||||
}
|
||||
catch (SQLException e)
|
||||
@@ -762,7 +767,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void healPlayers()
|
||||
{
|
||||
final PlayerInstance player1 = _playerOne.getPlayer();
|
||||
@@ -782,7 +786,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void untransformPlayers()
|
||||
{
|
||||
final PlayerInstance player1 = _playerOne.getPlayer();
|
||||
@@ -798,7 +801,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void makePlayersInvul()
|
||||
{
|
||||
if (_playerOne.getPlayer() != null)
|
||||
@@ -811,7 +813,6 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void removePlayersInvul()
|
||||
{
|
||||
if (_playerOne.getPlayer() != null)
|
||||
@@ -823,4 +824,341 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
|
||||
_playerTwo.getPlayer().setIsInvul(false);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isAborted()
|
||||
{
|
||||
return _aborted;
|
||||
}
|
||||
|
||||
public final int getStadiumId()
|
||||
{
|
||||
return _stadiumId;
|
||||
}
|
||||
|
||||
protected boolean makeCompetitionStart1()
|
||||
{
|
||||
_startTime = System.currentTimeMillis();
|
||||
return !_aborted;
|
||||
}
|
||||
|
||||
protected final void addPointsToParticipant(Participant par, int points)
|
||||
{
|
||||
par.updateStat(POINTS, points);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_EARNED_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
|
||||
sm.addString(par.getName());
|
||||
sm.addInt(points);
|
||||
broadcastPacket(sm);
|
||||
}
|
||||
|
||||
protected final void removePointsFromParticipant(Participant par, int points)
|
||||
{
|
||||
par.updateStat(POINTS, -points);
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HAS_LOST_S2_POINTS_IN_THE_OLYMPIAD_GAMES);
|
||||
sm.addString(par.getName());
|
||||
sm.addInt(points);
|
||||
broadcastPacket(sm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function return null if player passed all checks or SystemMessage with reason for broadcast to opponent(s).
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
protected static SystemMessage checkDefaulted(PlayerInstance player)
|
||||
{
|
||||
if ((player == null) || !player.isOnline())
|
||||
{
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
|
||||
if ((player.getClient() == null) || player.getClient().isDetached())
|
||||
{
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_MADE_HASTE_WITH_THEIR_TAIL_BETWEEN_THEIR_LEGS_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
|
||||
// safety precautions
|
||||
if (player.inObserverMode())
|
||||
{
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
|
||||
SystemMessage sm;
|
||||
if (player.isDead())
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_CURRENTLY_DEAD_AND_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
|
||||
sm.addPcName(player);
|
||||
player.sendPacket(sm);
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
if (player.isSubClassActive())
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_YOU_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD_BECAUSE_YOU_HAVE_CHANGED_YOUR_CLASS_TO_SUBCLASS);
|
||||
sm.addPcName(player);
|
||||
player.sendPacket(sm);
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
if (player.isCursedWeaponEquipped())
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_THE_OWNER_OF_S2_CANNOT_PARTICIPATE_IN_THE_OLYMPIAD);
|
||||
sm.addPcName(player);
|
||||
sm.addItemName(player.getCursedWeaponEquippedId());
|
||||
player.sendPacket(sm);
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
if (!player.isInventoryUnder90(true))
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.C1_DOES_NOT_MEET_THE_PARTICIPATION_REQUIREMENTS_AS_THE_INVENTORY_WEIGHT_SLOT_IS_FILLED_BEYOND_80);
|
||||
sm.addPcName(player);
|
||||
player.sendPacket(sm);
|
||||
return SystemMessage.getSystemMessage(SystemMessageId.YOUR_OPPONENT_DOES_NOT_MEET_THE_REQUIREMENTS_TO_DO_BATTLE_THE_MATCH_HAS_BEEN_CANCELLED);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static boolean portPlayerToArena(Participant par, Location loc, int id, Instance instance)
|
||||
{
|
||||
final PlayerInstance player = par.getPlayer();
|
||||
if ((player == null) || !player.isOnline())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
player.setLastLocation();
|
||||
if (player.isSitting())
|
||||
{
|
||||
player.standUp();
|
||||
}
|
||||
player.setTarget(null);
|
||||
|
||||
player.setOlympiadGameId(id);
|
||||
player.setIsInOlympiadMode(true);
|
||||
player.setIsOlympiadStart(false);
|
||||
player.setOlympiadSide(par.getSide());
|
||||
player.teleToLocation(loc, instance);
|
||||
player.sendPacket(new ExOlympiadMode(2));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected static void removals(PlayerInstance player, boolean removeParty)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove Buffs
|
||||
player.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
|
||||
// Remove Clan Skills
|
||||
if (player.getClan() != null)
|
||||
{
|
||||
player.getClan().removeSkillEffects(player);
|
||||
if (player.getClan().getCastleId() > 0)
|
||||
{
|
||||
CastleManager.getInstance().getCastleByOwner(player.getClan()).removeResidentialSkills(player);
|
||||
}
|
||||
if (player.getClan().getFortId() > 0)
|
||||
{
|
||||
FortManager.getInstance().getFortByOwner(player.getClan()).removeResidentialSkills(player);
|
||||
}
|
||||
}
|
||||
// Abort casting if player casting
|
||||
player.abortAttack();
|
||||
player.abortCast();
|
||||
|
||||
// Force the character to be visible
|
||||
player.setInvisible(false);
|
||||
|
||||
// Heal Player fully
|
||||
player.setCurrentCp(player.getMaxCp());
|
||||
player.setCurrentHp(player.getMaxHp());
|
||||
player.setCurrentMp(player.getMaxMp());
|
||||
|
||||
// Remove Summon's Buffs
|
||||
if (player.hasSummon())
|
||||
{
|
||||
final Summon pet = player.getPet();
|
||||
if (pet != null)
|
||||
{
|
||||
pet.unSummon(player);
|
||||
}
|
||||
|
||||
player.getServitors().values().forEach(s ->
|
||||
{
|
||||
s.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
s.abortAttack();
|
||||
s.abortCast();
|
||||
});
|
||||
}
|
||||
|
||||
// stop any cubic that has been given by other player.
|
||||
player.stopCubicsByOthers();
|
||||
|
||||
// Remove player from his party
|
||||
if (removeParty)
|
||||
{
|
||||
final Party party = player.getParty();
|
||||
if (party != null)
|
||||
{
|
||||
party.removePartyMember(player, MessageType.EXPELLED);
|
||||
}
|
||||
}
|
||||
// Remove Agathion
|
||||
if (player.getAgathionId() > 0)
|
||||
{
|
||||
player.setAgathionId(0);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
|
||||
player.checkItemRestriction();
|
||||
|
||||
// Remove shot automation
|
||||
player.disableAutoShotsAll();
|
||||
|
||||
// Discharge any active shots
|
||||
player.unchargeAllShots();
|
||||
|
||||
// enable skills with cool time <= 15 minutes
|
||||
for (Skill skill : player.getAllSkills())
|
||||
{
|
||||
if (skill.getReuseDelay() <= 900000)
|
||||
{
|
||||
player.enableSkill(skill);
|
||||
}
|
||||
}
|
||||
|
||||
player.sendSkillList();
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void cleanEffects(PlayerInstance player)
|
||||
{
|
||||
try
|
||||
{
|
||||
// prevent players kill each other
|
||||
player.setIsOlympiadStart(false);
|
||||
player.setTarget(null);
|
||||
player.abortAttack();
|
||||
player.abortCast();
|
||||
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
|
||||
if (player.isDead())
|
||||
{
|
||||
player.setIsDead(false);
|
||||
}
|
||||
|
||||
player.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
player.clearSouls();
|
||||
player.clearCharges();
|
||||
if (player.getAgathionId() > 0)
|
||||
{
|
||||
player.setAgathionId(0);
|
||||
}
|
||||
final Summon pet = player.getPet();
|
||||
if ((pet != null) && !pet.isDead())
|
||||
{
|
||||
pet.setTarget(null);
|
||||
pet.abortAttack();
|
||||
pet.abortCast();
|
||||
pet.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
pet.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
}
|
||||
|
||||
player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s ->
|
||||
{
|
||||
s.setTarget(null);
|
||||
s.abortAttack();
|
||||
s.abortCast();
|
||||
s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
s.stopAllEffectsExceptThoseThatLastThroughDeath();
|
||||
});
|
||||
|
||||
player.setCurrentCp(player.getMaxCp());
|
||||
player.setCurrentHp(player.getMaxHp());
|
||||
player.setCurrentMp(player.getMaxMp());
|
||||
player.getStatus().startHpMpRegeneration();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void playerStatusBack(PlayerInstance player)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (player.isTransformed())
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
|
||||
player.setIsInOlympiadMode(false);
|
||||
player.setIsOlympiadStart(false);
|
||||
player.setOlympiadSide(-1);
|
||||
player.setOlympiadGameId(-1);
|
||||
player.sendPacket(new ExOlympiadMode(0));
|
||||
|
||||
// Add Clan Skills
|
||||
if (player.getClan() != null)
|
||||
{
|
||||
player.getClan().addSkillEffects(player);
|
||||
if (player.getClan().getCastleId() > 0)
|
||||
{
|
||||
CastleManager.getInstance().getCastleByOwner(player.getClan()).giveResidentialSkills(player);
|
||||
}
|
||||
if (player.getClan().getFortId() > 0)
|
||||
{
|
||||
FortManager.getInstance().getFortByOwner(player.getClan()).giveResidentialSkills(player);
|
||||
}
|
||||
player.sendSkillList();
|
||||
}
|
||||
|
||||
// heal again after adding clan skills
|
||||
player.setCurrentCp(player.getMaxCp());
|
||||
player.setCurrentHp(player.getMaxHp());
|
||||
player.setCurrentMp(player.getMaxMp());
|
||||
player.getStatus().startHpMpRegeneration();
|
||||
|
||||
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
|
||||
{
|
||||
AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, player);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "playerStatusBack()", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void portPlayerBack(PlayerInstance player)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Location loc = player.getLastLocation();
|
||||
if (loc != null)
|
||||
{
|
||||
player.setIsPendingRevive(false);
|
||||
player.teleToLocation(loc, null);
|
||||
player.unsetLastLocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ public final class OlympiadGameTask implements Runnable
|
||||
};
|
||||
|
||||
private final OlympiadStadium _stadium;
|
||||
private AbstractOlympiadGame _game;
|
||||
private OlympiadGameNormal _game;
|
||||
private GameState _state = GameState.IDLE;
|
||||
private boolean _needAnnounce = false;
|
||||
private int _countDown = 0;
|
||||
@@ -154,12 +154,12 @@ public final class OlympiadGameTask implements Runnable
|
||||
return _stadium;
|
||||
}
|
||||
|
||||
public final AbstractOlympiadGame getGame()
|
||||
public final OlympiadGameNormal getGame()
|
||||
{
|
||||
return _game;
|
||||
}
|
||||
|
||||
public final void attachGame(AbstractOlympiadGame game)
|
||||
public final void attachGame(OlympiadGameNormal game)
|
||||
{
|
||||
if ((game != null) && (_state != GameState.IDLE))
|
||||
{
|
||||
|
@@ -16,10 +16,6 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.olympiad;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -36,8 +32,7 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
*/
|
||||
public class OlympiadManager
|
||||
{
|
||||
private final Set<Integer> _nonClassBasedRegisters = ConcurrentHashMap.newKeySet();
|
||||
private final Map<Integer, Set<Integer>> _classBasedRegisters = new ConcurrentHashMap<>();
|
||||
private final Set<Integer> _playerRegistered = ConcurrentHashMap.newKeySet();
|
||||
|
||||
protected OlympiadManager()
|
||||
{
|
||||
@@ -48,43 +43,19 @@ public class OlympiadManager
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public final Set<Integer> getRegisteredNonClassBased()
|
||||
public final Set<Integer> getPlayerRegistered()
|
||||
{
|
||||
return _nonClassBasedRegisters;
|
||||
}
|
||||
|
||||
public final Map<Integer, Set<Integer>> getRegisteredClassBased()
|
||||
{
|
||||
return _classBasedRegisters;
|
||||
}
|
||||
|
||||
protected final List<Set<Integer>> hasEnoughRegisteredClassed()
|
||||
{
|
||||
List<Set<Integer>> result = null;
|
||||
for (Map.Entry<Integer, Set<Integer>> classList : _classBasedRegisters.entrySet())
|
||||
{
|
||||
if ((classList.getValue() != null) && (classList.getValue().size() >= Config.ALT_OLY_CLASSED))
|
||||
{
|
||||
if (result == null)
|
||||
{
|
||||
result = new ArrayList<>();
|
||||
}
|
||||
|
||||
result.add(classList.getValue());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return _playerRegistered;
|
||||
}
|
||||
|
||||
protected final boolean hasEnoughRegisteredNonClassed()
|
||||
{
|
||||
return _nonClassBasedRegisters.size() >= Config.ALT_OLY_NONCLASSED;
|
||||
return _playerRegistered.size() >= Config.ALT_OLY_NONCLASSED;
|
||||
}
|
||||
|
||||
protected final void clearRegistered()
|
||||
{
|
||||
_nonClassBasedRegisters.clear();
|
||||
_classBasedRegisters.clear();
|
||||
_playerRegistered.clear();
|
||||
AntiFeedManager.getInstance().clear(AntiFeedManager.OLYMPIAD_ID);
|
||||
}
|
||||
|
||||
@@ -96,7 +67,7 @@ public class OlympiadManager
|
||||
private boolean isRegistered(PlayerInstance noble, PlayerInstance player, boolean showMessage)
|
||||
{
|
||||
final Integer objId = Integer.valueOf(noble.getObjectId());
|
||||
if (_nonClassBasedRegisters.contains(objId))
|
||||
if (_playerRegistered.contains(objId))
|
||||
{
|
||||
if (showMessage)
|
||||
{
|
||||
@@ -106,19 +77,6 @@ public class OlympiadManager
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
final Set<Integer> classed = _classBasedRegisters.get(getClassGroup(noble));
|
||||
if ((classed != null) && classed.contains(objId))
|
||||
{
|
||||
if (showMessage)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
|
||||
sm.addPcName(noble);
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -134,7 +92,7 @@ public class OlympiadManager
|
||||
return false;
|
||||
}
|
||||
|
||||
AbstractOlympiadGame game;
|
||||
OlympiadGameNormal game;
|
||||
for (int i = OlympiadGameManager.getInstance().getNumberOfStadiums(); --i >= 0;)
|
||||
{
|
||||
game = OlympiadGameManager.getInstance().getOlympiadTask(i).getGame();
|
||||
@@ -150,30 +108,17 @@ public class OlympiadManager
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (game.getType())
|
||||
{
|
||||
case CLASSED:
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_CLASS_MATCH_WAITING_LIST);
|
||||
sm.addPcName(noble);
|
||||
player.sendPacket(sm);
|
||||
break;
|
||||
}
|
||||
case NON_CLASSED:
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
|
||||
sm.addPcName(noble);
|
||||
player.sendPacket(sm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_IS_ALREADY_REGISTERED_ON_THE_WAITING_LIST_FOR_THE_ALL_CLASS_BATTLE);
|
||||
sm.addPcName(noble);
|
||||
player.sendPacket(sm);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final boolean registerNoble(PlayerInstance player, CompetitionType type)
|
||||
public final boolean registerNoble(PlayerInstance player)
|
||||
{
|
||||
if (!Olympiad._inCompPeriod)
|
||||
{
|
||||
@@ -181,7 +126,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;
|
||||
@@ -194,63 +139,24 @@ public class OlympiadManager
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
if (player.isOnEvent())
|
||||
{
|
||||
case CLASSED:
|
||||
{
|
||||
if (player.isOnEvent())
|
||||
{
|
||||
player.sendMessage("You can't join olympiad while participating on an Event.");
|
||||
return false;
|
||||
}
|
||||
|
||||
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());
|
||||
message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
|
||||
message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
|
||||
player.sendPacket(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Olympiad.getInstance().getRemainingWeeklyMatchesClassed(charId) < 1)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ENTER_UP_TO_30_FREE_FOR_ALL_BATTLES_AND_30_CLASS_SPECIFIC_BATTLES_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;
|
||||
}
|
||||
case NON_CLASSED:
|
||||
{
|
||||
if (player.isOnEvent())
|
||||
{
|
||||
player.sendMessage("You can't join olympiad while participating on TvT Event.");
|
||||
return false;
|
||||
}
|
||||
|
||||
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());
|
||||
message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
|
||||
message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
|
||||
player.sendPacket(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed(charId) < 1)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CAN_ENTER_UP_TO_30_FREE_FOR_ALL_BATTLES_AND_30_CLASS_SPECIFIC_BATTLES_PER_WEEK);
|
||||
return false;
|
||||
}
|
||||
|
||||
_nonClassBasedRegisters.add(charId);
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
|
||||
break;
|
||||
}
|
||||
player.sendMessage("You can't join olympiad while participating on TvT Event.");
|
||||
return false;
|
||||
}
|
||||
|
||||
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());
|
||||
message.setFile(player, "data/html/mods/OlympiadIPRestriction.htm");
|
||||
message.replace("%max%", String.valueOf(AntiFeedManager.getInstance().getLimit(player, Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP)));
|
||||
player.sendPacket(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
_playerRegistered.add(charId);
|
||||
player.sendPacket(SystemMessageId.YOU_ARE_CURRENTLY_REGISTERED_FOR_A_1V1_CLASS_IRRELEVANT_MATCH);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -282,19 +188,7 @@ public class OlympiadManager
|
||||
}
|
||||
|
||||
final Integer objId = Integer.valueOf(noble.getObjectId());
|
||||
if (_nonClassBasedRegisters.remove(objId))
|
||||
{
|
||||
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
|
||||
{
|
||||
AntiFeedManager.getInstance().removePlayer(AntiFeedManager.OLYMPIAD_ID, noble);
|
||||
}
|
||||
|
||||
noble.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REMOVED_FROM_THE_OLYMPIAD_WAITING_LIST);
|
||||
return true;
|
||||
}
|
||||
|
||||
final Set<Integer> classed = _classBasedRegisters.get(getClassGroup(noble));
|
||||
if ((classed != null) && classed.remove(objId))
|
||||
if (_playerRegistered.remove(objId))
|
||||
{
|
||||
if (Config.DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP > 0)
|
||||
{
|
||||
@@ -315,67 +209,16 @@ public class OlympiadManager
|
||||
{
|
||||
task.getGame().handleDisconnect(player);
|
||||
}
|
||||
|
||||
final Integer objId = Integer.valueOf(player.getObjectId());
|
||||
if (_nonClassBasedRegisters.remove(objId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_classBasedRegisters.getOrDefault(getClassGroup(player), Collections.emptySet()).remove(objId);
|
||||
_playerRegistered.remove(player.getObjectId());
|
||||
}
|
||||
|
||||
public int getCountOpponents()
|
||||
{
|
||||
return _nonClassBasedRegisters.size() + _classBasedRegisters.size();
|
||||
return _playerRegistered.size();
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final OlympiadManager INSTANCE = new OlympiadManager();
|
||||
}
|
||||
|
||||
private int getClassGroup(PlayerInstance player)
|
||||
{
|
||||
if (player.isInCategory(CategoryType.SIXTH_TIR_GROUP))
|
||||
{
|
||||
return 1001;
|
||||
}
|
||||
else if (player.isInCategory(CategoryType.SIXTH_SIGEL_GROUP))
|
||||
{
|
||||
return 1002;
|
||||
}
|
||||
else if (player.isInCategory(CategoryType.SIXTH_OTHEL_GROUP))
|
||||
{
|
||||
return 1003;
|
||||
}
|
||||
else if (player.isInCategory(CategoryType.SIXTH_FEOH_GROUP))
|
||||
{
|
||||
return 1004;
|
||||
}
|
||||
else if (player.isInCategory(CategoryType.SIXTH_IS_GROUP))
|
||||
{
|
||||
return 1005;
|
||||
}
|
||||
else if (player.isInCategory(CategoryType.SIXTH_EOLH_GROUP))
|
||||
{
|
||||
return 1006;
|
||||
}
|
||||
else if (player.isInCategory(CategoryType.SIXTH_WYNN_GROUP))
|
||||
{
|
||||
return 1007;
|
||||
}
|
||||
else if (player.isInCategory(CategoryType.SIXTH_YR_GROUP))
|
||||
{
|
||||
return 1008;
|
||||
}
|
||||
else if (player.isInCategory(CategoryType.ERTHEIA_FOURTH_CLASS_GROUP))
|
||||
{
|
||||
return 1009;
|
||||
}
|
||||
else
|
||||
{
|
||||
return player.getBaseClass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -67,7 +67,6 @@ import org.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import org.l2jmobius.gameserver.model.interfaces.IIdentifiable;
|
||||
import org.l2jmobius.gameserver.model.items.Item;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.model.olympiad.CompetitionType;
|
||||
import org.l2jmobius.gameserver.model.olympiad.Participant;
|
||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||
@@ -924,13 +923,12 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
/**
|
||||
* @param winner
|
||||
* @param looser
|
||||
* @param type
|
||||
*/
|
||||
public final void notifyOlympiadMatch(Participant winner, Participant looser, CompetitionType type)
|
||||
public final void notifyOlympiadMatch(Participant winner, Participant looser)
|
||||
{
|
||||
try
|
||||
{
|
||||
onOlympiadMatchFinish(winner, looser, type);
|
||||
onOlympiadMatchFinish(winner, looser);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -1360,18 +1358,16 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
* This function is called whenever a player wins an Olympiad Game.
|
||||
* @param winner in this match.
|
||||
* @param looser in this match.
|
||||
* @param type the competition type.
|
||||
*/
|
||||
public void onOlympiadMatchFinish(Participant winner, Participant looser, CompetitionType type)
|
||||
public void onOlympiadMatchFinish(Participant winner, Participant looser)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called whenever a player looses an Olympiad Game.
|
||||
* @param loser this parameter contains a reference to the exact instance of the player who lose the competition.
|
||||
* @param type this parameter contains a reference to the competition type.
|
||||
*/
|
||||
public void onOlympiadLose(PlayerInstance loser, CompetitionType type)
|
||||
public void onOlympiadLose(PlayerInstance loser)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -2281,7 +2277,7 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
|
||||
public void addOlympiadMatchFinishId()
|
||||
{
|
||||
setOlympiadMatchResult(event -> notifyOlympiadMatch(event.getWinner(), event.getLoser(), event.getCompetitionType()));
|
||||
setOlympiadMatchResult(event -> notifyOlympiadMatch(event.getWinner(), event.getLoser()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,10 +20,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.olympiad.AbstractOlympiadGame;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameClassed;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameNormal;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
@@ -63,24 +61,11 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket
|
||||
|
||||
for (OlympiadGameTask curGame : _games)
|
||||
{
|
||||
final AbstractOlympiadGame game = curGame.getGame();
|
||||
final OlympiadGameNormal game = curGame.getGame();
|
||||
if (game != null)
|
||||
{
|
||||
packet.writeD(game.getStadiumId()); // Stadium Id (Arena 1 = 0)
|
||||
|
||||
if (game instanceof OlympiadGameNonClassed)
|
||||
{
|
||||
packet.writeD(1);
|
||||
}
|
||||
else if (game instanceof OlympiadGameClassed)
|
||||
{
|
||||
packet.writeD(2);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.writeD(0);
|
||||
}
|
||||
|
||||
packet.writeD(1); // Classed is 2, Non Classed is 1, Other is 0
|
||||
packet.writeD(curGame.isRunning() ? 0x02 : 0x01); // (1 = Standby, 2 = Playing)
|
||||
packet.writeS(game.getPlayerNames()[0]); // Player 1 Name
|
||||
packet.writeS(game.getPlayerNames()[1]); // Player 2 Name
|
||||
|
Reference in New Issue
Block a user