diff --git a/L2J_Mobius_08.2_Homunculus/dist/db_installer/sql/game/olympiad_fights.sql b/L2J_Mobius_08.2_Homunculus/dist/db_installer/sql/game/olympiad_fights.sql index 618ee73db0..15ffc8332b 100644 --- a/L2J_Mobius_08.2_Homunculus/dist/db_installer/sql/game/olympiad_fights.sql +++ b/L2J_Mobius_08.2_Homunculus/dist/db_installer/sql/game/olympiad_fights.sql @@ -4,6 +4,8 @@ CREATE TABLE IF NOT EXISTS `olympiad_fights` ( `charTwoId` int(10) unsigned NOT NULL, `charOneClass` tinyint(3) unsigned NOT NULL DEFAULT '0', `charTwoClass` tinyint(3) unsigned NOT NULL DEFAULT '0', + `charOneLevel` int(5) unsigned NOT NULL DEFAULT '0', + `charTwoLevel` int(5) unsigned NOT NULL DEFAULT '0', `winner` tinyint(1) unsigned NOT NULL DEFAULT '0', `start` bigint(13) unsigned NOT NULL DEFAULT '0', `time` bigint(13) unsigned NOT NULL DEFAULT '0', diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java index c93a046978..f4d66bc22a 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -254,6 +254,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.PlayerRefund; import org.l2jmobius.gameserver.model.itemcontainer.PlayerWarehouse; import org.l2jmobius.gameserver.model.matching.MatchingRoom; import org.l2jmobius.gameserver.model.olympiad.Hero; +import org.l2jmobius.gameserver.model.olympiad.OlympiadFightHistory; import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager; import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask; import org.l2jmobius.gameserver.model.olympiad.OlympiadManager; @@ -835,6 +836,8 @@ public class Player extends Playable private Map _customSkills = null; public final Set _replacedSkills = ConcurrentHashMap.newKeySet(1); + private final OlympiadFightHistory _olympiadFightHistory = new OlympiadFightHistory(this); + private volatile int _actionMask; private int _questZoneId = -1; @@ -13545,6 +13548,11 @@ public class Player extends Playable return _replacedSkills.contains(skillId); } + public OlympiadFightHistory getOlympiadFightHistory() + { + return _olympiadFightHistory; + } + /** * @return {@code true} if current player can revive and shows 'To Village' button upon death, {@code false} otherwise. */ diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java new file mode 100644 index 0000000000..29e288c309 --- /dev/null +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java @@ -0,0 +1,56 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model.olympiad; + +/** + * @author dontknowdontcare + */ +public class OlympiadFight +{ + private final String _opponentName; + private final int _opponentClassId; + private final int _winner; // 0 = win, 1 = loss, 2 = draw + private final int _opponentLevel; + + public OlympiadFight(String opponentName, int opponentLevel, int opponentClassId, int winner) + { + _opponentName = opponentName; + _opponentClassId = opponentClassId; + _winner = winner; + _opponentLevel = opponentLevel; + } + + public String getOpponentName() + { + return _opponentName; + } + + public int getOpponentClassId() + { + return _opponentClassId; + } + + public int getWinner() + { + return _winner; + } + + public int getOpponentLevel() + { + return _opponentLevel; + } +} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java new file mode 100644 index 0000000000..047f6738c7 --- /dev/null +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java @@ -0,0 +1,193 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model.olympiad; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.l2jmobius.commons.database.DatabaseFactory; +import org.l2jmobius.gameserver.data.sql.CharNameTable; +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author dontknowdontcare + */ +public class OlympiadFightHistory +{ + private static final Logger LOGGER = Logger.getLogger(OlympiadFightHistory.class.getName()); + + private static final int MAX_FIGHT_HISTORY_COUNT = 3; + private final Player _player; + + private List _fights = new ArrayList<>(); + + public OlympiadFightHistory(Player player) + { + _player = player; + if ((MAX_FIGHT_HISTORY_COUNT > 0) && (_player != null)) + { + loadRecentFights(_player.getObjectId()); + } + } + + public List getFights() + { + return _fights; + } + + public int getWinnerFormat(Participant parOne, Participant parTwo, int winner) + { + if (parOne == null) + { + LOGGER.warning("OlympiadFightHistory - getWinnerFormat error parOne is null, owner = " + _player.getName()); + return 2; + } + if (_player.getObjectId() == parOne.getObjectId()) + { + if (winner == 1) + { + return 0; + } + else if (winner == 2) + { + return 1; + } + else + { + return 2; + } + } + if (winner == 2) + { + return 0; + } + else if (winner == 1) + { + return 1; + } + else + { + return 2; + } + } + + public void addOlympiadFight(Participant opponent, int winner) + { + if (opponent != null) + { + final OlympiadFight fight = new OlympiadFight(opponent.getName(), opponent.getLevel(), opponent.getBaseClass(), winner); + final List newFights = new ArrayList<>(); + newFights.add(fight); + if ((MAX_FIGHT_HISTORY_COUNT > 1) && !_fights.isEmpty()) + { + for (int i = 0; i < (MAX_FIGHT_HISTORY_COUNT - 1); i++) + { + if (_fights.size() < (i + 1)) + { + break; + } + OlympiadFight curFight = _fights.get(i); + newFights.add(curFight); + } + } + _fights = newFights; + } + } + + private void loadRecentFights(int charId) + { + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) ORDER BY start DESC LIMIT " + MAX_FIGHT_HISTORY_COUNT)) + { + ps.setInt(1, charId); + ps.setInt(2, charId); + try (ResultSet rset = ps.executeQuery()) + { + int charOneId; + int charOneClass; + int charTwoId; + int charTwoClass; + int winner; + int opponentCharId; + int opponentLevel; + int opponentClassId; + int winInfo; + while (rset.next()) + { + charOneId = rset.getInt("charOneId"); + charOneClass = rset.getInt("charOneClass"); + charTwoId = rset.getInt("charTwoId"); + charTwoClass = rset.getInt("charTwoClass"); + winner = rset.getInt("winner"); + opponentLevel = charOneId == charId ? rset.getInt("charTwoLevel") : rset.getInt("charOneLevel"); + opponentCharId = charOneId == charId ? charTwoId : charOneId; + opponentClassId = charOneId == charId ? charTwoClass : charOneClass; + + final String name = CharNameTable.getInstance().getNameById(opponentCharId); + if ((name != null)) + { + // winInfo: 0 = win, 1 = loss, 2 = draw + if (charOneId == charId) + { + if (winner == 1) + { + winInfo = 0; + } + else if (winner == 2) + { + winInfo = 1; + } + else + { + winInfo = 2; + } + } + else + { + if (winner == 2) + { + winInfo = 0; + } + else if (winner == 1) + { + winInfo = 1; + } + else + { + winInfo = 2; + } + } + _fights.add(new OlympiadFight(name, opponentLevel, opponentClassId, winInfo)); + } + else + { + LOGGER.severe("OlympiadFightHistory could not load opponent name for char id = " + opponentCharId); + } + } + } + } + catch (SQLException e) + { + LOGGER.warning("OlympiadFightHistory: could not load fights history for CharId: " + charId + ": " + e); + } + } +} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java index 259251d20d..0e9a03caae 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java @@ -1192,17 +1192,24 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame protected void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type) { + final int winnerFormat1 = one.getPlayer().getOlympiadFightHistory().getWinnerFormat(one, two, winner); + one.getPlayer().getOlympiadFightHistory().addOlympiadFight(two, winnerFormat1); + final int winnerFormat2 = two.getPlayer().getOlympiadFightHistory().getWinnerFormat(one, two, winner); + two.getPlayer().getOlympiadFightHistory().addOlympiadFight(one, winnerFormat2); + 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, charOneLevel, charTwoLevel, winner, start, time, classed) values(?,?,?,?,?,?,?,?,?,?)")) { statement.setInt(1, one.getObjectId()); statement.setInt(2, two.getObjectId()); statement.setInt(3, one.getBaseClass()); statement.setInt(4, two.getBaseClass()); - statement.setInt(5, winner); - statement.setLong(6, startTime); - statement.setLong(7, fightTime); - statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0)); + statement.setInt(5, one.getLevel()); + statement.setInt(6, two.getLevel()); + statement.setInt(7, winner); + statement.setLong(8, startTime != 0 ? startTime : System.currentTimeMillis()); + statement.setLong(9, fightTime); + statement.setInt(10, (type == CompetitionType.CLASSED ? 1 : 0)); statement.execute(); } catch (SQLException e) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/Participant.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/Participant.java index 6b00f4650b..9331b5712b 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/Participant.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/olympiad/Participant.java @@ -25,52 +25,60 @@ import org.l2jmobius.gameserver.model.actor.Player; */ public class Participant { - private final int objectId; - private Player player; - private final String name; - private final int side; - private final int baseClass; - private boolean disconnected = false; - private boolean defaulted = false; - private final StatSet stats; - public String clanName; - public int clanId; + private final int _objectId; + private Player _player; + private final String _name; + private final int _side; + private final int _baseClass; + private boolean _disconnected = false; + private boolean _defaulted = false; + private final StatSet _stats; + private final int _level; + private final String _clanName; + private final int _clanId; public Participant(Player plr, int olympiadSide) { - objectId = plr.getObjectId(); - player = plr; - name = plr.getName(); - side = olympiadSide; - baseClass = plr.getBaseClass(); - stats = Olympiad.getNobleStats(objectId); - clanName = plr.getClan() != null ? plr.getClan().getName() : ""; - clanId = plr.getClanId(); + _objectId = plr.getObjectId(); + _player = plr; + _name = plr.getName(); + _side = olympiadSide; + _baseClass = plr.getBaseClass(); + _stats = Olympiad.getNobleStats(_objectId); + _clanName = plr.getClan() != null ? plr.getClan().getName() : ""; + _clanId = plr.getClanId(); + _level = plr.getLevel(); } public Participant(int objId, int olympiadSide) { - objectId = objId; - player = null; - name = "-"; - side = olympiadSide; - baseClass = 0; - stats = null; - clanName = ""; - clanId = 0; + _objectId = objId; + _player = null; + _name = "-"; + _side = olympiadSide; + _baseClass = 0; + _stats = null; + _clanName = ""; + _clanId = 0; + _level = 0; + } + + public int getLevel() + { + return _level; } /** - * Updates the reference to {@link #player}, if it's null or appears off-line. + * Updates the reference to {@link #_player}, if it's null or appears off-line. * @return {@code true} if after the update the player isn't null, {@code false} otherwise. */ public boolean updatePlayer() { - if ((player == null) || !player.isOnline()) + if ((_player == null) || !_player.isOnline()) { - player = World.getInstance().getPlayer(getObjectId()); + _player = World.getInstance().getPlayer(getObjectId()); } - return (player != null); + return (_player != null); } /** @@ -79,7 +87,7 @@ public class Participant */ public void updateStat(String statName, int increment) { - stats.set(statName, Math.max(stats.getInt(statName) + increment, 0)); + _stats.set(statName, Math.max(_stats.getInt(statName) + increment, 0)); } /** @@ -87,7 +95,7 @@ public class Participant */ public String getName() { - return name; + return _name; } /** @@ -95,7 +103,7 @@ public class Participant */ public String getClanName() { - return clanName; + return _clanName; } /** @@ -103,7 +111,7 @@ public class Participant */ public int getClanId() { - return clanId; + return _clanId; } /** @@ -111,7 +119,7 @@ public class Participant */ public Player getPlayer() { - return player; + return _player; } /** @@ -119,7 +127,7 @@ public class Participant */ public int getObjectId() { - return objectId; + return _objectId; } /** @@ -127,7 +135,7 @@ public class Participant */ public StatSet getStats() { - return stats; + return _stats; } /** @@ -135,7 +143,7 @@ public class Participant */ public void setPlayer(Player noble) { - player = noble; + _player = noble; } /** @@ -143,7 +151,7 @@ public class Participant */ public int getSide() { - return side; + return _side; } /** @@ -151,7 +159,7 @@ public class Participant */ public int getBaseClass() { - return baseClass; + return _baseClass; } /** @@ -159,7 +167,7 @@ public class Participant */ public boolean isDisconnected() { - return disconnected; + return _disconnected; } /** @@ -167,7 +175,7 @@ public class Participant */ public void setDisconnected(boolean value) { - disconnected = value; + _disconnected = value; } /** @@ -175,7 +183,7 @@ public class Participant */ public boolean isDefaulted() { - return defaulted; + return _defaulted; } /** @@ -183,6 +191,6 @@ public class Participant */ public void setDefaulted(boolean value) { - defaulted = value; + _defaulted = value; } } \ No newline at end of file diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java index 5cfad5d67f..11c873138c 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java @@ -24,12 +24,10 @@ import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMatchMa public class OlympiadMatchMaking implements IClientIncomingPacket { - private byte _gameRuleType; - @Override public boolean read(GameClient client, PacketReader packet) { - _gameRuleType = (byte) packet.readC(); + packet.readC(); // gameRuleType return true; } @@ -42,6 +40,6 @@ public class OlympiadMatchMaking implements IClientIncomingPacket return; } - player.sendPacket(new ExOlympiadMatchMakingResult(_gameRuleType, 1)); + player.sendPacket(new ExOlympiadMatchMakingResult(1)); } } \ No newline at end of file diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java index e165096e42..83e290fbae 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java @@ -24,12 +24,10 @@ import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMatchMa public class OlympiadMatchMakingCancel implements IClientIncomingPacket { - private byte _gameRuleType; - @Override public boolean read(GameClient client, PacketReader packet) { - _gameRuleType = (byte) packet.readC(); + packet.readC(); // gameRuleType return true; } @@ -42,6 +40,6 @@ public class OlympiadMatchMakingCancel implements IClientIncomingPacket return; } - player.sendPacket(new ExOlympiadMatchMakingResult(_gameRuleType, 0)); + player.sendPacket(new ExOlympiadMatchMakingResult(0)); } } \ No newline at end of file diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java index 255d11e91d..e4ea47de67 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.network.clientpackets.olympiad; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.enums.OlympiadMode; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMode; /** * format ch c: (id) 0xD0 h: (subid) 0x12 @@ -46,5 +48,9 @@ public class RequestOlympiadObserverEnd implements IClientIncomingPacket { player.leaveOlympiadObserverMode(); } + else + { + player.sendPacket(new ExOlympiadMode(OlympiadMode.NONE)); + } } } \ No newline at end of file diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java index b541ddf502..aa8cc4444b 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java @@ -22,7 +22,7 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; public class ExOlympiadInfo implements IClientOutgoingPacket { - private static int _open; + private final int _open; public ExOlympiadInfo(int open) { diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java deleted file mode 100644 index 1d7653e028..0000000000 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java +++ /dev/null @@ -1,37 +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 . - */ -package org.l2jmobius.gameserver.network.serverpackets.olympiad; - -import org.l2jmobius.commons.network.PacketWriter; -import org.l2jmobius.gameserver.network.OutgoingPackets; -import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; - -public class ExOlympiadMatchInfoEnd implements IClientOutgoingPacket -{ - public static final ExOlympiadMatchInfoEnd STATIC_PACKET = new ExOlympiadMatchInfoEnd(); - - private ExOlympiadMatchInfoEnd() - { - } - - @Override - public boolean write(PacketWriter packet) - { - OutgoingPackets.EX_OLYMPIAD_MATCH_INFO.writeId(packet); - return true; - } -} diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java index 80564627aa..90ebbea23d 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java @@ -82,7 +82,7 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket packet.writeD(0); } - packet.writeD(curGame.isRunning() ? 2 : 1); // (1 = Standby, 2 = Playing) + packet.writeD(curGame.isBattleStarted() || curGame.isBattleFinished() ? 1 : 2); // (1 = Standby, 2 = Playing) packet.writeS(game.getPlayerNames()[0]); // Player 1 Name packet.writeS(game.getPlayerNames()[1]); // Player 2 Name } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java index a72825cad4..1ba52936ad 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java @@ -22,12 +22,10 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; public class ExOlympiadMatchMakingResult implements IClientOutgoingPacket { - private final int _gameRuleType; private final int _type; - public ExOlympiadMatchMakingResult(int cGameRuleType, int type) + public ExOlympiadMatchMakingResult(int type) { - _gameRuleType = 0; _type = type; } @@ -36,7 +34,7 @@ public class ExOlympiadMatchMakingResult implements IClientOutgoingPacket { OutgoingPackets.EX_OLYMPIAD_INFO.writeId(packet); packet.writeC(_type); - packet.writeD(_gameRuleType); + packet.writeD(0); return true; } } diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java index 2c57635a47..926911e420 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java @@ -68,26 +68,32 @@ public class ExOlympiadMatchResult implements IClientOutgoingPacket for (OlympiadInfo info : _winnerList) { packet.writeS(info.getName()); - packet.writeS(info.getClanName()); - packet.writeD(info.getClanId()); + + // New UI doesn't support clan name/id + packet.writeH(0); // clan name + packet.writeD(0); // clan id + packet.writeD(info.getClassId()); packet.writeD(info.getDamage()); packet.writeD(info.getCurrentPoints()); packet.writeD(info.getDiffPoints()); - packet.writeD(0); // Helios + packet.writeD(1); // Helios } packet.writeD(_loseTeam); packet.writeD(_loserList.size()); for (OlympiadInfo info : _loserList) { packet.writeS(info.getName()); - packet.writeS(info.getClanName()); - packet.writeD(info.getClanId()); + + // New UI doesn't support clan name/id + packet.writeH(0); // clan name + packet.writeD(0); // clan id + packet.writeD(info.getClassId()); packet.writeD(info.getDamage()); packet.writeD(info.getCurrentPoints()); packet.writeD(info.getDiffPoints()); - packet.writeD(0); // Helios + packet.writeD(1); // Helios } packet.writeC(_round1winner); // Round 1 outcome packet.writeC(_round2winner); // Round 2 outcome diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java index 1acac0ec7a..4ab2250f5f 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java @@ -29,10 +29,10 @@ public class ExOlympiadUserInfo implements IClientOutgoingPacket { private final Player _player; private Participant _par = null; - private int _curHp; - private int _maxHp; - private int _curCp; - private int _maxCp; + private final int _curHp; + private final int _maxHp; + private final int _curCp; + private final int _maxCp; public ExOlympiadUserInfo(Player player) { diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java index 35aa028535..1905691dc3 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java @@ -20,9 +20,11 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.List; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.network.PacketWriter; @@ -31,12 +33,13 @@ import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.olympiad.Hero; import org.l2jmobius.gameserver.model.olympiad.Olympiad; +import org.l2jmobius.gameserver.model.olympiad.OlympiadFight; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.PacketLogger; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; /** - * @author NviX + * @author NviX, dontknowdontcare */ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket { @@ -116,7 +119,7 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket } catch (SQLException e) { - PacketLogger.warning("Olympiad my ranking: Couldnt load data: " + e.getMessage()); + PacketLogger.warning("Olympiad my ranking: Couldn't load data: " + e.getMessage()); } int heroCount = 0; int legendCount = 0; @@ -139,7 +142,31 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket packet.writeD(previousPoints); // Points on previous cycle packet.writeD(heroCount); // Hero counts packet.writeD(legendCount); // Legend counts - packet.writeD(0); // change to 1 causes shows nothing + + List fightList = _player.getOlympiadFightHistory().getFights(); + if (fightList == null) + { + fightList = new ArrayList<>(); + } + + packet.writeD(fightList.size()); + int count = 1; + for (OlympiadFight fight : fightList) + { + if (count > 3) + { + break; + } + + packet.writeH(fight.getOpponentName().length() + 1); + packet.writeS(fight.getOpponentName()); + packet.writeC(fight.getWinner()); + packet.writeD(fight.getOpponentLevel()); + packet.writeD(fight.getOpponentClassId()); + + count++; + } + return true; } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/db_installer/sql/game/olympiad_fights.sql b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/db_installer/sql/game/olympiad_fights.sql index 618ee73db0..15ffc8332b 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/db_installer/sql/game/olympiad_fights.sql +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/dist/db_installer/sql/game/olympiad_fights.sql @@ -4,6 +4,8 @@ CREATE TABLE IF NOT EXISTS `olympiad_fights` ( `charTwoId` int(10) unsigned NOT NULL, `charOneClass` tinyint(3) unsigned NOT NULL DEFAULT '0', `charTwoClass` tinyint(3) unsigned NOT NULL DEFAULT '0', + `charOneLevel` int(5) unsigned NOT NULL DEFAULT '0', + `charTwoLevel` int(5) unsigned NOT NULL DEFAULT '0', `winner` tinyint(1) unsigned NOT NULL DEFAULT '0', `start` bigint(13) unsigned NOT NULL DEFAULT '0', `time` bigint(13) unsigned NOT NULL DEFAULT '0', diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java index c130b81afd..3575b50f79 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -258,6 +258,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.PlayerRefund; import org.l2jmobius.gameserver.model.itemcontainer.PlayerWarehouse; import org.l2jmobius.gameserver.model.matching.MatchingRoom; import org.l2jmobius.gameserver.model.olympiad.Hero; +import org.l2jmobius.gameserver.model.olympiad.OlympiadFightHistory; import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager; import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask; import org.l2jmobius.gameserver.model.olympiad.OlympiadManager; @@ -848,6 +849,8 @@ public class Player extends Playable private Map _customSkills = null; public final Set _replacedSkills = ConcurrentHashMap.newKeySet(1); + private final OlympiadFightHistory _olympiadFightHistory = new OlympiadFightHistory(this); + private volatile int _actionMask; private int _questZoneId = -1; @@ -13583,6 +13586,11 @@ public class Player extends Playable return _replacedSkills.contains(skillId); } + public OlympiadFightHistory getOlympiadFightHistory() + { + return _olympiadFightHistory; + } + /** * @return {@code true} if current player can revive and shows 'To Village' button upon death, {@code false} otherwise. */ diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java new file mode 100644 index 0000000000..29e288c309 --- /dev/null +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java @@ -0,0 +1,56 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model.olympiad; + +/** + * @author dontknowdontcare + */ +public class OlympiadFight +{ + private final String _opponentName; + private final int _opponentClassId; + private final int _winner; // 0 = win, 1 = loss, 2 = draw + private final int _opponentLevel; + + public OlympiadFight(String opponentName, int opponentLevel, int opponentClassId, int winner) + { + _opponentName = opponentName; + _opponentClassId = opponentClassId; + _winner = winner; + _opponentLevel = opponentLevel; + } + + public String getOpponentName() + { + return _opponentName; + } + + public int getOpponentClassId() + { + return _opponentClassId; + } + + public int getWinner() + { + return _winner; + } + + public int getOpponentLevel() + { + return _opponentLevel; + } +} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java new file mode 100644 index 0000000000..047f6738c7 --- /dev/null +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java @@ -0,0 +1,193 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model.olympiad; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.l2jmobius.commons.database.DatabaseFactory; +import org.l2jmobius.gameserver.data.sql.CharNameTable; +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author dontknowdontcare + */ +public class OlympiadFightHistory +{ + private static final Logger LOGGER = Logger.getLogger(OlympiadFightHistory.class.getName()); + + private static final int MAX_FIGHT_HISTORY_COUNT = 3; + private final Player _player; + + private List _fights = new ArrayList<>(); + + public OlympiadFightHistory(Player player) + { + _player = player; + if ((MAX_FIGHT_HISTORY_COUNT > 0) && (_player != null)) + { + loadRecentFights(_player.getObjectId()); + } + } + + public List getFights() + { + return _fights; + } + + public int getWinnerFormat(Participant parOne, Participant parTwo, int winner) + { + if (parOne == null) + { + LOGGER.warning("OlympiadFightHistory - getWinnerFormat error parOne is null, owner = " + _player.getName()); + return 2; + } + if (_player.getObjectId() == parOne.getObjectId()) + { + if (winner == 1) + { + return 0; + } + else if (winner == 2) + { + return 1; + } + else + { + return 2; + } + } + if (winner == 2) + { + return 0; + } + else if (winner == 1) + { + return 1; + } + else + { + return 2; + } + } + + public void addOlympiadFight(Participant opponent, int winner) + { + if (opponent != null) + { + final OlympiadFight fight = new OlympiadFight(opponent.getName(), opponent.getLevel(), opponent.getBaseClass(), winner); + final List newFights = new ArrayList<>(); + newFights.add(fight); + if ((MAX_FIGHT_HISTORY_COUNT > 1) && !_fights.isEmpty()) + { + for (int i = 0; i < (MAX_FIGHT_HISTORY_COUNT - 1); i++) + { + if (_fights.size() < (i + 1)) + { + break; + } + OlympiadFight curFight = _fights.get(i); + newFights.add(curFight); + } + } + _fights = newFights; + } + } + + private void loadRecentFights(int charId) + { + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) ORDER BY start DESC LIMIT " + MAX_FIGHT_HISTORY_COUNT)) + { + ps.setInt(1, charId); + ps.setInt(2, charId); + try (ResultSet rset = ps.executeQuery()) + { + int charOneId; + int charOneClass; + int charTwoId; + int charTwoClass; + int winner; + int opponentCharId; + int opponentLevel; + int opponentClassId; + int winInfo; + while (rset.next()) + { + charOneId = rset.getInt("charOneId"); + charOneClass = rset.getInt("charOneClass"); + charTwoId = rset.getInt("charTwoId"); + charTwoClass = rset.getInt("charTwoClass"); + winner = rset.getInt("winner"); + opponentLevel = charOneId == charId ? rset.getInt("charTwoLevel") : rset.getInt("charOneLevel"); + opponentCharId = charOneId == charId ? charTwoId : charOneId; + opponentClassId = charOneId == charId ? charTwoClass : charOneClass; + + final String name = CharNameTable.getInstance().getNameById(opponentCharId); + if ((name != null)) + { + // winInfo: 0 = win, 1 = loss, 2 = draw + if (charOneId == charId) + { + if (winner == 1) + { + winInfo = 0; + } + else if (winner == 2) + { + winInfo = 1; + } + else + { + winInfo = 2; + } + } + else + { + if (winner == 2) + { + winInfo = 0; + } + else if (winner == 1) + { + winInfo = 1; + } + else + { + winInfo = 2; + } + } + _fights.add(new OlympiadFight(name, opponentLevel, opponentClassId, winInfo)); + } + else + { + LOGGER.severe("OlympiadFightHistory could not load opponent name for char id = " + opponentCharId); + } + } + } + } + catch (SQLException e) + { + LOGGER.warning("OlympiadFightHistory: could not load fights history for CharId: " + charId + ": " + e); + } + } +} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java index 259251d20d..0e9a03caae 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java @@ -1192,17 +1192,24 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame protected void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type) { + final int winnerFormat1 = one.getPlayer().getOlympiadFightHistory().getWinnerFormat(one, two, winner); + one.getPlayer().getOlympiadFightHistory().addOlympiadFight(two, winnerFormat1); + final int winnerFormat2 = two.getPlayer().getOlympiadFightHistory().getWinnerFormat(one, two, winner); + two.getPlayer().getOlympiadFightHistory().addOlympiadFight(one, winnerFormat2); + 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, charOneLevel, charTwoLevel, winner, start, time, classed) values(?,?,?,?,?,?,?,?,?,?)")) { statement.setInt(1, one.getObjectId()); statement.setInt(2, two.getObjectId()); statement.setInt(3, one.getBaseClass()); statement.setInt(4, two.getBaseClass()); - statement.setInt(5, winner); - statement.setLong(6, startTime); - statement.setLong(7, fightTime); - statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0)); + statement.setInt(5, one.getLevel()); + statement.setInt(6, two.getLevel()); + statement.setInt(7, winner); + statement.setLong(8, startTime != 0 ? startTime : System.currentTimeMillis()); + statement.setLong(9, fightTime); + statement.setInt(10, (type == CompetitionType.CLASSED ? 1 : 0)); statement.execute(); } catch (SQLException e) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/Participant.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/Participant.java index 6b00f4650b..9331b5712b 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/Participant.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/olympiad/Participant.java @@ -25,52 +25,60 @@ import org.l2jmobius.gameserver.model.actor.Player; */ public class Participant { - private final int objectId; - private Player player; - private final String name; - private final int side; - private final int baseClass; - private boolean disconnected = false; - private boolean defaulted = false; - private final StatSet stats; - public String clanName; - public int clanId; + private final int _objectId; + private Player _player; + private final String _name; + private final int _side; + private final int _baseClass; + private boolean _disconnected = false; + private boolean _defaulted = false; + private final StatSet _stats; + private final int _level; + private final String _clanName; + private final int _clanId; public Participant(Player plr, int olympiadSide) { - objectId = plr.getObjectId(); - player = plr; - name = plr.getName(); - side = olympiadSide; - baseClass = plr.getBaseClass(); - stats = Olympiad.getNobleStats(objectId); - clanName = plr.getClan() != null ? plr.getClan().getName() : ""; - clanId = plr.getClanId(); + _objectId = plr.getObjectId(); + _player = plr; + _name = plr.getName(); + _side = olympiadSide; + _baseClass = plr.getBaseClass(); + _stats = Olympiad.getNobleStats(_objectId); + _clanName = plr.getClan() != null ? plr.getClan().getName() : ""; + _clanId = plr.getClanId(); + _level = plr.getLevel(); } public Participant(int objId, int olympiadSide) { - objectId = objId; - player = null; - name = "-"; - side = olympiadSide; - baseClass = 0; - stats = null; - clanName = ""; - clanId = 0; + _objectId = objId; + _player = null; + _name = "-"; + _side = olympiadSide; + _baseClass = 0; + _stats = null; + _clanName = ""; + _clanId = 0; + _level = 0; + } + + public int getLevel() + { + return _level; } /** - * Updates the reference to {@link #player}, if it's null or appears off-line. + * Updates the reference to {@link #_player}, if it's null or appears off-line. * @return {@code true} if after the update the player isn't null, {@code false} otherwise. */ public boolean updatePlayer() { - if ((player == null) || !player.isOnline()) + if ((_player == null) || !_player.isOnline()) { - player = World.getInstance().getPlayer(getObjectId()); + _player = World.getInstance().getPlayer(getObjectId()); } - return (player != null); + return (_player != null); } /** @@ -79,7 +87,7 @@ public class Participant */ public void updateStat(String statName, int increment) { - stats.set(statName, Math.max(stats.getInt(statName) + increment, 0)); + _stats.set(statName, Math.max(_stats.getInt(statName) + increment, 0)); } /** @@ -87,7 +95,7 @@ public class Participant */ public String getName() { - return name; + return _name; } /** @@ -95,7 +103,7 @@ public class Participant */ public String getClanName() { - return clanName; + return _clanName; } /** @@ -103,7 +111,7 @@ public class Participant */ public int getClanId() { - return clanId; + return _clanId; } /** @@ -111,7 +119,7 @@ public class Participant */ public Player getPlayer() { - return player; + return _player; } /** @@ -119,7 +127,7 @@ public class Participant */ public int getObjectId() { - return objectId; + return _objectId; } /** @@ -127,7 +135,7 @@ public class Participant */ public StatSet getStats() { - return stats; + return _stats; } /** @@ -135,7 +143,7 @@ public class Participant */ public void setPlayer(Player noble) { - player = noble; + _player = noble; } /** @@ -143,7 +151,7 @@ public class Participant */ public int getSide() { - return side; + return _side; } /** @@ -151,7 +159,7 @@ public class Participant */ public int getBaseClass() { - return baseClass; + return _baseClass; } /** @@ -159,7 +167,7 @@ public class Participant */ public boolean isDisconnected() { - return disconnected; + return _disconnected; } /** @@ -167,7 +175,7 @@ public class Participant */ public void setDisconnected(boolean value) { - disconnected = value; + _disconnected = value; } /** @@ -175,7 +183,7 @@ public class Participant */ public boolean isDefaulted() { - return defaulted; + return _defaulted; } /** @@ -183,6 +191,6 @@ public class Participant */ public void setDefaulted(boolean value) { - defaulted = value; + _defaulted = value; } } \ No newline at end of file diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java index 5cfad5d67f..11c873138c 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java @@ -24,12 +24,10 @@ import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMatchMa public class OlympiadMatchMaking implements IClientIncomingPacket { - private byte _gameRuleType; - @Override public boolean read(GameClient client, PacketReader packet) { - _gameRuleType = (byte) packet.readC(); + packet.readC(); // gameRuleType return true; } @@ -42,6 +40,6 @@ public class OlympiadMatchMaking implements IClientIncomingPacket return; } - player.sendPacket(new ExOlympiadMatchMakingResult(_gameRuleType, 1)); + player.sendPacket(new ExOlympiadMatchMakingResult(1)); } } \ No newline at end of file diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java index e165096e42..83e290fbae 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java @@ -24,12 +24,10 @@ import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMatchMa public class OlympiadMatchMakingCancel implements IClientIncomingPacket { - private byte _gameRuleType; - @Override public boolean read(GameClient client, PacketReader packet) { - _gameRuleType = (byte) packet.readC(); + packet.readC(); // gameRuleType return true; } @@ -42,6 +40,6 @@ public class OlympiadMatchMakingCancel implements IClientIncomingPacket return; } - player.sendPacket(new ExOlympiadMatchMakingResult(_gameRuleType, 0)); + player.sendPacket(new ExOlympiadMatchMakingResult(0)); } } \ No newline at end of file diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java index 255d11e91d..e4ea47de67 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.network.clientpackets.olympiad; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.enums.OlympiadMode; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMode; /** * format ch c: (id) 0xD0 h: (subid) 0x12 @@ -46,5 +48,9 @@ public class RequestOlympiadObserverEnd implements IClientIncomingPacket { player.leaveOlympiadObserverMode(); } + else + { + player.sendPacket(new ExOlympiadMode(OlympiadMode.NONE)); + } } } \ No newline at end of file diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java index b541ddf502..aa8cc4444b 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java @@ -22,7 +22,7 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; public class ExOlympiadInfo implements IClientOutgoingPacket { - private static int _open; + private final int _open; public ExOlympiadInfo(int open) { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java deleted file mode 100644 index 1d7653e028..0000000000 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java +++ /dev/null @@ -1,37 +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 . - */ -package org.l2jmobius.gameserver.network.serverpackets.olympiad; - -import org.l2jmobius.commons.network.PacketWriter; -import org.l2jmobius.gameserver.network.OutgoingPackets; -import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; - -public class ExOlympiadMatchInfoEnd implements IClientOutgoingPacket -{ - public static final ExOlympiadMatchInfoEnd STATIC_PACKET = new ExOlympiadMatchInfoEnd(); - - private ExOlympiadMatchInfoEnd() - { - } - - @Override - public boolean write(PacketWriter packet) - { - OutgoingPackets.EX_OLYMPIAD_MATCH_INFO.writeId(packet); - return true; - } -} diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java index 80564627aa..90ebbea23d 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java @@ -82,7 +82,7 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket packet.writeD(0); } - packet.writeD(curGame.isRunning() ? 2 : 1); // (1 = Standby, 2 = Playing) + packet.writeD(curGame.isBattleStarted() || curGame.isBattleFinished() ? 1 : 2); // (1 = Standby, 2 = Playing) packet.writeS(game.getPlayerNames()[0]); // Player 1 Name packet.writeS(game.getPlayerNames()[1]); // Player 2 Name } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java index a72825cad4..1ba52936ad 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java @@ -22,12 +22,10 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; public class ExOlympiadMatchMakingResult implements IClientOutgoingPacket { - private final int _gameRuleType; private final int _type; - public ExOlympiadMatchMakingResult(int cGameRuleType, int type) + public ExOlympiadMatchMakingResult(int type) { - _gameRuleType = 0; _type = type; } @@ -36,7 +34,7 @@ public class ExOlympiadMatchMakingResult implements IClientOutgoingPacket { OutgoingPackets.EX_OLYMPIAD_INFO.writeId(packet); packet.writeC(_type); - packet.writeD(_gameRuleType); + packet.writeD(0); return true; } } diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java index 2c57635a47..926911e420 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java @@ -68,26 +68,32 @@ public class ExOlympiadMatchResult implements IClientOutgoingPacket for (OlympiadInfo info : _winnerList) { packet.writeS(info.getName()); - packet.writeS(info.getClanName()); - packet.writeD(info.getClanId()); + + // New UI doesn't support clan name/id + packet.writeH(0); // clan name + packet.writeD(0); // clan id + packet.writeD(info.getClassId()); packet.writeD(info.getDamage()); packet.writeD(info.getCurrentPoints()); packet.writeD(info.getDiffPoints()); - packet.writeD(0); // Helios + packet.writeD(1); // Helios } packet.writeD(_loseTeam); packet.writeD(_loserList.size()); for (OlympiadInfo info : _loserList) { packet.writeS(info.getName()); - packet.writeS(info.getClanName()); - packet.writeD(info.getClanId()); + + // New UI doesn't support clan name/id + packet.writeH(0); // clan name + packet.writeD(0); // clan id + packet.writeD(info.getClassId()); packet.writeD(info.getDamage()); packet.writeD(info.getCurrentPoints()); packet.writeD(info.getDiffPoints()); - packet.writeD(0); // Helios + packet.writeD(1); // Helios } packet.writeC(_round1winner); // Round 1 outcome packet.writeC(_round2winner); // Round 2 outcome diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java index 1acac0ec7a..4ab2250f5f 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java @@ -29,10 +29,10 @@ public class ExOlympiadUserInfo implements IClientOutgoingPacket { private final Player _player; private Participant _par = null; - private int _curHp; - private int _maxHp; - private int _curCp; - private int _maxCp; + private final int _curHp; + private final int _maxHp; + private final int _curCp; + private final int _maxCp; public ExOlympiadUserInfo(Player player) { diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java index 35aa028535..1905691dc3 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java @@ -20,9 +20,11 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.List; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.network.PacketWriter; @@ -31,12 +33,13 @@ import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.olympiad.Hero; import org.l2jmobius.gameserver.model.olympiad.Olympiad; +import org.l2jmobius.gameserver.model.olympiad.OlympiadFight; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.PacketLogger; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; /** - * @author NviX + * @author NviX, dontknowdontcare */ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket { @@ -116,7 +119,7 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket } catch (SQLException e) { - PacketLogger.warning("Olympiad my ranking: Couldnt load data: " + e.getMessage()); + PacketLogger.warning("Olympiad my ranking: Couldn't load data: " + e.getMessage()); } int heroCount = 0; int legendCount = 0; @@ -139,7 +142,31 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket packet.writeD(previousPoints); // Points on previous cycle packet.writeD(heroCount); // Hero counts packet.writeD(legendCount); // Legend counts - packet.writeD(0); // change to 1 causes shows nothing + + List fightList = _player.getOlympiadFightHistory().getFights(); + if (fightList == null) + { + fightList = new ArrayList<>(); + } + + packet.writeD(fightList.size()); + int count = 1; + for (OlympiadFight fight : fightList) + { + if (count > 3) + { + break; + } + + packet.writeH(fight.getOpponentName().length() + 1); + packet.writeS(fight.getOpponentName()); + packet.writeC(fight.getWinner()); + packet.writeD(fight.getOpponentLevel()); + packet.writeD(fight.getOpponentClassId()); + + count++; + } + return true; } } diff --git a/L2J_Mobius_10.1_MasterClass/dist/db_installer/sql/game/olympiad_fights.sql b/L2J_Mobius_10.1_MasterClass/dist/db_installer/sql/game/olympiad_fights.sql index 618ee73db0..15ffc8332b 100644 --- a/L2J_Mobius_10.1_MasterClass/dist/db_installer/sql/game/olympiad_fights.sql +++ b/L2J_Mobius_10.1_MasterClass/dist/db_installer/sql/game/olympiad_fights.sql @@ -4,6 +4,8 @@ CREATE TABLE IF NOT EXISTS `olympiad_fights` ( `charTwoId` int(10) unsigned NOT NULL, `charOneClass` tinyint(3) unsigned NOT NULL DEFAULT '0', `charTwoClass` tinyint(3) unsigned NOT NULL DEFAULT '0', + `charOneLevel` int(5) unsigned NOT NULL DEFAULT '0', + `charTwoLevel` int(5) unsigned NOT NULL DEFAULT '0', `winner` tinyint(1) unsigned NOT NULL DEFAULT '0', `start` bigint(13) unsigned NOT NULL DEFAULT '0', `time` bigint(13) unsigned NOT NULL DEFAULT '0', diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java index ac2c502111..e55e9bfde8 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -258,6 +258,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.PlayerRefund; import org.l2jmobius.gameserver.model.itemcontainer.PlayerWarehouse; import org.l2jmobius.gameserver.model.matching.MatchingRoom; import org.l2jmobius.gameserver.model.olympiad.Hero; +import org.l2jmobius.gameserver.model.olympiad.OlympiadFightHistory; import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager; import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask; import org.l2jmobius.gameserver.model.olympiad.OlympiadManager; @@ -850,6 +851,8 @@ public class Player extends Playable private Map _customSkills = null; public final Set _replacedSkills = ConcurrentHashMap.newKeySet(1); + private final OlympiadFightHistory _olympiadFightHistory = new OlympiadFightHistory(this); + private volatile int _actionMask; private int _questZoneId = -1; @@ -13621,6 +13624,11 @@ public class Player extends Playable return _replacedSkills.contains(skillId); } + public OlympiadFightHistory getOlympiadFightHistory() + { + return _olympiadFightHistory; + } + /** * @return {@code true} if current player can revive and shows 'To Village' button upon death, {@code false} otherwise. */ diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java new file mode 100644 index 0000000000..29e288c309 --- /dev/null +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java @@ -0,0 +1,56 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model.olympiad; + +/** + * @author dontknowdontcare + */ +public class OlympiadFight +{ + private final String _opponentName; + private final int _opponentClassId; + private final int _winner; // 0 = win, 1 = loss, 2 = draw + private final int _opponentLevel; + + public OlympiadFight(String opponentName, int opponentLevel, int opponentClassId, int winner) + { + _opponentName = opponentName; + _opponentClassId = opponentClassId; + _winner = winner; + _opponentLevel = opponentLevel; + } + + public String getOpponentName() + { + return _opponentName; + } + + public int getOpponentClassId() + { + return _opponentClassId; + } + + public int getWinner() + { + return _winner; + } + + public int getOpponentLevel() + { + return _opponentLevel; + } +} diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java new file mode 100644 index 0000000000..047f6738c7 --- /dev/null +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java @@ -0,0 +1,193 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model.olympiad; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.l2jmobius.commons.database.DatabaseFactory; +import org.l2jmobius.gameserver.data.sql.CharNameTable; +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author dontknowdontcare + */ +public class OlympiadFightHistory +{ + private static final Logger LOGGER = Logger.getLogger(OlympiadFightHistory.class.getName()); + + private static final int MAX_FIGHT_HISTORY_COUNT = 3; + private final Player _player; + + private List _fights = new ArrayList<>(); + + public OlympiadFightHistory(Player player) + { + _player = player; + if ((MAX_FIGHT_HISTORY_COUNT > 0) && (_player != null)) + { + loadRecentFights(_player.getObjectId()); + } + } + + public List getFights() + { + return _fights; + } + + public int getWinnerFormat(Participant parOne, Participant parTwo, int winner) + { + if (parOne == null) + { + LOGGER.warning("OlympiadFightHistory - getWinnerFormat error parOne is null, owner = " + _player.getName()); + return 2; + } + if (_player.getObjectId() == parOne.getObjectId()) + { + if (winner == 1) + { + return 0; + } + else if (winner == 2) + { + return 1; + } + else + { + return 2; + } + } + if (winner == 2) + { + return 0; + } + else if (winner == 1) + { + return 1; + } + else + { + return 2; + } + } + + public void addOlympiadFight(Participant opponent, int winner) + { + if (opponent != null) + { + final OlympiadFight fight = new OlympiadFight(opponent.getName(), opponent.getLevel(), opponent.getBaseClass(), winner); + final List newFights = new ArrayList<>(); + newFights.add(fight); + if ((MAX_FIGHT_HISTORY_COUNT > 1) && !_fights.isEmpty()) + { + for (int i = 0; i < (MAX_FIGHT_HISTORY_COUNT - 1); i++) + { + if (_fights.size() < (i + 1)) + { + break; + } + OlympiadFight curFight = _fights.get(i); + newFights.add(curFight); + } + } + _fights = newFights; + } + } + + private void loadRecentFights(int charId) + { + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) ORDER BY start DESC LIMIT " + MAX_FIGHT_HISTORY_COUNT)) + { + ps.setInt(1, charId); + ps.setInt(2, charId); + try (ResultSet rset = ps.executeQuery()) + { + int charOneId; + int charOneClass; + int charTwoId; + int charTwoClass; + int winner; + int opponentCharId; + int opponentLevel; + int opponentClassId; + int winInfo; + while (rset.next()) + { + charOneId = rset.getInt("charOneId"); + charOneClass = rset.getInt("charOneClass"); + charTwoId = rset.getInt("charTwoId"); + charTwoClass = rset.getInt("charTwoClass"); + winner = rset.getInt("winner"); + opponentLevel = charOneId == charId ? rset.getInt("charTwoLevel") : rset.getInt("charOneLevel"); + opponentCharId = charOneId == charId ? charTwoId : charOneId; + opponentClassId = charOneId == charId ? charTwoClass : charOneClass; + + final String name = CharNameTable.getInstance().getNameById(opponentCharId); + if ((name != null)) + { + // winInfo: 0 = win, 1 = loss, 2 = draw + if (charOneId == charId) + { + if (winner == 1) + { + winInfo = 0; + } + else if (winner == 2) + { + winInfo = 1; + } + else + { + winInfo = 2; + } + } + else + { + if (winner == 2) + { + winInfo = 0; + } + else if (winner == 1) + { + winInfo = 1; + } + else + { + winInfo = 2; + } + } + _fights.add(new OlympiadFight(name, opponentLevel, opponentClassId, winInfo)); + } + else + { + LOGGER.severe("OlympiadFightHistory could not load opponent name for char id = " + opponentCharId); + } + } + } + } + catch (SQLException e) + { + LOGGER.warning("OlympiadFightHistory: could not load fights history for CharId: " + charId + ": " + e); + } + } +} diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java index 7bf922e4a7..5de7d1818a 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java @@ -1192,17 +1192,24 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame protected void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type) { + final int winnerFormat1 = one.getPlayer().getOlympiadFightHistory().getWinnerFormat(one, two, winner); + one.getPlayer().getOlympiadFightHistory().addOlympiadFight(two, winnerFormat1); + final int winnerFormat2 = two.getPlayer().getOlympiadFightHistory().getWinnerFormat(one, two, winner); + two.getPlayer().getOlympiadFightHistory().addOlympiadFight(one, winnerFormat2); + 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, charOneLevel, charTwoLevel, winner, start, time, classed) values(?,?,?,?,?,?,?,?,?,?)")) { statement.setInt(1, one.getObjectId()); statement.setInt(2, two.getObjectId()); statement.setInt(3, one.getBaseClass()); statement.setInt(4, two.getBaseClass()); - statement.setInt(5, winner); - statement.setLong(6, startTime); - statement.setLong(7, fightTime); - statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0)); + statement.setInt(5, one.getLevel()); + statement.setInt(6, two.getLevel()); + statement.setInt(7, winner); + statement.setLong(8, startTime != 0 ? startTime : System.currentTimeMillis()); + statement.setLong(9, fightTime); + statement.setInt(10, (type == CompetitionType.CLASSED ? 1 : 0)); statement.execute(); } catch (SQLException e) diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/Participant.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/Participant.java index 6b00f4650b..9331b5712b 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/Participant.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/Participant.java @@ -25,52 +25,60 @@ import org.l2jmobius.gameserver.model.actor.Player; */ public class Participant { - private final int objectId; - private Player player; - private final String name; - private final int side; - private final int baseClass; - private boolean disconnected = false; - private boolean defaulted = false; - private final StatSet stats; - public String clanName; - public int clanId; + private final int _objectId; + private Player _player; + private final String _name; + private final int _side; + private final int _baseClass; + private boolean _disconnected = false; + private boolean _defaulted = false; + private final StatSet _stats; + private final int _level; + private final String _clanName; + private final int _clanId; public Participant(Player plr, int olympiadSide) { - objectId = plr.getObjectId(); - player = plr; - name = plr.getName(); - side = olympiadSide; - baseClass = plr.getBaseClass(); - stats = Olympiad.getNobleStats(objectId); - clanName = plr.getClan() != null ? plr.getClan().getName() : ""; - clanId = plr.getClanId(); + _objectId = plr.getObjectId(); + _player = plr; + _name = plr.getName(); + _side = olympiadSide; + _baseClass = plr.getBaseClass(); + _stats = Olympiad.getNobleStats(_objectId); + _clanName = plr.getClan() != null ? plr.getClan().getName() : ""; + _clanId = plr.getClanId(); + _level = plr.getLevel(); } public Participant(int objId, int olympiadSide) { - objectId = objId; - player = null; - name = "-"; - side = olympiadSide; - baseClass = 0; - stats = null; - clanName = ""; - clanId = 0; + _objectId = objId; + _player = null; + _name = "-"; + _side = olympiadSide; + _baseClass = 0; + _stats = null; + _clanName = ""; + _clanId = 0; + _level = 0; + } + + public int getLevel() + { + return _level; } /** - * Updates the reference to {@link #player}, if it's null or appears off-line. + * Updates the reference to {@link #_player}, if it's null or appears off-line. * @return {@code true} if after the update the player isn't null, {@code false} otherwise. */ public boolean updatePlayer() { - if ((player == null) || !player.isOnline()) + if ((_player == null) || !_player.isOnline()) { - player = World.getInstance().getPlayer(getObjectId()); + _player = World.getInstance().getPlayer(getObjectId()); } - return (player != null); + return (_player != null); } /** @@ -79,7 +87,7 @@ public class Participant */ public void updateStat(String statName, int increment) { - stats.set(statName, Math.max(stats.getInt(statName) + increment, 0)); + _stats.set(statName, Math.max(_stats.getInt(statName) + increment, 0)); } /** @@ -87,7 +95,7 @@ public class Participant */ public String getName() { - return name; + return _name; } /** @@ -95,7 +103,7 @@ public class Participant */ public String getClanName() { - return clanName; + return _clanName; } /** @@ -103,7 +111,7 @@ public class Participant */ public int getClanId() { - return clanId; + return _clanId; } /** @@ -111,7 +119,7 @@ public class Participant */ public Player getPlayer() { - return player; + return _player; } /** @@ -119,7 +127,7 @@ public class Participant */ public int getObjectId() { - return objectId; + return _objectId; } /** @@ -127,7 +135,7 @@ public class Participant */ public StatSet getStats() { - return stats; + return _stats; } /** @@ -135,7 +143,7 @@ public class Participant */ public void setPlayer(Player noble) { - player = noble; + _player = noble; } /** @@ -143,7 +151,7 @@ public class Participant */ public int getSide() { - return side; + return _side; } /** @@ -151,7 +159,7 @@ public class Participant */ public int getBaseClass() { - return baseClass; + return _baseClass; } /** @@ -159,7 +167,7 @@ public class Participant */ public boolean isDisconnected() { - return disconnected; + return _disconnected; } /** @@ -167,7 +175,7 @@ public class Participant */ public void setDisconnected(boolean value) { - disconnected = value; + _disconnected = value; } /** @@ -175,7 +183,7 @@ public class Participant */ public boolean isDefaulted() { - return defaulted; + return _defaulted; } /** @@ -183,6 +191,6 @@ public class Participant */ public void setDefaulted(boolean value) { - defaulted = value; + _defaulted = value; } } \ No newline at end of file diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java index 5cfad5d67f..11c873138c 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java @@ -24,12 +24,10 @@ import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMatchMa public class OlympiadMatchMaking implements IClientIncomingPacket { - private byte _gameRuleType; - @Override public boolean read(GameClient client, PacketReader packet) { - _gameRuleType = (byte) packet.readC(); + packet.readC(); // gameRuleType return true; } @@ -42,6 +40,6 @@ public class OlympiadMatchMaking implements IClientIncomingPacket return; } - player.sendPacket(new ExOlympiadMatchMakingResult(_gameRuleType, 1)); + player.sendPacket(new ExOlympiadMatchMakingResult(1)); } } \ No newline at end of file diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java index e165096e42..83e290fbae 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java @@ -24,12 +24,10 @@ import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMatchMa public class OlympiadMatchMakingCancel implements IClientIncomingPacket { - private byte _gameRuleType; - @Override public boolean read(GameClient client, PacketReader packet) { - _gameRuleType = (byte) packet.readC(); + packet.readC(); // gameRuleType return true; } @@ -42,6 +40,6 @@ public class OlympiadMatchMakingCancel implements IClientIncomingPacket return; } - player.sendPacket(new ExOlympiadMatchMakingResult(_gameRuleType, 0)); + player.sendPacket(new ExOlympiadMatchMakingResult(0)); } } \ No newline at end of file diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java index 255d11e91d..e4ea47de67 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.network.clientpackets.olympiad; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.enums.OlympiadMode; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMode; /** * format ch c: (id) 0xD0 h: (subid) 0x12 @@ -46,5 +48,9 @@ public class RequestOlympiadObserverEnd implements IClientIncomingPacket { player.leaveOlympiadObserverMode(); } + else + { + player.sendPacket(new ExOlympiadMode(OlympiadMode.NONE)); + } } } \ No newline at end of file diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java index b541ddf502..aa8cc4444b 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java @@ -22,7 +22,7 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; public class ExOlympiadInfo implements IClientOutgoingPacket { - private static int _open; + private final int _open; public ExOlympiadInfo(int open) { diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java deleted file mode 100644 index 1d7653e028..0000000000 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java +++ /dev/null @@ -1,37 +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 . - */ -package org.l2jmobius.gameserver.network.serverpackets.olympiad; - -import org.l2jmobius.commons.network.PacketWriter; -import org.l2jmobius.gameserver.network.OutgoingPackets; -import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; - -public class ExOlympiadMatchInfoEnd implements IClientOutgoingPacket -{ - public static final ExOlympiadMatchInfoEnd STATIC_PACKET = new ExOlympiadMatchInfoEnd(); - - private ExOlympiadMatchInfoEnd() - { - } - - @Override - public boolean write(PacketWriter packet) - { - OutgoingPackets.EX_OLYMPIAD_MATCH_INFO.writeId(packet); - return true; - } -} diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java index 80564627aa..90ebbea23d 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java @@ -82,7 +82,7 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket packet.writeD(0); } - packet.writeD(curGame.isRunning() ? 2 : 1); // (1 = Standby, 2 = Playing) + packet.writeD(curGame.isBattleStarted() || curGame.isBattleFinished() ? 1 : 2); // (1 = Standby, 2 = Playing) packet.writeS(game.getPlayerNames()[0]); // Player 1 Name packet.writeS(game.getPlayerNames()[1]); // Player 2 Name } diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java index a72825cad4..1ba52936ad 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java @@ -22,12 +22,10 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; public class ExOlympiadMatchMakingResult implements IClientOutgoingPacket { - private final int _gameRuleType; private final int _type; - public ExOlympiadMatchMakingResult(int cGameRuleType, int type) + public ExOlympiadMatchMakingResult(int type) { - _gameRuleType = 0; _type = type; } @@ -36,7 +34,7 @@ public class ExOlympiadMatchMakingResult implements IClientOutgoingPacket { OutgoingPackets.EX_OLYMPIAD_INFO.writeId(packet); packet.writeC(_type); - packet.writeD(_gameRuleType); + packet.writeD(0); return true; } } diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java index 2c57635a47..926911e420 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java @@ -68,26 +68,32 @@ public class ExOlympiadMatchResult implements IClientOutgoingPacket for (OlympiadInfo info : _winnerList) { packet.writeS(info.getName()); - packet.writeS(info.getClanName()); - packet.writeD(info.getClanId()); + + // New UI doesn't support clan name/id + packet.writeH(0); // clan name + packet.writeD(0); // clan id + packet.writeD(info.getClassId()); packet.writeD(info.getDamage()); packet.writeD(info.getCurrentPoints()); packet.writeD(info.getDiffPoints()); - packet.writeD(0); // Helios + packet.writeD(1); // Helios } packet.writeD(_loseTeam); packet.writeD(_loserList.size()); for (OlympiadInfo info : _loserList) { packet.writeS(info.getName()); - packet.writeS(info.getClanName()); - packet.writeD(info.getClanId()); + + // New UI doesn't support clan name/id + packet.writeH(0); // clan name + packet.writeD(0); // clan id + packet.writeD(info.getClassId()); packet.writeD(info.getDamage()); packet.writeD(info.getCurrentPoints()); packet.writeD(info.getDiffPoints()); - packet.writeD(0); // Helios + packet.writeD(1); // Helios } packet.writeC(_round1winner); // Round 1 outcome packet.writeC(_round2winner); // Round 2 outcome diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java index 1acac0ec7a..4ab2250f5f 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java @@ -29,10 +29,10 @@ public class ExOlympiadUserInfo implements IClientOutgoingPacket { private final Player _player; private Participant _par = null; - private int _curHp; - private int _maxHp; - private int _curCp; - private int _maxCp; + private final int _curHp; + private final int _maxHp; + private final int _curCp; + private final int _maxCp; public ExOlympiadUserInfo(Player player) { diff --git a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java index 35aa028535..1905691dc3 100644 --- a/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java +++ b/L2J_Mobius_10.1_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java @@ -20,9 +20,11 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.List; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.network.PacketWriter; @@ -31,12 +33,13 @@ import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.olympiad.Hero; import org.l2jmobius.gameserver.model.olympiad.Olympiad; +import org.l2jmobius.gameserver.model.olympiad.OlympiadFight; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.PacketLogger; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; /** - * @author NviX + * @author NviX, dontknowdontcare */ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket { @@ -116,7 +119,7 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket } catch (SQLException e) { - PacketLogger.warning("Olympiad my ranking: Couldnt load data: " + e.getMessage()); + PacketLogger.warning("Olympiad my ranking: Couldn't load data: " + e.getMessage()); } int heroCount = 0; int legendCount = 0; @@ -139,7 +142,31 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket packet.writeD(previousPoints); // Points on previous cycle packet.writeD(heroCount); // Hero counts packet.writeD(legendCount); // Legend counts - packet.writeD(0); // change to 1 causes shows nothing + + List fightList = _player.getOlympiadFightHistory().getFights(); + if (fightList == null) + { + fightList = new ArrayList<>(); + } + + packet.writeD(fightList.size()); + int count = 1; + for (OlympiadFight fight : fightList) + { + if (count > 3) + { + break; + } + + packet.writeH(fight.getOpponentName().length() + 1); + packet.writeS(fight.getOpponentName()); + packet.writeC(fight.getWinner()); + packet.writeD(fight.getOpponentLevel()); + packet.writeD(fight.getOpponentClassId()); + + count++; + } + return true; } } diff --git a/L2J_Mobius_10.2_MasterClass/dist/db_installer/sql/game/olympiad_fights.sql b/L2J_Mobius_10.2_MasterClass/dist/db_installer/sql/game/olympiad_fights.sql index 618ee73db0..15ffc8332b 100644 --- a/L2J_Mobius_10.2_MasterClass/dist/db_installer/sql/game/olympiad_fights.sql +++ b/L2J_Mobius_10.2_MasterClass/dist/db_installer/sql/game/olympiad_fights.sql @@ -4,6 +4,8 @@ CREATE TABLE IF NOT EXISTS `olympiad_fights` ( `charTwoId` int(10) unsigned NOT NULL, `charOneClass` tinyint(3) unsigned NOT NULL DEFAULT '0', `charTwoClass` tinyint(3) unsigned NOT NULL DEFAULT '0', + `charOneLevel` int(5) unsigned NOT NULL DEFAULT '0', + `charTwoLevel` int(5) unsigned NOT NULL DEFAULT '0', `winner` tinyint(1) unsigned NOT NULL DEFAULT '0', `start` bigint(13) unsigned NOT NULL DEFAULT '0', `time` bigint(13) unsigned NOT NULL DEFAULT '0', diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java index d8c9fa6825..c7bdd72e10 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/actor/Player.java @@ -258,6 +258,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.PlayerRefund; import org.l2jmobius.gameserver.model.itemcontainer.PlayerWarehouse; import org.l2jmobius.gameserver.model.matching.MatchingRoom; import org.l2jmobius.gameserver.model.olympiad.Hero; +import org.l2jmobius.gameserver.model.olympiad.OlympiadFightHistory; import org.l2jmobius.gameserver.model.olympiad.OlympiadGameManager; import org.l2jmobius.gameserver.model.olympiad.OlympiadGameTask; import org.l2jmobius.gameserver.model.olympiad.OlympiadManager; @@ -850,6 +851,8 @@ public class Player extends Playable private Map _customSkills = null; public final Set _replacedSkills = ConcurrentHashMap.newKeySet(1); + private final OlympiadFightHistory _olympiadFightHistory = new OlympiadFightHistory(this); + private volatile int _actionMask; private int _questZoneId = -1; @@ -13649,6 +13652,11 @@ public class Player extends Playable return _replacedSkills.contains(skillId); } + public OlympiadFightHistory getOlympiadFightHistory() + { + return _olympiadFightHistory; + } + /** * @return {@code true} if current player can revive and shows 'To Village' button upon death, {@code false} otherwise. */ diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java new file mode 100644 index 0000000000..29e288c309 --- /dev/null +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFight.java @@ -0,0 +1,56 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model.olympiad; + +/** + * @author dontknowdontcare + */ +public class OlympiadFight +{ + private final String _opponentName; + private final int _opponentClassId; + private final int _winner; // 0 = win, 1 = loss, 2 = draw + private final int _opponentLevel; + + public OlympiadFight(String opponentName, int opponentLevel, int opponentClassId, int winner) + { + _opponentName = opponentName; + _opponentClassId = opponentClassId; + _winner = winner; + _opponentLevel = opponentLevel; + } + + public String getOpponentName() + { + return _opponentName; + } + + public int getOpponentClassId() + { + return _opponentClassId; + } + + public int getWinner() + { + return _winner; + } + + public int getOpponentLevel() + { + return _opponentLevel; + } +} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java new file mode 100644 index 0000000000..047f6738c7 --- /dev/null +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadFightHistory.java @@ -0,0 +1,193 @@ +/* + * 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 . + */ +package org.l2jmobius.gameserver.model.olympiad; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +import org.l2jmobius.commons.database.DatabaseFactory; +import org.l2jmobius.gameserver.data.sql.CharNameTable; +import org.l2jmobius.gameserver.model.actor.Player; + +/** + * @author dontknowdontcare + */ +public class OlympiadFightHistory +{ + private static final Logger LOGGER = Logger.getLogger(OlympiadFightHistory.class.getName()); + + private static final int MAX_FIGHT_HISTORY_COUNT = 3; + private final Player _player; + + private List _fights = new ArrayList<>(); + + public OlympiadFightHistory(Player player) + { + _player = player; + if ((MAX_FIGHT_HISTORY_COUNT > 0) && (_player != null)) + { + loadRecentFights(_player.getObjectId()); + } + } + + public List getFights() + { + return _fights; + } + + public int getWinnerFormat(Participant parOne, Participant parTwo, int winner) + { + if (parOne == null) + { + LOGGER.warning("OlympiadFightHistory - getWinnerFormat error parOne is null, owner = " + _player.getName()); + return 2; + } + if (_player.getObjectId() == parOne.getObjectId()) + { + if (winner == 1) + { + return 0; + } + else if (winner == 2) + { + return 1; + } + else + { + return 2; + } + } + if (winner == 2) + { + return 0; + } + else if (winner == 1) + { + return 1; + } + else + { + return 2; + } + } + + public void addOlympiadFight(Participant opponent, int winner) + { + if (opponent != null) + { + final OlympiadFight fight = new OlympiadFight(opponent.getName(), opponent.getLevel(), opponent.getBaseClass(), winner); + final List newFights = new ArrayList<>(); + newFights.add(fight); + if ((MAX_FIGHT_HISTORY_COUNT > 1) && !_fights.isEmpty()) + { + for (int i = 0; i < (MAX_FIGHT_HISTORY_COUNT - 1); i++) + { + if (_fights.size() < (i + 1)) + { + break; + } + OlympiadFight curFight = _fights.get(i); + newFights.add(curFight); + } + } + _fights = newFights; + } + } + + private void loadRecentFights(int charId) + { + try (Connection con = DatabaseFactory.getConnection(); + PreparedStatement ps = con.prepareStatement("SELECT * FROM olympiad_fights WHERE (charOneId=? OR charTwoId=?) ORDER BY start DESC LIMIT " + MAX_FIGHT_HISTORY_COUNT)) + { + ps.setInt(1, charId); + ps.setInt(2, charId); + try (ResultSet rset = ps.executeQuery()) + { + int charOneId; + int charOneClass; + int charTwoId; + int charTwoClass; + int winner; + int opponentCharId; + int opponentLevel; + int opponentClassId; + int winInfo; + while (rset.next()) + { + charOneId = rset.getInt("charOneId"); + charOneClass = rset.getInt("charOneClass"); + charTwoId = rset.getInt("charTwoId"); + charTwoClass = rset.getInt("charTwoClass"); + winner = rset.getInt("winner"); + opponentLevel = charOneId == charId ? rset.getInt("charTwoLevel") : rset.getInt("charOneLevel"); + opponentCharId = charOneId == charId ? charTwoId : charOneId; + opponentClassId = charOneId == charId ? charTwoClass : charOneClass; + + final String name = CharNameTable.getInstance().getNameById(opponentCharId); + if ((name != null)) + { + // winInfo: 0 = win, 1 = loss, 2 = draw + if (charOneId == charId) + { + if (winner == 1) + { + winInfo = 0; + } + else if (winner == 2) + { + winInfo = 1; + } + else + { + winInfo = 2; + } + } + else + { + if (winner == 2) + { + winInfo = 0; + } + else if (winner == 1) + { + winInfo = 1; + } + else + { + winInfo = 2; + } + } + _fights.add(new OlympiadFight(name, opponentLevel, opponentClassId, winInfo)); + } + else + { + LOGGER.severe("OlympiadFightHistory could not load opponent name for char id = " + opponentCharId); + } + } + } + } + catch (SQLException e) + { + LOGGER.warning("OlympiadFightHistory: could not load fights history for CharId: " + charId + ": " + e); + } + } +} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java index 3665b8d802..9fe4265519 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/OlympiadGameNormal.java @@ -1192,17 +1192,24 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame protected void saveResults(Participant one, Participant two, int winner, long startTime, long fightTime, CompetitionType type) { + final int winnerFormat1 = one.getPlayer().getOlympiadFightHistory().getWinnerFormat(one, two, winner); + one.getPlayer().getOlympiadFightHistory().addOlympiadFight(two, winnerFormat1); + final int winnerFormat2 = two.getPlayer().getOlympiadFightHistory().getWinnerFormat(one, two, winner); + two.getPlayer().getOlympiadFightHistory().addOlympiadFight(one, winnerFormat2); + 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, charOneLevel, charTwoLevel, winner, start, time, classed) values(?,?,?,?,?,?,?,?,?,?)")) { statement.setInt(1, one.getObjectId()); statement.setInt(2, two.getObjectId()); statement.setInt(3, one.getBaseClass()); statement.setInt(4, two.getBaseClass()); - statement.setInt(5, winner); - statement.setLong(6, startTime); - statement.setLong(7, fightTime); - statement.setInt(8, (type == CompetitionType.CLASSED ? 1 : 0)); + statement.setInt(5, one.getLevel()); + statement.setInt(6, two.getLevel()); + statement.setInt(7, winner); + statement.setLong(8, startTime != 0 ? startTime : System.currentTimeMillis()); + statement.setLong(9, fightTime); + statement.setInt(10, (type == CompetitionType.CLASSED ? 1 : 0)); statement.execute(); } catch (SQLException e) diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/Participant.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/Participant.java index 6b00f4650b..9331b5712b 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/Participant.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/model/olympiad/Participant.java @@ -25,52 +25,60 @@ import org.l2jmobius.gameserver.model.actor.Player; */ public class Participant { - private final int objectId; - private Player player; - private final String name; - private final int side; - private final int baseClass; - private boolean disconnected = false; - private boolean defaulted = false; - private final StatSet stats; - public String clanName; - public int clanId; + private final int _objectId; + private Player _player; + private final String _name; + private final int _side; + private final int _baseClass; + private boolean _disconnected = false; + private boolean _defaulted = false; + private final StatSet _stats; + private final int _level; + private final String _clanName; + private final int _clanId; public Participant(Player plr, int olympiadSide) { - objectId = plr.getObjectId(); - player = plr; - name = plr.getName(); - side = olympiadSide; - baseClass = plr.getBaseClass(); - stats = Olympiad.getNobleStats(objectId); - clanName = plr.getClan() != null ? plr.getClan().getName() : ""; - clanId = plr.getClanId(); + _objectId = plr.getObjectId(); + _player = plr; + _name = plr.getName(); + _side = olympiadSide; + _baseClass = plr.getBaseClass(); + _stats = Olympiad.getNobleStats(_objectId); + _clanName = plr.getClan() != null ? plr.getClan().getName() : ""; + _clanId = plr.getClanId(); + _level = plr.getLevel(); } public Participant(int objId, int olympiadSide) { - objectId = objId; - player = null; - name = "-"; - side = olympiadSide; - baseClass = 0; - stats = null; - clanName = ""; - clanId = 0; + _objectId = objId; + _player = null; + _name = "-"; + _side = olympiadSide; + _baseClass = 0; + _stats = null; + _clanName = ""; + _clanId = 0; + _level = 0; + } + + public int getLevel() + { + return _level; } /** - * Updates the reference to {@link #player}, if it's null or appears off-line. + * Updates the reference to {@link #_player}, if it's null or appears off-line. * @return {@code true} if after the update the player isn't null, {@code false} otherwise. */ public boolean updatePlayer() { - if ((player == null) || !player.isOnline()) + if ((_player == null) || !_player.isOnline()) { - player = World.getInstance().getPlayer(getObjectId()); + _player = World.getInstance().getPlayer(getObjectId()); } - return (player != null); + return (_player != null); } /** @@ -79,7 +87,7 @@ public class Participant */ public void updateStat(String statName, int increment) { - stats.set(statName, Math.max(stats.getInt(statName) + increment, 0)); + _stats.set(statName, Math.max(_stats.getInt(statName) + increment, 0)); } /** @@ -87,7 +95,7 @@ public class Participant */ public String getName() { - return name; + return _name; } /** @@ -95,7 +103,7 @@ public class Participant */ public String getClanName() { - return clanName; + return _clanName; } /** @@ -103,7 +111,7 @@ public class Participant */ public int getClanId() { - return clanId; + return _clanId; } /** @@ -111,7 +119,7 @@ public class Participant */ public Player getPlayer() { - return player; + return _player; } /** @@ -119,7 +127,7 @@ public class Participant */ public int getObjectId() { - return objectId; + return _objectId; } /** @@ -127,7 +135,7 @@ public class Participant */ public StatSet getStats() { - return stats; + return _stats; } /** @@ -135,7 +143,7 @@ public class Participant */ public void setPlayer(Player noble) { - player = noble; + _player = noble; } /** @@ -143,7 +151,7 @@ public class Participant */ public int getSide() { - return side; + return _side; } /** @@ -151,7 +159,7 @@ public class Participant */ public int getBaseClass() { - return baseClass; + return _baseClass; } /** @@ -159,7 +167,7 @@ public class Participant */ public boolean isDisconnected() { - return disconnected; + return _disconnected; } /** @@ -167,7 +175,7 @@ public class Participant */ public void setDisconnected(boolean value) { - disconnected = value; + _disconnected = value; } /** @@ -175,7 +183,7 @@ public class Participant */ public boolean isDefaulted() { - return defaulted; + return _defaulted; } /** @@ -183,6 +191,6 @@ public class Participant */ public void setDefaulted(boolean value) { - defaulted = value; + _defaulted = value; } } \ No newline at end of file diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java index 5cfad5d67f..11c873138c 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMaking.java @@ -24,12 +24,10 @@ import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMatchMa public class OlympiadMatchMaking implements IClientIncomingPacket { - private byte _gameRuleType; - @Override public boolean read(GameClient client, PacketReader packet) { - _gameRuleType = (byte) packet.readC(); + packet.readC(); // gameRuleType return true; } @@ -42,6 +40,6 @@ public class OlympiadMatchMaking implements IClientIncomingPacket return; } - player.sendPacket(new ExOlympiadMatchMakingResult(_gameRuleType, 1)); + player.sendPacket(new ExOlympiadMatchMakingResult(1)); } } \ No newline at end of file diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java index e165096e42..83e290fbae 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/OlympiadMatchMakingCancel.java @@ -24,12 +24,10 @@ import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMatchMa public class OlympiadMatchMakingCancel implements IClientIncomingPacket { - private byte _gameRuleType; - @Override public boolean read(GameClient client, PacketReader packet) { - _gameRuleType = (byte) packet.readC(); + packet.readC(); // gameRuleType return true; } @@ -42,6 +40,6 @@ public class OlympiadMatchMakingCancel implements IClientIncomingPacket return; } - player.sendPacket(new ExOlympiadMatchMakingResult(_gameRuleType, 0)); + player.sendPacket(new ExOlympiadMatchMakingResult(0)); } } \ No newline at end of file diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java index 255d11e91d..e4ea47de67 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/clientpackets/olympiad/RequestOlympiadObserverEnd.java @@ -17,9 +17,11 @@ package org.l2jmobius.gameserver.network.clientpackets.olympiad; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.enums.OlympiadMode; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; +import org.l2jmobius.gameserver.network.serverpackets.olympiad.ExOlympiadMode; /** * format ch c: (id) 0xD0 h: (subid) 0x12 @@ -46,5 +48,9 @@ public class RequestOlympiadObserverEnd implements IClientIncomingPacket { player.leaveOlympiadObserverMode(); } + else + { + player.sendPacket(new ExOlympiadMode(OlympiadMode.NONE)); + } } } \ No newline at end of file diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java index b541ddf502..aa8cc4444b 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadInfo.java @@ -22,7 +22,7 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; public class ExOlympiadInfo implements IClientOutgoingPacket { - private static int _open; + private final int _open; public ExOlympiadInfo(int open) { diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java deleted file mode 100644 index 1d7653e028..0000000000 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchInfoEnd.java +++ /dev/null @@ -1,37 +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 . - */ -package org.l2jmobius.gameserver.network.serverpackets.olympiad; - -import org.l2jmobius.commons.network.PacketWriter; -import org.l2jmobius.gameserver.network.OutgoingPackets; -import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; - -public class ExOlympiadMatchInfoEnd implements IClientOutgoingPacket -{ - public static final ExOlympiadMatchInfoEnd STATIC_PACKET = new ExOlympiadMatchInfoEnd(); - - private ExOlympiadMatchInfoEnd() - { - } - - @Override - public boolean write(PacketWriter packet) - { - OutgoingPackets.EX_OLYMPIAD_MATCH_INFO.writeId(packet); - return true; - } -} diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java index 80564627aa..90ebbea23d 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchList.java @@ -82,7 +82,7 @@ public class ExOlympiadMatchList implements IClientOutgoingPacket packet.writeD(0); } - packet.writeD(curGame.isRunning() ? 2 : 1); // (1 = Standby, 2 = Playing) + packet.writeD(curGame.isBattleStarted() || curGame.isBattleFinished() ? 1 : 2); // (1 = Standby, 2 = Playing) packet.writeS(game.getPlayerNames()[0]); // Player 1 Name packet.writeS(game.getPlayerNames()[1]); // Player 2 Name } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java index a72825cad4..1ba52936ad 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchMakingResult.java @@ -22,12 +22,10 @@ import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; public class ExOlympiadMatchMakingResult implements IClientOutgoingPacket { - private final int _gameRuleType; private final int _type; - public ExOlympiadMatchMakingResult(int cGameRuleType, int type) + public ExOlympiadMatchMakingResult(int type) { - _gameRuleType = 0; _type = type; } @@ -36,7 +34,7 @@ public class ExOlympiadMatchMakingResult implements IClientOutgoingPacket { OutgoingPackets.EX_OLYMPIAD_INFO.writeId(packet); packet.writeC(_type); - packet.writeD(_gameRuleType); + packet.writeD(0); return true; } } diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java index 2c57635a47..926911e420 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadMatchResult.java @@ -68,26 +68,32 @@ public class ExOlympiadMatchResult implements IClientOutgoingPacket for (OlympiadInfo info : _winnerList) { packet.writeS(info.getName()); - packet.writeS(info.getClanName()); - packet.writeD(info.getClanId()); + + // New UI doesn't support clan name/id + packet.writeH(0); // clan name + packet.writeD(0); // clan id + packet.writeD(info.getClassId()); packet.writeD(info.getDamage()); packet.writeD(info.getCurrentPoints()); packet.writeD(info.getDiffPoints()); - packet.writeD(0); // Helios + packet.writeD(1); // Helios } packet.writeD(_loseTeam); packet.writeD(_loserList.size()); for (OlympiadInfo info : _loserList) { packet.writeS(info.getName()); - packet.writeS(info.getClanName()); - packet.writeD(info.getClanId()); + + // New UI doesn't support clan name/id + packet.writeH(0); // clan name + packet.writeD(0); // clan id + packet.writeD(info.getClassId()); packet.writeD(info.getDamage()); packet.writeD(info.getCurrentPoints()); packet.writeD(info.getDiffPoints()); - packet.writeD(0); // Helios + packet.writeD(1); // Helios } packet.writeC(_round1winner); // Round 1 outcome packet.writeC(_round2winner); // Round 2 outcome diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java index 1acac0ec7a..4ab2250f5f 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/olympiad/ExOlympiadUserInfo.java @@ -29,10 +29,10 @@ public class ExOlympiadUserInfo implements IClientOutgoingPacket { private final Player _player; private Participant _par = null; - private int _curHp; - private int _maxHp; - private int _curCp; - private int _maxCp; + private final int _curHp; + private final int _maxHp; + private final int _curCp; + private final int _maxCp; public ExOlympiadUserInfo(Player player) { diff --git a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java index 35aa028535..1905691dc3 100644 --- a/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java +++ b/L2J_Mobius_10.2_MasterClass/java/org/l2jmobius/gameserver/network/serverpackets/ranking/ExOlympiadMyRankingInfo.java @@ -20,9 +20,11 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.List; import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.network.PacketWriter; @@ -31,12 +33,13 @@ import org.l2jmobius.gameserver.model.StatSet; import org.l2jmobius.gameserver.model.actor.Player; import org.l2jmobius.gameserver.model.olympiad.Hero; import org.l2jmobius.gameserver.model.olympiad.Olympiad; +import org.l2jmobius.gameserver.model.olympiad.OlympiadFight; import org.l2jmobius.gameserver.network.OutgoingPackets; import org.l2jmobius.gameserver.network.PacketLogger; import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket; /** - * @author NviX + * @author NviX, dontknowdontcare */ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket { @@ -116,7 +119,7 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket } catch (SQLException e) { - PacketLogger.warning("Olympiad my ranking: Couldnt load data: " + e.getMessage()); + PacketLogger.warning("Olympiad my ranking: Couldn't load data: " + e.getMessage()); } int heroCount = 0; int legendCount = 0; @@ -139,7 +142,31 @@ public class ExOlympiadMyRankingInfo implements IClientOutgoingPacket packet.writeD(previousPoints); // Points on previous cycle packet.writeD(heroCount); // Hero counts packet.writeD(legendCount); // Legend counts - packet.writeD(0); // change to 1 causes shows nothing + + List fightList = _player.getOlympiadFightHistory().getFights(); + if (fightList == null) + { + fightList = new ArrayList<>(); + } + + packet.writeD(fightList.size()); + int count = 1; + for (OlympiadFight fight : fightList) + { + if (count > 3) + { + break; + } + + packet.writeH(fight.getOpponentName().length() + 1); + packet.writeS(fight.getOpponentName()); + packet.writeC(fight.getWinner()); + packet.writeD(fight.getOpponentLevel()); + packet.writeD(fight.getOpponentClassId()); + + count++; + } + return true; } }