* For Lottery Manager *
*/
public void showLotoWindow(L2Player player, int val) {
int npcId = getTemplate().npcId;
String filename;
SystemMessage sm;
NpcHtmlMessage html = new NpcHtmlMessage(player, this);
// if loto
if (val == 0) {
filename = getHtmlPath(npcId, 1);
html.setFile(filename);
} else if (val >= 1 && val <= 21) {
if (!LotteryManager.getInstance().isStarted()) {
/** LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD **/
player.sendPacket(Msg.LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD);
return;
}
if (!LotteryManager.getInstance().isSellableTickets()) {
/** TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE **/
player.sendPacket(Msg.TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE);
return;
}
filename = getHtmlPath(npcId, 5);
html.setFile(filename);
int count = 0;
int found = 0;
// counting buttons and unsetting button if found
for (int i = 0; i < 5; i++) {
if (player.getLoto(i) == val) {
// unsetting button
player.setLoto(i, 0);
found = 1;
} else if (player.getLoto(i) > 0) {
count++;
}
}
// if not rearched limit 5 and not unseted value
if (count < 5 && found == 0 && val <= 20) {
for (int i = 0; i < 5; i++) {
if (player.getLoto(i) == 0) {
player.setLoto(i, val);
break;
}
}
}
// setting pusshed buttons
count = 0;
for (int i = 0; i < 5; i++) {
if (player.getLoto(i) > 0) {
count++;
String button = String.valueOf(player.getLoto(i));
if (player.getLoto(i) < 10) {
button = "0" + button;
}
String search = "fore=\"L2UI.lottoNum" + button + "\" back=\"L2UI.lottoNum" + button + "a_check\"";
String replace = "fore=\"L2UI.lottoNum" + button + "a_check\" back=\"L2UI.lottoNum" + button + "\"";
html.replace(search, replace);
}
}
if (count == 5) {
String search = "0\">Return";
String replace = "22\">The winner selected the numbers above.";
html.replace(search, replace);
}
player.sendPacket(html);
}
if (val == 22) {
if (!LotteryManager.getInstance().isStarted()) {
/** LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD **/
player.sendPacket(Msg.LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD);
return;
}
if (!LotteryManager.getInstance().isSellableTickets()) {
/** TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE **/
player.sendPacket(Msg.TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE);
return;
}
int price = Config.SERVICES_ALT_LOTTERY_PRICE;
int lotonumber = LotteryManager.getInstance().getId();
int enchant = 0;
int type2 = 0;
for (int i = 0; i < 5; i++) {
if (player.getLoto(i) == 0) {
return;
}
if (player.getLoto(i) < 17) {
enchant += Math.pow(2, player.getLoto(i) - 1);
} else {
type2 += Math.pow(2, player.getLoto(i) - 17);
}
}
if (player.getAdena() < price) {
player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
return;
}
player.reduceAdena(price, true);
sm = new SystemMessage(SystemMessage.ACQUIRED__S1_S2);
sm.addNumber(lotonumber);
sm.addItemName(4442);
player.sendPacket(sm);
L2ItemInstance item = ItemTable.getInstance().createItem(4442);
item.setCustomType1(lotonumber);
item.setEnchantLevel(enchant);
item.setCustomType2(type2);