public static float GetCorruption(this Clan clan) { float corruption = 0f; int numFiefsTooMany = clan.GetPermanentFiefs().Count() - clan.Tier; if (numFiefsTooMany > 0) { int factor = numFiefsTooMany > 5 ? 2 : 1; corruption = numFiefsTooMany * factor; } return(corruption); }
private FiefBarterable GetBestFiefBarter(Clan ownerClan, out Clan otherClan) { Settlement settlementToTrade = ownerClan.GetPermanentFiefs().OrderBy(settlement => settlement.Prosperity).FirstOrDefault()?.Settlement; Clan targetClan = (ownerClan.MapFaction as Kingdom).Clans.Where(clan => clan != ownerClan && !clan.HasMaximumFiefs() && !clan.IsUnderMercenaryService && clan != Clan.PlayerClan)?.OrderByDescending(clan => GetGoldValueForFief(clan, settlementToTrade))?.FirstOrDefault(); if (settlementToTrade != null && targetClan != null) { FiefBarterable fiefBarterable = new FiefBarterable(settlementToTrade, ownerClan.Leader, targetClan.Leader); otherClan = targetClan; return(fiefBarterable); } else { otherClan = default; return(default);
private FiefBarterable? GetBestFiefBarter(Clan ownerClan, out Clan? otherClan) { otherClan = default; var settlementToTrade = ownerClan.GetPermanentFiefs() .OrderBy(settlement => settlement.Prosperity) .FirstOrDefault()?.Settlement; if (settlementToTrade is null) return default; var targetClan = ((Kingdom)ownerClan.MapFaction).Clans .Where(c => c != ownerClan && !c.HasMaximumFiefs() && !c.IsUnderMercenaryService && c != Clan.PlayerClan)? .OrderByDescending(c => GetGoldValueForFief(c, settlementToTrade)) .FirstOrDefault(); if (targetClan is null) return default; var fiefBarterable = new FiefBarterable(settlementToTrade, ownerClan.Leader, targetClan.Leader); otherClan = targetClan; return fiefBarterable; }
public static bool HasMaximumFiefs(this Clan clan) { int numFiefsTooMany = clan.GetPermanentFiefs().Count() - clan.Tier; return(numFiefsTooMany >= 0); }