コード例 #1
0
ファイル: CreatePouch.java プロジェクト: Delcorum/WrathServer
  /**
   * 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;
  }