_gpreward = Config.ALT_OLY_CLASSED_RITEM_C;
classed = "yes";
break;
}
StatsSet playerOneStat = Olympiad.getNobleStats(_playerOne.getObjectId());
StatsSet playerTwoStat = Olympiad.getNobleStats(_playerTwo.getObjectId());
int playerOnePlayed = playerOneStat.getInteger(COMP_DONE);
int playerTwoPlayed = playerTwoStat.getInteger(COMP_DONE);
int playerOneWon = playerOneStat.getInteger(COMP_WON);
int playerTwoWon = playerTwoStat.getInteger(COMP_WON);
int playerOneLost = playerOneStat.getInteger(COMP_LOST);
int playerTwoLost = playerTwoStat.getInteger(COMP_LOST);
int playerOneDrawn = playerOneStat.getInteger(COMP_DRAWN);
int playerTwoDrawn = playerTwoStat.getInteger(COMP_DRAWN);
int playerOnePoints = playerOneStat.getInteger(POINTS);
int playerTwoPoints = playerTwoStat.getInteger(POINTS);
int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / _div;
// Check for if a player defaulted before battle started
if (_playerOneDefaulted || _playerTwoDefaulted)
{
if (_playerOneDefaulted)
{
int lostPoints = playerOnePoints / 3;
playerOneStat.set(POINTS, playerOnePoints - lostPoints);
Olympiad.updateNobleStats(_playerOne.getObjectId(), playerOneStat);
SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
sm.addString(_playerOneName);
sm.addNumber(lostPoints);
broadcastMessage(sm, false);
if (Config.DEBUG)
_log.info("Olympia Result: " + _playerOneName + " lost " + lostPoints + " points for defaulting");
Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,_playerOneName+" default",lostPoints,classed);
}
if (_playerTwoDefaulted)
{
int lostPoints = playerTwoPoints / 3;
playerTwoStat.set(POINTS, playerTwoPoints - lostPoints);
Olympiad.updateNobleStats(_playerTwo.getObjectId(), playerTwoStat);
SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
sm.addString(_playerTwoName);
sm.addNumber(lostPoints);
broadcastMessage(sm, false);
if (Config.DEBUG)
_log.info("Olympia Result: " + _playerTwoName + " lost " + lostPoints + " points for defaulting");
Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,_playerTwoName+" default",lostPoints,classed);
}
return;
}
// Create results for players if a player crashed
if (_pOneCrash || _pTwoCrash)
{
if (_pOneCrash && !_pTwoCrash)
{
try
{
playerOneStat.set(POINTS, playerOnePoints - pointDiff);
playerOneStat.set(COMP_LOST, playerOneLost + 1);
if (Config.DEBUG)
_log.info("Olympia Result: " + _playerOneName + " vs " + _playerTwoName + " ... "
+ _playerOneName + " lost " + pointDiff + " points for crash");
Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,_playerOneName+" crash",pointDiff,classed);
playerTwoStat.set(POINTS, playerTwoPoints + pointDiff);
playerTwoStat.set(COMP_WON, playerTwoWon + 1);
if (Config.DEBUG)
_log.info("Olympia Result: " + _playerOneName + " vs " + _playerTwoName + " ... "
+ _playerTwoName + " Win " + pointDiff + " points");
_sm = new SystemMessage(SystemMessageId.S1_HAS_WON_THE_GAME);
_sm2 = new SystemMessage(SystemMessageId.S1_HAS_GAINED_S2_OLYMPIAD_POINTS);
_sm.addString(_playerTwoName);
broadcastMessage(_sm, true);
_sm2.addString(_playerTwoName);
_sm2.addNumber(pointDiff);
broadcastMessage(_sm2, false);
}
catch (Exception e)
{
e.printStackTrace();
}
}
else if (_pTwoCrash && !_pOneCrash)
{
try
{
playerTwoStat.set(POINTS, playerTwoPoints - pointDiff);
playerTwoStat.set(COMP_LOST, playerTwoLost + 1);
if (Config.DEBUG)
_log.info("Olympia Result: " + _playerTwoName + " vs " + _playerOneName + " ... "
+ _playerTwoName + " lost " + pointDiff + " points for crash");
Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,_playerTwoName+" crash",pointDiff,classed);
playerOneStat.set(POINTS, playerOnePoints + pointDiff);
playerOneStat.set(COMP_WON, playerOneWon + 1);
if (Config.DEBUG)
_log.info("Olympia Result: " + _playerTwoName + " vs " + _playerOneName + " ... "
+ _playerOneName + " Win " + pointDiff + " points");
_sm = new SystemMessage(SystemMessageId.S1_HAS_WON_THE_GAME);
_sm2 = new SystemMessage(SystemMessageId.S1_HAS_GAINED_S2_OLYMPIAD_POINTS);
_sm.addString(_playerOneName);
broadcastMessage(_sm, true);
_sm2.addString(_playerOneName);
_sm2.addNumber(pointDiff);
broadcastMessage(_sm2, false);
}
catch (Exception e)
{
e.printStackTrace();
}
}
else if (_pOneCrash && _pTwoCrash)
{
try
{
playerOneStat.set(POINTS, playerOnePoints - pointDiff);
playerOneStat.set(COMP_LOST, playerOneLost + 1);
playerTwoStat.set(POINTS, playerTwoPoints - pointDiff);
playerTwoStat.set(COMP_LOST, playerTwoLost + 1);
if (Config.DEBUG)
_log.info("Olympia Result: " + _playerOneName + " vs " + _playerTwoName + " ... "
+ " both lost " + pointDiff + " points for crash");
Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,"both crash",pointDiff,classed);
}
catch (Exception e)
{
e.printStackTrace();
}
}
playerOneStat.set(COMP_DONE, playerOnePlayed + 1);
playerTwoStat.set(COMP_DONE, playerTwoPlayed + 1);
Olympiad.updateNobleStats(_playerOne.getObjectId(), playerOneStat);
Olympiad.updateNobleStats(_playerTwo.getObjectId(), playerTwoStat);
return;
}
double playerOneHp = 0;
if (!_playerOne.isDead())
{
playerOneHp = _playerOne.getCurrentHp() + _playerOne.getCurrentCp();
}
double playerTwoHp = 0;
if (!_playerTwo.isDead())
{
playerTwoHp = _playerTwo.getCurrentHp() + _playerTwo.getCurrentCp();
}
_sm = new SystemMessage(SystemMessageId.S1_HAS_WON_THE_GAME);
_sm2 = new SystemMessage(SystemMessageId.S1_HAS_GAINED_S2_OLYMPIAD_POINTS);
_sm3 = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
String result = "";
String winner = "draw";
if (_playerOne == null && _playerTwo == null)
{
playerOneStat.set(COMP_DRAWN, playerOneDrawn + 1);
playerTwoStat.set(COMP_DRAWN, playerTwoDrawn + 1);
result = " tie";
_sm = new SystemMessage(SystemMessageId.THE_GAME_ENDED_IN_A_TIE);
broadcastMessage(_sm, true);
}
else if (_playerTwo == null
|| _playerTwo.isOnline() == 0
|| (playerTwoHp == 0 && playerOneHp != 0)
|| (_damageP1 > _damageP2 && playerTwoHp != 0 && playerOneHp != 0))
{
playerOneStat.set(POINTS, playerOnePoints + pointDiff);
playerTwoStat.set(POINTS, playerTwoPoints - pointDiff);
playerOneStat.set(COMP_WON, playerOneWon + 1);
playerTwoStat.set(COMP_LOST, playerTwoLost + 1);
_sm.addString(_playerOneName);
broadcastMessage(_sm, true);
_sm2.addString(_playerOneName);
_sm2.addNumber(pointDiff);
broadcastMessage(_sm2, false);
_sm3.addString(_playerTwoName);
_sm3.addNumber(pointDiff);
broadcastMessage(_sm3, false);
winner = _playerOneName + " won";
try
{
result = " (" + playerOneHp + "hp vs " + playerTwoHp + "hp - "
+ _damageP1 + "dmg vs " + _damageP2 + "dmg) "
+ _playerOneName + " win " + pointDiff + " points";
L2ItemInstance item = _playerOne.getInventory().addItem("Olympiad", Config.ALT_OLY_BATTLE_REWARD_ITEM, _gpreward, _playerOne, null);
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(item);
_playerOne.sendPacket(iu);
SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
sm.addItemName(item.getItemId());
sm.addNumber(_gpreward);
_playerOne.sendPacket(sm);
}
catch (Exception e)
{
}
}
else if (_playerOne == null
|| _playerOne.isOnline() == 0
|| (playerOneHp == 0 && playerTwoHp != 0)
|| (_damageP2 > _damageP1 && playerOneHp != 0 && playerTwoHp != 0))
{
playerTwoStat.set(POINTS, playerTwoPoints + pointDiff);
playerOneStat.set(POINTS, playerOnePoints - pointDiff);
playerTwoStat.set(COMP_WON, playerTwoWon + 1);
playerOneStat.set(COMP_LOST, playerOneLost + 1);
_sm.addString(_playerTwoName);
broadcastMessage(_sm, true);
_sm2.addString(_playerTwoName);
_sm2.addNumber(pointDiff);
broadcastMessage(_sm2, false);
_sm3.addString(_playerOneName);
_sm3.addNumber(pointDiff);
broadcastMessage(_sm3, false);
winner = _playerTwoName + " won";
try
{
result = " (" + playerOneHp + "hp vs " + playerTwoHp + "hp - "
+ _damageP1 + "dmg vs " + _damageP2 + "dmg) "
+ _playerTwoName + " win " + pointDiff + " points";
L2ItemInstance item = _playerTwo.getInventory().addItem("Olympiad", Config.ALT_OLY_BATTLE_REWARD_ITEM, _gpreward, _playerTwo, null);
InventoryUpdate iu = new InventoryUpdate();
iu.addModifiedItem(item);
_playerTwo.sendPacket(iu);
SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
sm.addItemName(item.getItemId());
sm.addNumber(_gpreward);
_playerTwo.sendPacket(sm);
}
catch (Exception e)
{
}
}
else
{
result = " tie";
_sm = new SystemMessage(SystemMessageId.THE_GAME_ENDED_IN_A_TIE);
broadcastMessage(_sm, true);
int pointOneDiff = playerOnePoints / 5;
int pointTwoDiff = playerTwoPoints / 5;
playerOneStat.set(POINTS, playerOnePoints - pointOneDiff);
playerTwoStat.set(POINTS, playerTwoPoints - pointTwoDiff);
playerOneStat.set(COMP_DRAWN, playerOneDrawn + 1);
playerTwoStat.set(COMP_DRAWN, playerTwoDrawn + 1);
_sm2 = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
_sm2.addString(_playerOneName);
_sm2.addNumber(pointOneDiff);
broadcastMessage(_sm2, false);
_sm3 = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
_sm3.addString(_playerTwoName);
_sm3.addNumber(pointTwoDiff);
broadcastMessage(_sm3, false);
}
if (Config.DEBUG)
_log.info("Olympia Result: " + _playerOneName + " vs " + _playerTwoName + " ... " + result);
playerOneStat.set(COMP_DONE, playerOnePlayed + 1);
playerTwoStat.set(COMP_DONE, playerTwoPlayed + 1);
Olympiad.updateNobleStats(_playerOne.getObjectId(), playerOneStat);
Olympiad.updateNobleStats(_playerTwo.getObjectId(), playerTwoStat);
Olympiad.logResult(_playerOneName, _playerTwoName, playerOneHp, playerTwoHp, _damageP1, _damageP2, winner, pointDiff, classed);