Ejemplo n.º 1
0
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;
            IEnumerable <LogEntry> gameActionLogs = Campaign.Current.LogEntryHistory.GameActionLogs;

            var lastPeaceTime = CampaignTime.Never;

            foreach (var logEntry in gameActionLogs)
            {
                if (logEntry is MakePeaceLogEntry &&
                    ((((MakePeaceLogEntry)logEntry).Faction1 == kingdom.MapFaction && ((MakePeaceLogEntry)logEntry).Faction2 == otherKingdom.MapFaction) || (((MakePeaceLogEntry)logEntry).Faction1 == otherKingdom.MapFaction && ((MakePeaceLogEntry)logEntry).Faction2 == kingdom.MapFaction)))
                {
                    lastPeaceTime = logEntry.GameTime;
                    break;
                }
            }

            var daysSinceLastWar     = CampaignTime.Now.ToDays - lastPeaceTime.ToDays;
            var hasEnoughTimeElapsed = lastPeaceTime == CampaignTime.Never || daysSinceLastWar > MinimumTimeFromLastWar;

            if (!hasEnoughTimeElapsed)
            {
                textObject = new TextObject(TOO_SOON);
                textObject.SetTextVariable("ELAPSED_DAYS", (int)daysSinceLastWar);
                textObject.SetTextVariable("REQUIRED_DAYS", (int)MinimumTimeFromLastWar);
            }
            return(hasEnoughTimeElapsed);
        }
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;
            var alliancesEnabled = Settings.Instance !.EnableAlliances;

            if (!alliancesEnabled)
            {
                textObject = new TextObject(ALLIANCES_DISABLED);
            }
            return(alliancesEnabled);
        }
Ejemplo n.º 3
0
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;
            var atWar = FactionManager.IsAtWarAgainstFaction(kingdom, otherKingdom);

            if (atWar)
            {
                textObject = new TextObject(StringConstants.AT_WAR);
            }
            return(!atWar);
        }
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;
            var hasNonAggressionPact = DiplomaticAgreementManager.HasNonAggressionPact(kingdom, otherKingdom, out _);

            if (hasNonAggressionPact)
            {
                textObject = new TextObject(HAS_NON_AGGRESSION_PACT);
            }

            return(!hasNonAggressionPact);
        }
Ejemplo n.º 5
0
 public Datepicker(
     string actionId,
     TextObject?placeholder     = null,
     DateTime?initialDate       = null,
     ConfirmationDialog?confirm = null
     ) : base(actionId)
 {
     // Assign values.
     Placeholder = placeholder;
     InitialDate = initialDate;
     Confirm     = confirm;
 }
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;
            var scoreTooLow = AllianceScoringModel.Instance.GetScore(otherKingdom, kingdom).ResultNumber < AllianceScoringModel.Instance.ScoreThreshold;

            if (scoreTooLow)
            {
                var scoreTooLowText = new TextObject("{=VvTTrRpl}This faction is not interested in forming an alliance with you.");
                textObject = scoreTooLowText;
            }
            return(!scoreTooLow);
        }
 public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
 {
     textObject = null;
     if (bypassCosts)
     {
         return(true);
     }
     else
     {
         return(ApplyConditionInternal(kingdom, otherKingdom, ref textObject, forcePlayerCharacterCosts));
     }
 }
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;
            var hasEnoughTimeElapsed = CooldownManager.HasExceededMinimumWarDuration(kingdom, otherKingdom, out var elapsedDaysUntilNow);

            if (!hasEnoughTimeElapsed)
            {
                textObject = new TextObject(TOO_SOON);
                textObject.SetTextVariable("ELAPSED_DAYS", (float)Math.Floor(elapsedDaysUntilNow));
                textObject.SetTextVariable("REQUIRED_DAYS", Settings.Instance !.MinimumWarDurationInDays);
            }
            return(hasEnoughTimeElapsed);
        }
Ejemplo n.º 9
0
        public bool ApplyCondition(Kingdom kingdom,
                                   Kingdom otherKingdom,
                                   out TextObject?textObject,
                                   bool forcePlayerCharacterCosts = false,
                                   bool bypassCosts = false)
        {
            textObject = null;

            var alreadyInAlliance = FactionManager.IsAlliedWithFaction(kingdom, otherKingdom);

            if (alreadyInAlliance)
            {
                textObject = new TextObject(StringConstants.IN_ALLIANCE);
            }

            return(!alreadyInAlliance);
        }
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;
            var playerKingdom = Clan.PlayerClan.Kingdom;

            if (kingdom == playerKingdom || otherKingdom == playerKingdom)
            {
                var besiegedKingdom  = PlayerSiege.PlayerSiegeEvent?.BesiegedSettlement?.OwnerClan.Kingdom;
                var besiegingKingdom = PlayerSiege.PlayerSiegeEvent?.BesiegerCamp?.BesiegerParty.LeaderHero.MapFaction as Kingdom;

                if ((besiegedKingdom == playerKingdom || besiegingKingdom == playerKingdom) && (besiegedKingdom == otherKingdom || besiegingKingdom == otherKingdom))
                {
                    textObject = new TextObject(ACTIVE_PLAYER_SIEGE);
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 11
0
        public Image(
            string imageUrl,
            string altText,
            TextObject?title = null,
            string?blockId   = null
            ) : base(blockId)
        {
            // Validate parameters.
            ImageUrl = string.IsNullOrWhiteSpace(imageUrl)
                ? throw new ArgumentNullException(nameof(imageUrl))
                : imageUrl;
            AltText = string.IsNullOrWhiteSpace(altText)
                ? throw new ArgumentNullException(nameof(altText))
                : altText;

            // Assign values.
            Title = title;
        }
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;

            // not in story mode
            if (StoryMode.StoryMode.Current == null)
            {
                return(true);
            }

            var thirdPhase        = StoryMode.StoryMode.Current?.MainStoryLine?.ThirdPhase;
            var isValidQuestState = thirdPhase is null || !thirdPhase.OppositionKingdoms.Contains(otherKingdom);

            if (!isValidQuestState)
            {
                textObject = new TextObject(ACTIVE_QUEST);
            }
            return(isValidQuestState);
        }
        public bool ApplyCondition(Kingdom kingdom,
                                   Kingdom otherKingdom,
                                   out TextObject?textObject,
                                   bool forcePlayerCosts = false,
                                   bool bypassCosts      = false)
        {
            textObject = null;

            var authority = Clan.PlayerClan.Kingdom != kingdom ||
                            (kingdom?.Leader.IsHumanPlayerCharacter ?? false) ||
                            !forcePlayerCosts ||
                            Settings.Instance !.PlayerDiplomacyControl;

            if (!authority)
            {
                textObject = new TextObject("{=lQAaLeSy}You don't have the authority to perform this action.");
            }

            return(authority);
        }
Ejemplo n.º 14
0
        public bool ApplyCondition(Kingdom kingdom, Kingdom otherKingdom, out TextObject?textObject, bool forcePlayerCharacterCosts = false, bool bypassCosts = false)
        {
            textObject = null;
            var hasDeclareWarCooldown = CooldownManager.HasDeclareWarCooldown(kingdom, otherKingdom, out var elapsedTime);
            var hasLowWarExhaustion   = true;

            if (Settings.Instance !.EnableWarExhaustion)
            {
                hasLowWarExhaustion = WarExhaustionManager.Instance.HasLowWarExhaustion(kingdom, otherKingdom);
            }

            if (!hasLowWarExhaustion)
            {
                var lowWarExhaustionThreshold = (int)WarExhaustionManager.GetLowWarExhaustion();
                textObject = new TextObject(WAR_EXHAUSTION_TOO_HIGH);
                textObject.SetTextVariable("LOW_WAR_EXHAUSTION_THRESHOLD", lowWarExhaustionThreshold);
                textObject.SetTextVariable("CURRENT_WAR_EXHAUSTION", (int)Math.Ceiling(WarExhaustionManager.Instance.GetWarExhaustion(kingdom, otherKingdom)));
            }

            return(hasLowWarExhaustion);
        }
Ejemplo n.º 15
0
        protected override bool ApplyConditionInternal(Kingdom kingdom, Kingdom otherKingdom, ref TextObject?textObject, bool forcePlayerCharacterCosts = false)
        {
            var hasEnoughGold = DiplomacyCostCalculator.DetermineCostForFormingNonAggressionPact(kingdom, otherKingdom, forcePlayerCharacterCosts).GoldCost.CanPayCost();

            if (!hasEnoughGold)
            {
                textObject = FailedConditionText;
            }
            return(hasEnoughGold);
        }
        protected override bool ApplyConditionInternal(Kingdom kingdom, Kingdom otherKingdom, ref TextObject?textObject, bool forcePlayerCharacterCosts = false)
        {
            var hasEnoughInfluence = DiplomacyCostCalculator.DetermineCostForFormingAlliance(kingdom, otherKingdom, true).InfluenceCost.CanPayCost();

            if (!hasEnoughInfluence)
            {
                textObject = FailedConditionText;
            }

            return(hasEnoughInfluence);
        }
 public abstract void AddScreen(string internalName, int index, Func <ScreenBase?> screenFactory, TextObject?text);
 protected abstract bool ApplyConditionInternal(Kingdom kingdom, Kingdom otherKingdom, ref TextObject?textObject, bool forcePlayerCharacterCosts = false);