List<SiegeClanObject> attackers = removeObjects(ATTACKERS);
for (SiegeClanObject siegeClan : attackers)
siegeClan.deleteFlag();
broadcastToWorld(new SystemMessage2(SystemMsg.THE_SIEGE_OF_S1_IS_FINISHED).addResidenceName(getResidence()));
removeObjects(DEFENDERS);
removeObjects(DEFENDERS_WAITING);
removeObjects(DEFENDERS_REFUSED);
Clan ownerClan = getResidence().getOwner();
if (ownerClan != null) {
if (_oldOwner == ownerClan) {
getResidence().setRewardCount(getResidence().getRewardCount() + 1);
ownerClan.broadcastToOnlineMembers(new SystemMessage2(SystemMsg.SINCE_YOUR_CLAN_EMERGED_VICTORIOUS_FROM_THE_SIEGE_S1_POINTS_HAVE_BEEN_ADDED_TO_YOUR_CLANS_REPUTATION_SCORE).addInteger(ownerClan.incReputation(1500, false, toString())));
} else {
broadcastToWorld(new SystemMessage2(SystemMsg.CLAN_S1_IS_VICTORIOUS_OVER_S2S_CASTLE_SIEGE).addString(ownerClan.getName()).addResidenceName(getResidence()));
ownerClan.broadcastToOnlineMembers(new SystemMessage2(SystemMsg.SINCE_YOUR_CLAN_EMERGED_VICTORIOUS_FROM_THE_SIEGE_S1_POINTS_HAVE_BEEN_ADDED_TO_YOUR_CLANS_REPUTATION_SCORE).addInteger(ownerClan.incReputation(3000, false, toString())));
if (_oldOwner != null)
_oldOwner.broadcastToOnlineMembers(new SystemMessage2(SystemMsg.YOUR_CLAN_HAS_FAILED_TO_DEFEND_THE_CASTLE_S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_YOU_CLAN_REPUTATION_SCORE_AND_ADDED_TO_YOUR_OPPONENTS).addInteger(-_oldOwner.incReputation(-3000, false, toString())));
for (UnitMember member : ownerClan) {
Player player = member.getPlayer();
if (player != null) {
player.sendPacket(PlaySound.SIEGE_VICTORY);
if (player.isOnline() && player.isNoble())
Hero.getInstance().addHeroDiary(player.getObjectId(), HeroDiary.ACTION_CASTLE_TAKEN, getResidence().getId());
}
}
}
getResidence().getOwnDate().setTimeInMillis(System.currentTimeMillis());
getResidence().getLastSiegeDate().setTimeInMillis(getResidence().getSiegeDate().getTimeInMillis());
} else {
broadcastToWorld(new SystemMessage2(SystemMsg.THE_SIEGE_OF_S1_HAS_ENDED_IN_A_DRAW).addResidenceName(getResidence()));
getResidence().getOwnDate().setTimeInMillis(0);
getResidence().getLastSiegeDate().setTimeInMillis(0);
}