コード例 #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);
                }
            }
        }