package services;
import core.gameserver.Config;
import core.gameserver.cache.Msg;
import core.gameserver.data.xml.holder.ItemHolder;
import core.gameserver.model.Player;
import core.gameserver.model.pledge.UnitMember;
import core.gameserver.scripts.Functions;
import core.gameserver.network.l2.s2c.MagicSkillUse;
import core.gameserver.network.l2.s2c.PledgeShowInfoUpdate;
import core.gameserver.network.l2.s2c.SystemMessage2;
import core.gameserver.network.l2.components.CustomMessage;
import core.gameserver.network.l2.components.SystemMsg;
import core.gameserver.utils.SiegeUtils;
public class Clan extends Functions {
public void getPoints(String[] param) {
Player player = getSelf();
if (player == null) {
return;
}
if (!Config.SERVICES_CLAN_BUY_POINTS_ENABLED) {
show(new CustomMessage("scripts.services.TurnOff", player), player);
return;
}
if (player.getClan() == null) {
player.sendMessage("Вы должны быть в клане.");
return;
}
int n = Integer.parseInt(param[0]);
int countCRP = Config.SERVICES_CLAN_BUY_POINTS_PRICE[n][0];
int price = Config.SERVICES_CLAN_BUY_POINTS_PRICE[n][1];
if (Functions.getItemCount(player, Config.SERVICES_CLAN_BUY_POINTS_ITEM) < price) {
player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
return;
}
if (player.getInventory().destroyItemByItemId(Config.SERVICES_CLAN_BUY_POINTS_ITEM, price)) {
player.sendPacket(SystemMessage2.removeItems(Config.SERVICES_CLAN_BUY_POINTS_ITEM, price));
player.getClan().incReputation(countCRP, false, "ClanService");
player.getClan().broadcastToOnlineMembers(new PledgeShowInfoUpdate(player.getClan()));
player.sendMessage(new CustomMessage("scripts.services.Clan.Rep", player).addNumber(countCRP));
}
}
public void points_page() {
Player player = getSelf();
if (player == null) {
return;
}
if (!Config.SERVICES_CLAN_BUY_POINTS_ENABLED) {
show(new CustomMessage("scripts.services.TurnOff", player), player);
return;
}
if (player.getClan() == null) {
player.sendMessage("Вы должны быть в клане.");
return;
}
// Уровень клана должен быть 5 или больше.
if (player.getClan().getLevel() < 5) {
player.sendMessage(new CustomMessage("scripts.services.Clan.MinLvl", player));
return;
}
String item_name = ItemHolder.getInstance().getTemplate(Config.SERVICES_CLAN_BUY_POINTS_ITEM).getName();
String append = "Покупка очков репутации клана:";
append += "<br>";
append += "Клан " + player.getClan().getName() + ": уровень <font color=\"LEVEL\">" + player.getClan().getLevel() + "</font>, CRP <font color=\"LEVEL\">" + player.getClan().getReputationScore() + "</font>";
append += "<br>";
append += "<table>";
append += "<tr><td><center>CRP</center></td><td><center>Цена</center></td></tr>";
for (int i = 0; i < Config.SERVICES_CLAN_BUY_POINTS_PRICE.length; i++) {
append
+= "<tr>"
+ "<td><font color=\"FF9900\">" + Config.SERVICES_CLAN_BUY_POINTS_PRICE[i][0] + "</font> CRP</td>"
+ "<td><font color=\"FF9900\">" + Config.SERVICES_CLAN_BUY_POINTS_PRICE[i][1] + "</font> " + item_name + "</td>"
+ "<td>" + "<button value=\"Купить\" action=\"bypass -h scripts_services.Clan:getPoints " + i + "\" width=60 height=20 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>"
+ "</tr>";
}
append += "</table>";
show(append, player);
}
}