/**
   * 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);
    }
  }
Exemple #2
0
 /**
  * Method changeOwner.
  *
  * @param clan Clan
  */
 @Override
 public void changeOwner(Clan clan) {
   if (clan != null) {
     if (clan.getHasFortress() != 0) {
       Fortress oldFortress =
           ResidenceHolder.getInstance().getResidence(Fortress.class, clan.getHasFortress());
       if (oldFortress != null) {
         oldFortress.changeOwner(null);
       }
     }
     if (clan.getCastle() != 0) {
       Castle oldCastle =
           ResidenceHolder.getInstance().getResidence(Castle.class, clan.getCastle());
       if (oldCastle != null) {
         oldCastle.changeOwner(null);
       }
     }
   }
   if ((getOwnerId() > 0) && ((clan == null) || (clan.getClanId() != getOwnerId()))) {
     removeSkills();
     Clan oldOwner = getOwner();
     if (oldOwner != null) {
       oldOwner.setHasFortress(0);
     }
     cancelCycleTask();
     clearFacility();
   }
   if (clan != null) {
     clan.setHasFortress(getId());
   }
   updateOwnerInDB(clan);
   rewardSkills();
   setFortState(NOT_DECIDED, 0);
   setJdbcState(JdbcEntityState.UPDATED);
   update();
 }