Esempio n. 1
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);
        }
Esempio n. 2
0
        private static void ApplyInternal(Kingdom kingdom, Kingdom otherKingdom, bool forcePlayerCharacterCosts)
        {
            FactionManager.DeclareAlliance(kingdom, otherKingdom);
            float influenceCost = DiplomacyCostCalculator.DetermineInfluenceCostForFormingAlliance(kingdom, otherKingdom, forcePlayerCharacterCosts);

            if (forcePlayerCharacterCosts)
            {
                DiplomacyCostManager.deductInfluenceFromPlayerClan(influenceCost);
            }
            else
            {
                DiplomacyCostManager.DeductInfluenceFromKingdom(kingdom, influenceCost);
            }
            Events.Instance.OnAllianceFormed(new AllianceEvent(kingdom, otherKingdom));
        }
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject textObject, bool forcePlayerCharacterCosts = false)
        {
            textObject = null;
            float influenceCost = DiplomacyCostCalculator.DetermineInfluenceCostForFormingAlliance(kingdom, otherKingdom, true);
            bool  hasEnoughInfluence;

            if (forcePlayerCharacterCosts)
            {
                hasEnoughInfluence = influenceCost <= Clan.PlayerClan.Influence;
            }
            else
            {
                hasEnoughInfluence = influenceCost <= kingdom.Leader.Clan.Influence;
            }

            if (!hasEnoughInfluence)
            {
                textObject = new TextObject(NOT_ENOUGH_INFLUENCE);
            }

            return(hasEnoughInfluence);
        }