//CalculateSituationalFactor private (float value, int multiplier) CalculateSituationalFactor(Kingdom decidingKingdom, IFaction factionToChangeStateWith) { bool atWar = decidingKingdom.IsAtWarWith(factionToChangeStateWith); IEnumerable <Kingdom> warringKingdoms = decidingKingdom.GetAdversaries(); float currentEffectiveStrength = decidingKingdom.TotalStrength / Math.Max(1, warringKingdoms.Count()); float currentPowerScore = currentEffectiveStrength - warringKingdoms.Sum(k => k.GetEffectiveStrength()) - Clan.All.Where(c => c.Kingdom is null && c.IsAtWarWith(decidingKingdom)).Sum(c => c.TotalStrength / 10); float newEffectiveStrength = factionToChangeStateWith.IsKingdomFaction ? decidingKingdom.TotalStrength / Math.Max(1, warringKingdoms.Count() + (atWar ? -1 : 1)) : currentEffectiveStrength; float newPowerScore = factionToChangeStateWith.IsKingdomFaction ? newEffectiveStrength - decidingKingdom.GetAdversaries((Kingdom)factionToChangeStateWith).Sum(k => k.TotalStrength / Math.Max(1, k == factionToChangeStateWith ? k.GetNumberOfWars(decidingKingdom) : k.GetNumberOfWars())) - Clan.All.Where(c => c.Kingdom is null && c.IsAtWarWith(decidingKingdom)).Sum(c => c.TotalStrength / 10) : currentPowerScore + (atWar ? factionToChangeStateWith.TotalStrength / 10 : -factionToChangeStateWith.TotalStrength / 10); int multiplier = newPowerScore < 0 ? 2 + (int)Math.Round(-newPowerScore / newEffectiveStrength, MidpointRounding.AwayFromZero) : 1; float value = multiplier * (newPowerScore - currentPowerScore) + (atWar ? CalculateWarSuccessScore(decidingKingdom, factionToChangeStateWith) : newPowerScore); return(value * 0.001f, multiplier); }