int val = Integer.parseInt(command.substring(13));
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
showChatWindow(player, 1, null, false);
break;
case 2: // Festival 2 xxxx
// Check if the festival period is active, if not then don't allow registration.
if(SevenSigns.getInstance().getCurrentPeriod() != SevenSigns.PERIOD_COMPETITION)
{
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(new CustomMessage("l2p.gameserver.model.instances.L2FestivalGuideInstance.InProgress", player));
return;
}
// Check if the player is in a formed party already.
if(playerParty == null || playerParty.getMemberCount() < Config.FESTIVAL_MIN_PARTY_SIZE)
{
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 if all the party members are in the required level range.
int maxlevel = SevenSignsFestival.getMaxLevelForFestival(_festivalType);
for(L2Player p : playerParty.getPartyMembers())
{
if(p.getLevel() > maxlevel)
{
showChatWindow(player, 2, "d", false);
return;
}
else if(SevenSigns.getInstance().getPlayerCabal(p) == SevenSigns.CABAL_NULL)
{
showChatWindow(player, 2, "g", false);
return;
}
}
if(player.isFestivalParticipant())
{
showChatWindow(player, 2, "f", false);
return;
}
int stoneType = Integer.parseInt(command.substring(11));
long stonesNeeded = (long) Math.floor(SevenSignsFestival.getStoneCount(_festivalType, stoneType) * Config.FESTIVAL_RATE_PRICE);
L2ItemInstance sealStoneInst = player.getInventory().getItemByItemId(stoneType);
if(sealStoneInst == null || sealStoneInst.getCount() < stonesNeeded)
{
player.sendMessage(new CustomMessage("l2p.gameserver.model.instances.L2FestivalGuideInstance.NotEnoughSSType", player));
return;
}
player.getInventory().destroyItem(sealStoneInst, stonesNeeded, true);
player.sendPacket(SystemMessage.removeItems(stoneType, stonesNeeded));
SevenSignsFestival.getInstance().addAccumulatedBonus(_festivalType, stoneType, stonesNeeded);
new DarknessFestival(player.getParty(), SevenSigns.getInstance().getPlayerCabal(player), _festivalType);
showChatWindow(player, 2, "e", false);
break;
case 4: // Current High Scores
StringBuffer strBuffer = new StringBuffer("<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("names").replaceAll(",", ", ") + "<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("names").replaceAll(",", ", ") + "<br>");
}
else
{
strBuffer.append("Dusk: No record exists. Score 0<br>");
}
if(overallScore > 0 && overallData != null)
{
String cabalStr = "Children of Dusk";
if(overallData.getInteger("cabal") == SevenSigns.CABAL_DAWN)
{
cabalStr = "Children of Dawn";
}
strBuffer.append("Consecutive top scores: " + calculateDate(overallData.getString("date")) + ". Score " + overallScore + "<br>Affilated side: " + cabalStr + "<br>" + overallData.getString("names").replaceAll(",", ", ") + "<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(player, this);
html.setHtml(strBuffer.toString());
player.sendPacket(html);
break;
case 8: // Increase the Festival Challenge
if(playerParty == null)
{
return;
}
if(!playerParty.isLeader(player))
{
showChatWindow(player, 8, "a", false);
break;
}
Reflection r = getReflection();
if(r instanceof DarknessFestival)
{
if(((DarknessFestival) r).increaseChallenge())
{
showChatWindow(player, 8, "b", false);
}
else
{
showChatWindow(player, 8, "c", false);
}
}
break;
case 9: // Leave the Festival
if(playerParty == null)
{
return;
}
r = getReflection();
if(!(r instanceof DarknessFestival))
{
return;
}
if(playerParty.isLeader(player))
{
((DarknessFestival) r).collapse();
}
else if(playerParty.getMemberCount() > Config.FESTIVAL_MIN_PARTY_SIZE)
{
playerParty.oustPartyMember(player);
}
else
{
player.sendMessage("Only party leader can leave festival, if minmum party member is reached.");
}