Ejemplo n.º 1
0
 /** Method chanceCycle. */
 @Override
 public void chanceCycle() {
   super.chanceCycle();
   if (getCycle() >= REMOVE_CYCLE) {
     getOwner()
         .broadcastToOnlineMembers(SystemMsg.ENEMY_BLOOD_PLEDGES_HAVE_INTRUDED_INTO_THE_FORTRESS);
     changeOwner(null);
     return;
   }
   setPaidCycle(getPaidCycle() + 1);
   if ((getPaidCycle() % REWARD_CYCLE) == 0) {
     setPaidCycle(0);
     setRewardCount(getRewardCount() + 1);
     if (getContractState() == CONTRACT_WITH_CASTLE) {
       Castle castle = ResidenceHolder.getInstance().getResidence(Castle.class, _castleId);
       if ((castle.getOwner() == null)
           || (castle.getOwner().getReputationScore() < 2)
           || (_owner.getWarehouse().getCountOf(ItemTemplate.ITEM_ID_ADENA) > CASTLE_FEE)) {
         setSupplyCount(0);
         setFortState(INDEPENDENT, 0);
         clearFacility();
       } else {
         if (_supplyCount < 6) {
           castle.getOwner().incReputation(-2, false, "Fortress:chanceCycle():" + getId());
           _owner.getWarehouse().destroyItemByItemId(ItemTemplate.ITEM_ID_ADENA, CASTLE_FEE);
           _supplyCount++;
         }
       }
     }
   }
 }
 /** Method runImpl. */
 @Override
 protected void runImpl() {
   Player player = getClient().getActiveChar();
   if (player == null) {
     return;
   }
   Castle castle = ResidenceHolder.getInstance().getResidence(Castle.class, _unitId);
   if ((castle == null) || (castle.getOwner() == null)) {
     return;
   }
   player.sendPacket(new CastleSiegeDefenderList(castle));
 }
Ejemplo n.º 3
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();
 }