Olympiad ranking and fight history adjustments.
Contributed by dontknowdontcare.
This commit is contained in:
parent
89a65f97bf
commit
32d64f1037
@ -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',
|
||||
|
@ -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<Integer, Skill> _customSkills = null;
|
||||
public final Set<Integer> _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.
|
||||
*/
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<OlympiadFight> _fights = new ArrayList<>();
|
||||
|
||||
public OlympiadFightHistory(Player player)
|
||||
{
|
||||
_player = player;
|
||||
if ((MAX_FIGHT_HISTORY_COUNT > 0) && (_player != null))
|
||||
{
|
||||
loadRecentFights(_player.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
public List<OlympiadFight> 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<OlympiadFight> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<OlympiadFight> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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<Integer, Skill> _customSkills = null;
|
||||
public final Set<Integer> _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.
|
||||
*/
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<OlympiadFight> _fights = new ArrayList<>();
|
||||
|
||||
public OlympiadFightHistory(Player player)
|
||||
{
|
||||
_player = player;
|
||||
if ((MAX_FIGHT_HISTORY_COUNT > 0) && (_player != null))
|
||||
{
|
||||
loadRecentFights(_player.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
public List<OlympiadFight> 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<OlympiadFight> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<OlympiadFight> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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<Integer, Skill> _customSkills = null;
|
||||
public final Set<Integer> _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.
|
||||
*/
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<OlympiadFight> _fights = new ArrayList<>();
|
||||
|
||||
public OlympiadFightHistory(Player player)
|
||||
{
|
||||
_player = player;
|
||||
if ((MAX_FIGHT_HISTORY_COUNT > 0) && (_player != null))
|
||||
{
|
||||
loadRecentFights(_player.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
public List<OlympiadFight> 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<OlympiadFight> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<OlympiadFight> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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',
|
||||
|
@ -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<Integer, Skill> _customSkills = null;
|
||||
public final Set<Integer> _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.
|
||||
*/
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<OlympiadFight> _fights = new ArrayList<>();
|
||||
|
||||
public OlympiadFightHistory(Player player)
|
||||
{
|
||||
_player = player;
|
||||
if ((MAX_FIGHT_HISTORY_COUNT > 0) && (_player != null))
|
||||
{
|
||||
loadRecentFights(_player.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
public List<OlympiadFight> 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<OlympiadFight> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<OlympiadFight> 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user