예제 #1
0
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    if (command.startsWith("BuyTicket") && state != ACCEPTING_BETS) {
      player.sendPacket(SystemMsg.MONSTER_RACE_TICKETS_ARE_NO_LONGER_AVAILABLE);
      command = "Chat 0";
    }
    if (command.startsWith("ShowOdds") && state == ACCEPTING_BETS) {
      player.sendPacket(
          SystemMsg.MONSTER_RACE_PAYOUT_INFORMATION_IS_NOT_AVAILABLE_WHILE_TICKETS_ARE_BEING_SOLD);
      command = "Chat 0";
    }

    if (command.startsWith("BuyTicket")) {
      int val = Integer.parseInt(command.substring(10));
      if (val == 0) {
        player.setRace(0, 0);
        player.setRace(1, 0);
      }
      if (val == 10 && player.getRace(0) == 0
          || val == 20 && player.getRace(0) == 0 && player.getRace(1) == 0) val = 0;
      showBuyTicket(player, val);
    } else if (command.equals("ShowOdds")) showOdds(player);
    else if (command.equals("ShowInfo")) showMonsterInfo(player);
    else if (command.equals("calculateWin")) {
      // displayCalculateWinnings(player);
    } else if (command.equals("viewHistory")) {
      // displayHistory(player);
    } else super.onBypassFeedback(player, command);
  }
예제 #2
0
 public void showBuyTicket(Player player, int val) {
   if (state != ACCEPTING_BETS) return;
   int npcId = getNpcId();
   String filename, search, replace;
   NpcHtmlMessage html = new NpcHtmlMessage(player, this);
   if (val < 10) {
     filename = getHtmlPath(npcId, 2, player);
     html.setFile(filename);
     for (int i = 0; i < 8; i++) {
       int n = i + 1;
       search = "Mob" + n;
       html.replace(search, MonsterRace.getInstance().getMonsters()[i].getTemplate().name);
     }
     search = "No1";
     if (val == 0) html.replace(search, "");
     else {
       html.replace(search, "" + val);
       player.setRace(0, val);
     }
   } else if (val < 20) {
     if (player.getRace(0) == 0) return;
     filename = getHtmlPath(npcId, 3, player);
     html.setFile(filename);
     html.replace("0place", "" + player.getRace(0));
     search = "Mob1";
     replace = MonsterRace.getInstance().getMonsters()[player.getRace(0) - 1].getTemplate().name;
     html.replace(search, replace);
     search = "0adena";
     if (val == 10) html.replace(search, "");
     else {
       html.replace(search, "" + cost[val - 11]);
       player.setRace(1, val - 10);
     }
   } else if (val == 20) {
     if (player.getRace(0) == 0 || player.getRace(1) == 0) return;
     filename = getHtmlPath(npcId, 4, player);
     html.setFile(filename);
     html.replace("0place", "" + player.getRace(0));
     search = "Mob1";
     replace = MonsterRace.getInstance().getMonsters()[player.getRace(0) - 1].getTemplate().name;
     html.replace(search, replace);
     search = "0adena";
     int price = cost[player.getRace(1) - 1];
     html.replace(search, "" + price);
     search = "0tax";
     int tax = 0;
     html.replace(search, "" + tax);
     search = "0total";
     int total = price + tax;
     html.replace(search, "" + total);
   } else {
     if (player.getRace(0) == 0 || player.getRace(1) == 0) return;
     if (player.getAdena() < cost[player.getRace(1) - 1]) {
       player.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
       return;
     }
     int ticket = player.getRace(0);
     int priceId = player.getRace(1);
     player.setRace(0, 0);
     player.setRace(1, 0);
     player.reduceAdena(cost[priceId - 1], true);
     SystemMessage sm = new SystemMessage(SystemMessage.ACQUIRED__S1_S2);
     sm.addNumber(_raceNumber);
     sm.addItemName(4443);
     player.sendPacket(sm);
     ItemInstance item = ItemFunctions.createItem(4443);
     item.setEnchantLevel(_raceNumber);
     item.setCustomType1(ticket);
     item.setCustomType2(cost[priceId - 1] / 100);
     player.getInventory().addItem(item);
     return;
   }
   html.replace("1race", String.valueOf(_raceNumber));
   player.sendPacket(html);
   player.sendActionFailed();
 }