示例#1
0
        private static string FormAlliance(List <string> strings)
        {
            if (!CampaignCheats.CheckCheatUsage(ref CampaignCheats.ErrorType))
            {
                return(CampaignCheats.ErrorType);
            }

            if (!CampaignCheats.CheckParameters(strings, 2) || CampaignCheats.CheckHelp(strings))
            {
                return("Format uses 2 kingdom ID parameters without spaces: diplomacy.form_alliance [Kingdom1] [Kingdom2]");
            }

            var b1 = strings[0].ToLower();
            var b2 = strings[1].ToLower();

            if (b1 == b2)
            {
                return("Cannot ally a kingdom to itself!");
            }

            Kingdom?kingdom1 = null;
            Kingdom?kingdom2 = null;

            foreach (var k in Kingdom.All)
            {
                var id = k.Name.ToString().ToLower().Replace(" ", "");

                if (id == b1)
                {
                    kingdom1 = k;
                }
                else if (id == b2)
                {
                    kingdom2 = k;
                }
            }

            if (kingdom1 is null && kingdom2 is null)
            {
                return("Could not find either required kingdom!");
            }

            if (kingdom1 is null)
            {
                return("1st kingdom ID not found: " + b1);
            }

            if (kingdom2 is null)
            {
                return("2nd kingdom ID not found: " + b2);
            }

            DeclareAllianceAction.Apply(kingdom1, kingdom2, bypassCosts: true);
            return($"Alliance formed between {kingdom1.Name} and  {kingdom2.Name}!");
        }
示例#2
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);
                }
            }
        }
示例#3
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);
                }
            }
        }
示例#4
0
        private static void ConsiderFormingAlliances(Kingdom kingdom)
        {
            var potentialAllies = Kingdom.All
                                  .Where(k => k != kingdom && FormAllianceConditions.Instance.CanApply(kingdom, k))
                                  .ToList();

            foreach (var potentialAlly in potentialAllies)
            {
                if (MBRandom.RandomFloat < 0.05f && AllianceScoringModel.Instance.ShouldFormBidirectional(kingdom, potentialAlly))
                {
                    DeclareAllianceAction.Apply(kingdom, potentialAlly);
                }
            }
        }
        public static string FormAlliance(List <string> strings)
        {
            if (!CampaignCheats.CheckCheatUsage(ref CampaignCheats.ErrorType))
            {
                return(CampaignCheats.ErrorType);
            }
            if (!CampaignCheats.CheckParameters(strings, 2) || CampaignCheats.CheckHelp(strings))
            {
                return("Format is faction names without space \"campaign.form_alliance [Faction1] [Faction2]\".");
            }
            string  b        = strings[0].ToLower();
            string  b2       = strings[1].ToLower();
            Kingdom faction  = null;
            Kingdom faction2 = null;

            foreach (Kingdom faction3 in Campaign.Current.Kingdoms)
            {
                string a = faction3.Name.ToString().ToLower().Replace(" ", "");
                if (a == b)
                {
                    faction = faction3;
                }
                else if (a == b2)
                {
                    faction2 = faction3;
                }
            }
            if (faction != null && faction2 != null)
            {
                DeclareAllianceAction.Apply(faction as Kingdom, faction2 as Kingdom, bypassCosts: true);
                return(string.Concat(new object[]
                {
                    "Alliance declared between ",
                    faction.Name,
                    " and ",
                    faction2.Name
                }));
            }
            if (faction == null)
            {
                return("Faction is not found: " + faction);
            }
            return("Faction is not found: " + faction2);
        }
示例#6
0
 protected void FormAlliance()
 {
     DeclareAllianceAction.Apply(this.Faction1 as Kingdom, this.Faction2 as Kingdom, true);
 }