Пример #1
0
 @Override
 protected void execute() {
   int newAmount = 0;
   for (int i = 1; i <= amount; i++) {
     if (hasRequirements(player, buttonId, false, 1, pouchData)) {
       player.getInventory().remove(new Item(POUCH_ID, 1));
       player.getInventory().remove(new Item(SHARD_ID, 1));
       player.getInventory().remove(new Item(pouchData.getCharmId(), 1));
       player.getInventory().remove(new Item(pouchData.getSecondIngredientId(), 1));
       player.getInventory().add(new Item(pouchData.getPouchId(), 1));
       newAmount++;
     } else {
       break;
     }
   }
   if (newAmount == 0) {
     abort();
     return;
   }
   player.playAnimation(new Animation(725));
   player.playGraphics(new Graphic(1207));
   player
       .getSkill()
       .addExperience(
           Skill.SUMMONING, pouchData.getExp() * newAmount * Constants.SUMMONING_EXPERIENCE);
   player.sendMessage(
       "You infuse "
           + newAmount
           + " "
           + new Item(pouchData.getPouchId()).getDefinition().getName()
           + (newAmount > 1 ? "s" : "")
           + ".");
   abort();
 }
Пример #2
0
  /**
   * Checks whether or not that player has requirements to make the pouch.
   *
   * @param c The Player.
   * @param itemId The item id.
   * @param slot The slot of the item.
   */
  public static boolean hasRequirements(
      final Player player, final int buttonId, boolean inform, int amount, PouchData pouch) {
    if (inform) {
      if (player.getSkill().getLevelForExperience(Skill.SUMMONING) < pouch.getLevelRequired()) {
        player.sendMessage(
            "You need a summoning level of " + pouch.getLevelRequired() + " to create this pouch");
        return false;
      }
    }
    if (!player.getInventory().contains(POUCH_ID)) {
      if (inform) {
        player.sendMessage("You dont have a pouch to create this item.");
      }
      return false;
    }
    if (!player.getInventory().hasItem(new Item(SHARD_ID, pouch.getShardsRequired()))) {
      if (inform) {
        player.sendMessage(
            "You need " + pouch.getShardsRequired() + " shards to create this pouch.");
      }
      return false;
    }

    if (!player.getInventory().contains(pouch.getCharmId())) {
      if (inform) {
        player.sendMessage(
            "You need a "
                + new Item(pouch.getCharmId()).getDefinition().getName()
                + " to create this pouch.");
      }
      return false;
    }
    if (!player.getInventory().contains(pouch.getSecondIngredientId())) {
      if (inform) {
        player.sendMessage(
            "You need "
                + new Item(pouch.getSecondIngredientId()).getDefinition().getName()
                + " to create this pouch.");
      }
      return false;
    }
    player.setCurrentSkill(new CreatePouch(player, buttonId, amount));
    player.getCurrentSkill().start();
    return true;
  }
Пример #3
0
  @Override
  public void execute() {
    if (player.getInventory().get(slot).getId() != impling.getJar()) {
      stop();
      return;
    }

    if (player.getInventory().freeSlots() < 2) {
      player.sendMessage("You do not have enough free inventory slots to do this.");
      stop();
      return;
    }

    player.getInventory().remove(slot, new Item(impling.getJar()));
    player.getInventory().add(impling.getRandomReward());
    player.getInventory().add(new Item(ItemIdentifiers.IMPLING_JAR));
    player.sendMessage("You loot the impling jar for a reward.");
    stop();
  }
Пример #4
0
  public static boolean stakeItem(Player player, int itemId, int amount, int slot) {
    if (!player.getInventory().contains(itemId) || !player.getDuel().isDueling()) {
      return false;
    }

    if (player.getInterfaceState().getCurrentInterface() != 37888) {
      return false;
    }

    if (new Item(itemId).getDefinition().isUntradeable()) {
      player.sendMessage("This item is currently untradeable and cannot be staked.");
      return false;
    }

    Player playerToDuel =
        GameService.getWorld().getByUsername(player.getDuel().getDuelingWith()).get();

    if (playerToDuel == null) {
      return false;
    }

    if (player.getDuel().getStatus() != DuelingStatus.WAITING_FIRST_ACCEPT
            && player.getDuel().getStatus() != DuelingStatus.ACCEPTED_FIRST_INTERFACE
        || playerToDuel.getDuel().getStatus() != DuelingStatus.WAITING_FIRST_ACCEPT
            && playerToDuel.getDuel().getStatus() != DuelingStatus.ACCEPTED_FIRST_INTERFACE) {
      DuelArenaHandler.declineDuel(player, true);
      return false;
    }

    if (player.getInventory().getItemAmount(itemId) < amount) {
      amount = player.getInventory().getItemAmount(itemId);

      if (amount == 0 || player.getInventory().getItemAmount(itemId) < amount) {
        return false;
      }
    }

    if (player.getDuel().getStakeInventory().add(new Item(itemId, amount))) {
      player.getInventory().remove(new Item(itemId, amount));
    }

    DuelArenaHandler.updateStakedItems(player, playerToDuel);

    player.getSession().send(new SendStringPacket("", 6684));
    playerToDuel.getSession().send(new SendStringPacket("", 6684));

    player.getDuel().setStatus(DuelingStatus.WAITING_FIRST_ACCEPT);
    playerToDuel.getDuel().setStatus(DuelingStatus.WAITING_FIRST_ACCEPT);
    player.setAttribute("stake_change_delay", System.currentTimeMillis());
    return true;
  }