コード例 #1
0
        protected override void UpdateActionAvailability()
        {
            base.UpdateActionAvailability();
            string breakAllianceException = AllianceConditions.CanBreakAllianceExceptions(this).FirstOrDefault()?.ToString();

            this.ActionHint        = breakAllianceException != null ? new HintViewModel(breakAllianceException) : new HintViewModel();
            this.IsOptionAvailable = breakAllianceException == null;
        }
コード例 #2
0
        private static void ConsiderBreakingAlliances(Kingdom kingdom)
        {
            List <Kingdom> alliedKingdoms = Kingdom.All.Where(otherKingdom => otherKingdom != kingdom).Where(otherKingdom => FactionManager.IsAlliedWithFaction(kingdom, otherKingdom)).ToList();

            foreach (Kingdom alliedKingdom in alliedKingdoms)
            {
                if (MBRandom.RandomFloat < 0.05f && AllianceConditions.CanBreakAlliance(kingdom, alliedKingdom) && !AllianceScoringModel.ShouldFormAlliance(kingdom, alliedKingdom))
                {
                    BreakAllianceAction.Apply(kingdom, alliedKingdom);
                }
            }
        }
コード例 #3
0
        protected virtual void UpdateActionAvailability()
        {
            this.IsMessengerAvailable = MessengerManager.CanSendMessengerWithInfluenceCost(Faction2Leader.Hero, this.SendMessengerInfluenceCost);
            this.IsOptionAvailable    = WarAndPeaceConditions.CanDeclareWarExceptions(this).IsEmpty();
            string allianceException = AllianceConditions.CanFormAllianceExceptions(this, true).FirstOrDefault()?.ToString();

            this.IsAllianceAvailable = allianceException == null;
            string declareWarException = WarAndPeaceConditions.CanDeclareWarExceptions(this).FirstOrDefault()?.ToString();

            this.ActionHint            = declareWarException != null ? new HintViewModel(declareWarException) : new HintViewModel();
            this.AllianceHint          = allianceException != null ? new HintViewModel(allianceException) : new HintViewModel();
            this.AllianceInfluenceCost = (int)DiplomacyCostCalculator.DetermineInfluenceCostForFormingAlliance(Faction1 as Kingdom, Faction2 as Kingdom, true);
        }
コード例 #4
0
        private static void ConsiderFormingAlliances(Kingdom kingdom)
        {
            List <Kingdom> potentialAllies = Kingdom.All.Where(otherKingdom => otherKingdom != kingdom).Where(otherKingdom => AllianceConditions.CanFormAlliance(kingdom, otherKingdom)).ToList();

            foreach (Kingdom potentialAlly in potentialAllies)
            {
                if (MBRandom.RandomFloat < 0.05f && AllianceScoringModel.ShouldFormAlliance(kingdom, potentialAlly))
                {
                    DeclareAllianceAction.Apply(kingdom, potentialAlly);
                }
            }
        }