Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.sf.l2j.gameserver.custom.events.mines;
- import net.sf.l2j.commons.lang.StringUtil;
- import net.sf.l2j.commons.random.Rnd;
- import net.sf.l2j.gameserver.model.actor.instance.Player;
- import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- import java.util.ArrayList;
- import java.util.List;
- public class Mines extends MinesEvent {
- private int _selected = -1;
- private final List<MineBox> _boxs = new ArrayList<>();
- private int _lives = 3;
- public Mines() {
- feedList();
- }
- public void minesWindow(Player player) {
- final StringBuilder sb = new StringBuilder();
- if(_lives != 0) {
- selectedBox(getSelected());
- StringUtil.append(sb, "<br>Lives");
- StringUtil.append(sb, "<br1><table width=96><tr>");
- for (int sI = 0; sI < _lives; sI++)
- StringUtil.append(sb, "<td><button action=\"bypass \" width=32 height=32 back=\"icon.etc_dice_a_i00\" fore=\"icon.etc_dice_a_i00\"></td>");
- StringUtil.append(sb, "</tr></table>");
- StringUtil.append(sb, "<br><table width=260>");
- int i = 0;
- for (MineBox bx : _boxs) {
- final boolean isNextLine = i % 6 == 0;
- if (isNextLine)
- sb.append("<tr>");
- StringUtil.append(sb, "" + displayIcons(bx.position, bx.chance, bx.selected, bx.content));
- if (isNextLine)
- sb.append("</tr>");
- i++;
- }
- StringUtil.append(sb, "</table>");
- }else
- StringUtil.append(sb, "<br>You Lost");
- NpcHtmlMessage html = new NpcHtmlMessage(0);
- html.setFile("data/html/mods/Events/mines/minesMW.htm");
- html.replace("%mines%", sb.toString());
- player.sendPacket(html);
- }
- public String displayIcons(int chanceNum,int position,boolean selected, String content){
- String tempHolder = "";
- if(selected)
- tempHolder = content;
- else
- tempHolder = "<td><button action=\"bypass _menuMinesSelect " + chanceNum + " "+ position + "\" width=32 height=32 back=\"icon.etc_box_of_adventure_1_i00\" fore=\"icon.etc_box_of_adventure_1_i00\"></td>";
- return tempHolder;
- }
- public void selectedBox(int pos){
- for(MineBox bx : _boxs){
- if(bx.position == pos){
- bx.selected = true;
- if(bx.chance < 50) {
- bx.content = "<td><button action=\"bypass \" width=32 height=32 back=\"icon.etc_torch_on_i00\" fore=\"icon.etc_torch_on_i00\"></td>";
- _lives--;
- }else
- bx.content = "<td><button action=\"bypass \" width=32 height=32 back=\"icon.etc_pig_adena_i00\" fore=\"icon.etc_pig_adena_i00\"></td>";
- }
- }
- }
- public class MineBox{
- public int position;
- public int chance;
- public boolean selected;
- public String content;
- }
- public void feedList(){
- for(int i=0; i < 30; i++){
- MineBox bx = new MineBox();
- bx.position = i;
- bx.chance = Rnd.get(100);
- bx.selected = false;
- _boxs.add(bx);
- }
- }
- public void setSelected(int position){
- _selected = position;
- }
- public int getSelected()
- {
- return _selected;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement