Beispiel #1
0
        private void MainBattleOnAboutToExitBattle(IBattleManager battle, ICombatList attackers, ICombatList defenders)
        {
            IStronghold stronghold;

            if (!gameObjectLocator.TryGetObjects(strongholdId, out stronghold))
            {
                throw new Exception("Stronghold not found");
            }

            var defensiveMeter = battle.GetProperty <decimal>("defense_stronghold_meter");
            // Transfer stronghold if
            // - defensive meter is 0
            // - occupied state and there is no one left defending it
            // - neutral state and the attacker killed the main group

            var hasDefendingUnitsLeft = stronghold.Troops.StationedHere().Any(p => p.TotalCount > 0);

            if (defensiveMeter <= 0 ||
                (stronghold.StrongholdState == StrongholdState.Occupied && !hasDefendingUnitsLeft) ||
                (stronghold.StrongholdState == StrongholdState.Neutral && npcGroupKilled))
            {
                strongholdManager.TransferTo(stronghold, stronghold.GateOpenTo);
            }
            else
            {
                strongholdManager.TribeFailedToTakeStronghold(stronghold, stronghold.GateOpenTo);
            }
        }