showChatWindow(player, val, null, true);
}
else if(command.startsWith("Festival"))
{
L2Party playerParty = player.getParty();
int val = Integer.parseInt(command.substring(9, 10));
switch(val)
{
case 1: // Become a Participant
// Check if the festival period is active, if not then don't allow registration.
if(SevenSigns.getInstance().isSealValidationPeriod())
{
showChatWindow(player, 2, "a", false);
return;
}
// Check if a festival is in progress, then don't allow registration yet.
if(SevenSignsFestival.getInstance().isFestivalInitialized())
{
player.sendMessage("You cannot sign up while a festival is in progress.");
return;
}
// Check if the player is in a formed party already.
if(playerParty == null)
{
showChatWindow(player, 2, "b", false);
return;
}
// Check if the player is the party leader.
if(!playerParty.isLeader(player))
{
showChatWindow(player, 2, "c", false);
return;
}
// Check to see if the party has at least 5 members.
if(playerParty.getMemberCount() < Config.ALT_FESTIVAL_MIN_PLAYER)
{
showChatWindow(player, 2, "b", false);
return;
}
// Check if all the party members are in the required level range.
if(playerParty.getLevel() > SevenSignsFestival.getMaxLevelForFestival(_festivalType))
{
showChatWindow(player, 2, "d", false);
return;
}
// TODO: Check if the player has delevelled by comparing their skill levels.
/*
* Check to see if the player has already signed up,
* if they are then update the participant list providing all the
* required criteria has been met.
*/
if(player.isFestivalParticipant())
{
SevenSignsFestival.getInstance().setParticipants(_festivalOracle, _festivalType, playerParty);
showChatWindow(player, 2, "f", false);
return;
}
showChatWindow(player, 1, null, false);
break;
case 2: // Festival 2 xxxx
int stoneType = Integer.parseInt(command.substring(11));
int stonesNeeded = 0;
switch(stoneType)
{
case SevenSigns.SEAL_STONE_BLUE_ID:
stonesNeeded = _blueStonesNeeded;
break;
case SevenSigns.SEAL_STONE_GREEN_ID:
stonesNeeded = _greenStonesNeeded;
break;
case SevenSigns.SEAL_STONE_RED_ID:
stonesNeeded = _redStonesNeeded;
break;
}
if(!player.destroyItemByItemId("SevenSigns", stoneType, stonesNeeded, this, true))
return;
SevenSignsFestival.getInstance().setParticipants(_festivalOracle, _festivalType, playerParty);
SevenSignsFestival.getInstance().addAccumulatedBonus(_festivalType, stoneType, stonesNeeded);
showChatWindow(player, 2, "e", false);
break;
case 3: // Score Registration
// Check if the festival period is active, if not then don't register the score.
if(SevenSigns.getInstance().isSealValidationPeriod())
{
showChatWindow(player, 3, "a", false);
return;
}
// Check if a festival is in progress, if it is don't register the score.
if(SevenSignsFestival.getInstance().isFestivalInProgress())
{
player.sendMessage("You cannot register a score while a festival is in progress.");
return;
}
// Check if the player is in a party.
if(playerParty == null)
{
showChatWindow(player, 3, "b", false);
return;
}
List<L2PcInstance> prevParticipants = SevenSignsFestival.getInstance().getPreviousParticipants(_festivalOracle, _festivalType);
// Check if there are any past participants.
if(prevParticipants == null)
return;
// Check if this player was among the past set of participants for this festival.
if(!prevParticipants.contains(player))
{
showChatWindow(player, 3, "b", false);
return;
}
// Check if this player was the party leader in the festival.
if(player.getObjectId() != prevParticipants.get(0).getObjectId())
{
showChatWindow(player, 3, "b", false);
return;
}
L2ItemInstance bloodOfferings = player.getInventory().getItemByItemId(SevenSignsFestival.FESTIVAL_OFFERING_ID);
int offeringCount = 0;
// Check if the player collected any blood offerings during the festival.
if(bloodOfferings == null)
{
player.sendMessage("You do not have any blood offerings to contribute.");
return;
}
offeringCount = bloodOfferings.getCount();
int offeringScore = offeringCount * SevenSignsFestival.FESTIVAL_OFFERING_VALUE;
boolean isHighestScore = SevenSignsFestival.getInstance().setFinalScore(player, _festivalOracle, _festivalType, offeringScore);
player.destroyItem("SevenSigns", bloodOfferings, this, false);
// Send message that the contribution score has increased.
SystemMessage sm = new SystemMessage(SystemMessageId.CONTRIB_SCORE_INCREASED);
sm.addNumber(offeringScore);
player.sendPacket(sm);
sm = null;
if(isHighestScore)
{
showChatWindow(player, 3, "c", false);
}
else
{
showChatWindow(player, 3, "d", false);
}
prevParticipants = null;
bloodOfferings = null;
break;
case 4: // Current High Scores
TextBuilder strBuffer = new TextBuilder("<html><body>Festival Guide:<br>These are the top scores of the week, for the ");
final StatsSet dawnData = SevenSignsFestival.getInstance().getHighestScoreData(SevenSigns.CABAL_DAWN, _festivalType);
final StatsSet duskData = SevenSignsFestival.getInstance().getHighestScoreData(SevenSigns.CABAL_DUSK, _festivalType);
final StatsSet overallData = SevenSignsFestival.getInstance().getOverallHighestScoreData(_festivalType);
final int dawnScore = dawnData.getInteger("score");
final int duskScore = duskData.getInteger("score");
int overallScore = 0;
// If no data is returned, assume there is no record, or all scores are 0.
if(overallData != null)
{
overallScore = overallData.getInteger("score");
}
strBuffer.append(SevenSignsFestival.getFestivalName(_festivalType) + " festival.<br>");
if(dawnScore > 0)
{
strBuffer.append("Dawn: " + calculateDate(dawnData.getString("date")) + ". Score " + dawnScore + "<br>" + dawnData.getString("members") + "<br>");
}
else
{
strBuffer.append("Dawn: No record exists. Score 0<br>");
}
if(duskScore > 0)
{
strBuffer.append("Dusk: " + calculateDate(duskData.getString("date")) + ". Score " + duskScore + "<br>" + duskData.getString("members") + "<br>");
}
else
{
strBuffer.append("Dusk: No record exists. Score 0<br>");
}
if ((overallScore > 0) && (overallData != null))
{
String cabalStr = "Children of Dusk";
if(overallData.getString("cabal").equals("dawn"))
{
cabalStr = "Children of Dawn";
}
strBuffer.append("Consecutive top scores: " + calculateDate(overallData.getString("date")) + ". Score " + overallScore + "<br>Affilated side: " + cabalStr + "<br>" + overallData.getString("members") + "<br>");
}
else
{
strBuffer.append("Consecutive top scores: No record exists. Score 0<br>");
}
strBuffer.append("<a action=\"bypass -h npc_" + getObjectId() + "_Chat 0\">Go back.</a></body></html>");
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setHtml(strBuffer.toString());
player.sendPacket(html);
strBuffer = null;
html = null;
break;
case 8: // Increase the Festival Challenge
if(playerParty == null)
return;
if(!SevenSignsFestival.getInstance().isFestivalInProgress())
return;
if(!playerParty.isLeader(player))
{
showChatWindow(player, 8, "a", false);
break;
}
if(SevenSignsFestival.getInstance().increaseChallenge(_festivalOracle, _festivalType))
{
showChatWindow(player, 8, "b", false);
}
else
{
showChatWindow(player, 8, "c", false);
}
break;
case 9: // Leave the Festival
if(playerParty == null)
return;
/**
* If the player is the party leader, remove all participants from the festival (i.e. set the party
* to null, when updating the participant list) otherwise just remove this player from the "arena",
* and also remove them from the party.
*/
boolean isLeader = playerParty.isLeader(player);
if(isLeader)
{
SevenSignsFestival.getInstance().updateParticipants(player, null);
}
else
{
SevenSignsFestival.getInstance().updateParticipants(player, playerParty);
playerParty.removePartyMember(player);
}
break;
case 0: // Distribute Accumulated Bonus
if(!SevenSigns.getInstance().isSealValidationPeriod())
{