Ejemplo n.º 1
0
  /**
   * Method onBypassFeedback.
   *
   * @param player Player
   * @param command String
   */
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) {
      return;
    }

    Fortress fortress = getFortress();

    if (command.equals("defenceInfo")) {
      if ((player.getClanPrivileges() & Clan.CP_CS_MANAGE_SIEGE) != Clan.CP_CS_MANAGE_SIEGE) {
        showChatWindow(player, "residence2/fortress/fortress_not_authorized.htm");
        return;
      }

      if (fortress.getContractState() != Fortress.CONTRACT_WITH_CASTLE) {
        showChatWindow(player, "residence2/fortress/fortress_supply_officer005.htm");
        return;
      }

      showChatWindow(
          player,
          "residence2/fortress/fortress_garrison002.htm",
          "%facility_0%",
          fortress.getFacilityLevel(Fortress.REINFORCE),
          "%facility_2%",
          fortress.getFacilityLevel(Fortress.DOOR_UPGRADE),
          "%facility_3%",
          fortress.getFacilityLevel(Fortress.DWARVENS),
          "%facility_4%",
          fortress.getFacilityLevel(Fortress.SCOUT));
    } else if (command.equals("defenceUp1") || command.equals("defenceUp2")) {
      buyFacility(player, Fortress.REINFORCE, Integer.parseInt(command.substring(9, 10)), 100000);
    } else if (command.equals("deployScouts")) {
      buyFacility(player, Fortress.SCOUT, 1, 150000);
    } else if (command.equals("doorUpgrade")) {
      boolean buy = buyFacility(player, Fortress.DOOR_UPGRADE, 1, 200000);

      if (buy) {
        List<DoorObject> doorObjects =
            fortress.getSiegeEvent().getObjects(FortressSiegeEvent.UPGRADEABLE_DOORS);

        for (DoorObject d : doorObjects) {
          d.setUpgradeValue(
              fortress.<SiegeEvent<?, ?>>getSiegeEvent(),
              d.getDoor().getMaxHp() * fortress.getFacilityLevel(Fortress.DOOR_UPGRADE));
        }
      }
    } else if (command.equals("hireDwarves")) {
      buyFacility(player, Fortress.DWARVENS, 1, 100000);
    }
  }