Beispiel #1
0
        /*
         * public override int GetNumberOfFiefsDesired(DecisionMaker decisionMaker)
         * {
         * int baseNumber = CalculateBaseNumberOfFiefs(decisionMaker.Hero.Clan, Settings.Instance!.DesiredFiefsBaseline.SelectedValue.EnumValue);
         * return baseNumber >= 0
         *    ? Math.Max(0, baseNumber + Settings.Instance.DesiredFiefsModifier + CalculateTraitsModifierForDesiredFiefs(decisionMaker, Settings.Instance.DesiredFiefsBaseline.SelectedValue.EnumValue))
         *    : baseNumber;
         * }
         *
         * public override int GetNumberOfFiefsDeemedFair(Clan clan)
         * {
         * int baseNumber = CalculateBaseNumberOfFiefs(clan, Settings.Instance!.FiefsDeemedFairBaseline.SelectedValue.EnumValue);
         * return baseNumber >= 0
         *    ? Math.Max(0, baseNumber + Settings.Instance.FiefsDeemedFairModifier)
         *    : baseNumber;
         * }
         */

        //Protected overrides
        protected override float GetGeneralSupportScore(Clan clan, KingdomDecision decision, DecisionOutcome possibleOutcome)
        {
            return(decision switch
            {
                MakePeaceKingdomDecision makePeaceDecision => GetGeneralSupportScore(clan, makePeaceDecision, possibleOutcome),
                DeclareWarDecision declareWarDecision => GetGeneralSupportScore(clan, declareWarDecision, possibleOutcome),
                SettlementClaimantDecision claimantDecision => GetGeneralSupportScore(clan, claimantDecision, possibleOutcome),
                SettlementClaimantPreliminaryDecision annexationDecision => GetGeneralSupportScore(clan, annexationDecision, possibleOutcome),
                _ => throw new ArgumentOutOfRangeException(nameof(decision), string.Format("Kingdom decision of type {0} is not supported.", decision.GetType().FullName)),
            });
 public static int GetRequiredDecisionCooldown(KingdomDecision decision)
 {
     return(decision switch
     {
         MakePeaceKingdomDecision _ => Settings.Instance !.MakePeaceDecisionCooldown,
         DeclareWarDecision _ => Settings.Instance !.DeclareWarDecisionCooldown,
         ExpelClanFromKingdomDecision _ => Settings.Instance !.ExpelClanDecisionCooldown,
         KingdomPolicyDecision _ => Settings.Instance !.KingdomPolicyDecisionCooldown,
         SettlementClaimantPreliminaryDecision _ => Settings.Instance !.AnnexationDecisionCooldown,
         _ => throw new ArgumentException(string.Format("{0} is not supported KingdomDecision type", decision.GetType().FullName), nameof(decision)),
     });
Beispiel #3
0
        public static bool Prefix(Clan clan, ref KingdomDecision __result, KingdomDecisionProposalBehavior __instance) //Bool prefixes compete with each other and skip others, as well as original, if return false
        {
            try
            {
                bool SubSystemEnabled   = SettingsHelper.SubSystemEnabled(SubSystemType.ElectionCooldowns, clan) || SettingsHelper.SubSystemEnabled(SubSystemType.DecisionSupportRebalance, clan);
                bool SystemDebugEnabled = SettingsHelper.SystemDebugEnabled(AOSystems.PoliticsRebalance, DebugType.General, clan);

                if (!SubSystemEnabled && !SystemDebugEnabled)
                {
                    return(true);
                }

                Kingdom kingdom = clan.Kingdom;
                __result = null;
                if (kingdom.UnresolvedDecisions.FirstOrDefault(x => x is SettlementClaimantPreliminaryDecision) == null && clan.Influence >= 300.0)
                {
                    bool possessionsFactorApplied = SettingsHelper.SubSystemEnabled(SubSystemType.AnnexationSupportRebalance, clan) &&
                                                    Settings.Instance.AnnexSupportCalculationMethod.SelectedValue.EnumValue.HasFlag(FiefOwnershipConsideration.PossessionsFactor) &&
                                                    Settings.Instance.FiefsDeemedFairBaseline.SelectedValue.EnumValue != NumberOfFiefsCalculationMethod.WithoutRestrictions;
                    Clan randomClan = kingdom.Clans.Where(x => x != clan &&
                                                          x.Fortifications.Count > 0 &&
                                                          (x.GetRelationWithClan(clan) < -25 || (possessionsFactorApplied && Campaign.Current.GetAOGameModels().DecisionSupportScoringModel.GetNumberOfFiefsDeemedFair(x) < x.Fortifications.Count)) &&
                                                          x.Fortifications.FirstOrDefault(f => !(SubSystemEnabled && AOCooldownManager.HasDecisionCooldown(new SettlementClaimantPreliminaryDecision(clan, f.Settlement)))) != null
                                                          ).ToArray().GetRandomElement();

                    Town randomFortification = SettingsHelper.SubSystemEnabled(SubSystemType.ElectionCooldowns, clan)
              ? clan.Fortifications.Where(f => !(AOCooldownManager.HasDecisionCooldown(new SettlementClaimantPreliminaryDecision(clan, f.Settlement)))).ToArray().GetRandomElement()
              : clan.Fortifications.ToArray().GetRandomElement();

                    //ConsiderAnnexDelegate deConsiderAnnex = AccessHelper.GetDelegate<ConsiderAnnexDelegate, KingdomDecisionProposalBehavior>(__instance, "ConsiderAnnex");
                    if (randomClan != null && deConsiderAnnex(__instance, clan, kingdom, randomClan, randomFortification))
                    {
                        __result = new SettlementClaimantPreliminaryDecision(clan, randomFortification.Settlement);
                    }

                    if (SystemDebugEnabled)
                    {
                        PoliticsDebugHelper.PrepareConsiderationDebugMessage(clan, randomFortification, __result, out TextObject debugLogMessage);
                        MessageHelper.SimpleMessage(debugLogMessage);
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                MethodInfo methodInfo = MethodBase.GetCurrentMethod() as MethodInfo;
                DebugHelper.HandleException(ex, methodInfo, "Harmony patch for KingdomDecisionProposalBehavior. GetRandomAnnexationDecision");
                return(true);
            }
        }
 private bool InternalEquals(KingdomDecision decision1, KingdomDecision decision2)
 {
     if (decision1.GetType() != decision2.GetType())
     {
         return(false);
     }
     return(decision1 switch
     {
         MakePeaceKingdomDecision peaceDecision1 => peaceDecision1.FactionToMakePeaceWith == ((MakePeaceKingdomDecision)decision2).FactionToMakePeaceWith,
         DeclareWarDecision warDecision1 => warDecision1.FactionToDeclareWarOn == ((DeclareWarDecision)decision2).FactionToDeclareWarOn,
         ExpelClanFromKingdomDecision expelDecision1 => expelDecision1.ClanToExpel == ((ExpelClanFromKingdomDecision)decision2).ClanToExpel,
         KingdomPolicyDecision policyDecision1 => policyDecision1.Policy == ((KingdomPolicyDecision)decision2).Policy,
         SettlementClaimantPreliminaryDecision annexationDecision1 => annexationDecision1.Settlement == ((SettlementClaimantPreliminaryDecision)decision2).Settlement,
         _ => throw new ArgumentException(string.Format("{0} is not supported KingdomDecision type", decision1.GetType().FullName), nameof(decision1)),
     });
 private double GetSupportScoreOfDecisionMaker(DecisionMaker decisionMaker, SettlementClaimantPreliminaryDecision annexationDecision, DecisionOutcome possibleOutcome)
 {
     throw new NotImplementedException();
 }
 private float GetGeneralSupportScore(Clan clan, SettlementClaimantPreliminaryDecision annexationDecision, DecisionOutcome possibleOutcome)
 {
     throw new NotImplementedException();
 }