Beispiel #1
0
            public override float GetScoreOfKingdomToGetClan(Kingdom kingdom, Clan clan)
            {
                var numClanHeroes           = clan.CommanderHeroes.Count;
                var existingHeroesInKingdom = GetNumberOfHeroesInKingdom(kingdom);

                if ((numClanHeroes == 0) ||
                    (existingHeroesInKingdom == 0))
                {
                    return(-1E+08f);
                }

                // Start with a basis of 0.
                var valueProposition = 0.0f;

                // Add value for the settlements the clan will bring to the kingdom, and the adjusted clan strength.
                // Adjusted clan strength is the clan strength ~ how badly the kingdom needs allies.
                var clanStrength        = GetClanStrength(clan, numClanHeroes);
                var powerRatioToEnemies = FactionHelper.GetPowerRatioToEnemies(kingdom);
                var howBadlyDoesThisKingdomNeedSupport = 1f / Clamp(powerRatioToEnemies > 1 ? (float)Math.Sqrt(powerRatioToEnemies) : powerRatioToEnemies, 0.1f, 2.5f);
                var adjustedClanStrength = clanStrength * howBadlyDoesThisKingdomNeedSupport;

                valueProposition += clan.CalculateSettlementValue(kingdom) * 0.1f + adjustedClanStrength;

                // Increase the value for happier relations.
                var relationMult = Clamp(1.0f + 0.0199999995529652f * FactionManager.GetRelationBetweenClans(kingdom.RulingClan, clan), 0.33f, 2f);

                valueProposition *= relationMult;

                // Increase the value for the same culture.
                var sameCultureMult = (float)(1.0 + (kingdom.Culture == clan.Culture ? 1.0 : 0.0));

                valueProposition *= sameCultureMult;

                // Increase the value if the lord is known to be honorable.
                var reliabilityConstant = HeroHelper.CalculateReliabilityConstant(clan.Leader);

                valueProposition *= reliabilityConstant;

                return(valueProposition);
            }