示例#1
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);
                }
            }
        }
示例#2
0
        private void ConsiderFormingNonAggressionPacts(Kingdom kingdom)
        {
            List <Kingdom> potentialPartners =
                Kingdom.All.Where(otherKingdom => otherKingdom != kingdom).Where(otherKingdom => NAPactConditions.Instance.CanExecuteAction(kingdom, otherKingdom)).ToList();

            foreach (Kingdom potentialPartner in potentialPartners)
            {
                if (MBRandom.RandomFloat < 0.05f && AllianceScoringModel.ShouldFormAlliance(kingdom, potentialAlly))
                {
                    DeclareAllianceAction.Apply(kingdom, potentialAlly);
                }
            }
        }
示例#3
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);
                }
            }
        }
示例#4
0
        internal static float DetermineInfluenceCostForFormingAlliance(Kingdom kingdom, Kingdom otherKingdom, bool isPlayerRequested = false)
        {
            const float baseInfluenceCost = 100f;

            if (isPlayerRequested)
            {
                return(MBMath.ClampFloat((float)Math.Pow(AllianceScoringModel.FormAllianceScoreThreshold / Math.Max(AllianceScoringModel.GetFormAllianceScore(kingdom, otherKingdom), 1f), 4), 1f, 256f) * baseInfluenceCost);
            }
            else
            {
                return(baseInfluenceCost);
            }
        }