public PersonList meichushengdehaiziliebiao() { PersonList haiziliebiao = new PersonList(); foreach (Person person in this.Scenario.Persons) { if (person.Alive && !person.Available && person.Father == this.ID) { haiziliebiao.Add(person); } } haiziliebiao.PropertyName = "YearBorn"; haiziliebiao.IsNumber = true; haiziliebiao.SmallToBig = true; haiziliebiao.ReSort(); return haiziliebiao; }
private void ReSortAllWeighingList(PersonList zhenzaiPersons, PersonList agriculturePersons, PersonList commercePersons, PersonList technologyPersons, PersonList dominationPersons, PersonList moralePersons, PersonList endurancePersons, PersonList recruitmentPersons, PersonList trainingPersons, MilitaryList weighingMilitaries) { PersonList pl = this.Persons; zhenzaiPersons.Clear(); if (this.kezhenzai()) { foreach (Person person in pl) { zhenzaiPersons.Add(person); } zhenzaiPersons.IsNumber = true; zhenzaiPersons.PropertyName = "zhenzaiWeighing"; zhenzaiPersons.ReSort(); } agriculturePersons.Clear(); if (this.Kind.HasAgriculture) { foreach (Person person in pl) { agriculturePersons.Add(person); } agriculturePersons.IsNumber = true; agriculturePersons.PropertyName = "AgricultureWeighing"; agriculturePersons.ReSort(); } commercePersons.Clear(); if (this.Kind.HasCommerce) { foreach (Person person in pl) { commercePersons.Add(person); } commercePersons.IsNumber = true; commercePersons.PropertyName = "CommerceWeighing"; commercePersons.ReSort(); } technologyPersons.Clear(); if (this.Kind.HasTechnology) { foreach (Person person in pl) { technologyPersons.Add(person); } technologyPersons.IsNumber = true; technologyPersons.PropertyName = "TechnologyWeighing"; technologyPersons.ReSort(); } dominationPersons.Clear(); if (this.Kind.HasDomination) { foreach (Person person in pl) { dominationPersons.Add(person); } dominationPersons.IsNumber = true; dominationPersons.PropertyName = "DominationWeighing"; dominationPersons.ReSort(); } moralePersons.Clear(); if (this.Kind.HasMorale) { foreach (Person person in pl) { moralePersons.Add(person); } moralePersons.IsNumber = true; moralePersons.PropertyName = "MoraleWeighing"; moralePersons.ReSort(); } endurancePersons.Clear(); if (this.Kind.HasEndurance) { foreach (Person person in pl) { endurancePersons.Add(person); } endurancePersons.IsNumber = true; endurancePersons.PropertyName = "EnduranceWeighing"; endurancePersons.ReSort(); } trainingPersons.Clear(); foreach (Person person in pl) { trainingPersons.Add(person); } trainingPersons.IsNumber = true; trainingPersons.PropertyName = "TrainingWeighing"; trainingPersons.ReSort(); recruitmentPersons.Clear(); foreach (Person person in this.Persons) { recruitmentPersons.Add(person); } recruitmentPersons.IsNumber = true; recruitmentPersons.PropertyName = "RecruitmentWeighing"; recruitmentPersons.ReSort(); weighingMilitaries.Clear(); foreach (Military military in this.Militaries) { weighingMilitaries.Add(military); } weighingMilitaries.IsNumber = true; weighingMilitaries.PropertyName = "Weighing"; weighingMilitaries.ReSort(); }
private void AIHouGong() { if (base.Scenario.IsPlayer(this.BelongedFaction)) return; if (this.HasHostileTroopsInView()) return; if (GlobalVariables.getChildrenRate <= 0) return; Person leader = this.BelongedFaction.Leader; int uncruelty = leader.Uncruelty; //build hougong int unAmbition = Enum.GetNames(typeof(PersonAmbition)).Length - (int)leader.Ambition; if (this.BelongedFaction.meinvkongjian() - this.BelongedFaction.feiziCount() <= 0 && (this.BuildingFacility < 0) && (this.PlanFacilityKind == null || this.PlanFacilityKind.rongna <= 0) && GameObject.Random((int)(GameObject.Square(unAmbition) * Parameters.AIBuildHougongUnambitionProbWeight + GameObject.Square(this.BelongedFaction.meinvkongjian()) * unAmbition * Parameters.AIBuildHougongSpaceBuiltProbWeight)) == 0) { if (((!this.FrontLine && !this.noFactionFrontline) || GameObject.Chance(Parameters.AILeaveFrontlineForHougongChance)) && (!this.HostileLine || GameObject.Chance(Parameters.AILeaveHostilelineForHougongChance)) && this.Kind.FacilityPositionUnit > 0 && this.Agriculture >= this.AgricultureCeiling * 9 / 10 && this.Commerce >= this.CommerceCeiling * 9 / 10 && this.Technology >= this.TechnologyCeiling * 9 / 10 && this.Endurance >= this.EnduranceCeiling * 9 / 10 && this.Domination >= this.DominationCeiling * 9 / 10 && this.Morale >= this.MoraleCeiling * 9 / 10) { int maxHgSize = (12 - uncruelty) + Math.Max(0, this.FacilityPositionCount / this.Kind.FacilityPositionUnit - 5) + Parameters.AIBuildHougongMaxSizeAdd; FacilityKind hougong = null; foreach (FacilityKind fk in base.Scenario.GameCommonData.AllFacilityKinds.FacilityKinds.Values) { if ((((!fk.PopulationRelated || this.Kind.HasPopulation) && ((this.Technology >= fk.TechnologyNeeded))) && ((!fk.UniqueInArchitecture || !this.ArchitectureHasFacilityKind(kind.ID)) && (!fk.UniqueInFaction || !this.FactionHasFacilityKind(kind.ID))))) { if (fk.rongna > 0 && fk.rongna < maxHgSize && GameObject.Chance(Parameters.AIBuildHougongSkipSizeChance)) { if (hougong == null || hougong.rongna < fk.rongna) { hougong = fk; } } } } if (hougong != null) { int facilityPositionLeft = this.FacilityPositionLeft; if (facilityPositionLeft < hougong.PositionOccupied && this.FacilityPositionCount >= hougong.PositionOccupied) { FacilityList fl = new FacilityList(); foreach (Facility f in this.Facilities) { if (!f.Kind.bukechaichu) { fl.Add(f); } } int totalRemovableSpace = 0; foreach (Facility f in fl) { totalRemovableSpace += f.PositionOccupied; } if (totalRemovableSpace >= hougong.PositionOccupied && this.BelongedSection.AIDetail.AllowFacilityRemoval) { fl.PropertyName = "AIValue"; fl.IsNumber = true; fl.SmallToBig = true; fl.ReSort(); while (this.FacilityPositionLeft < hougong.PositionOccupied && fl.Count > 0) { Facility f = fl[0] as Facility; if (this.FacilityEnabled || f.MaintenanceCost <= 0) { f.Influences.PurifyInfluence(this, Applier.Facility, f.ID); } this.Facilities.Remove(f); base.Scenario.Facilities.Remove(f); fl.Remove(f); } } /*foreach (Facility facility in this.Facilities.GetList()) { if ((((this.Technology > facility.TechnologyNeeded) && this.FacilityIsPossibleOverTechnology(facility.TechnologyNeeded)) && ((this.Fund > (facility.FundCost * 10)) && (this.BelongedFaction.TechniquePoint > (facility.PointCost * 10)))) && (GameObject.Random(facility.Days * facility.PositionOccupied) < 20 * hougong.PositionOccupied) && !facility.Kind.bukechaichu) { if (this.FacilityEnabled) { facility.Influences.PurifyInfluence(this); } this.Facilities.Remove(facility); base.Scenario.Facilities.Remove(facility); } }*/ facilityPositionLeft = this.FacilityPositionLeft; } if (facilityPositionLeft >= hougong.PositionOccupied) { if ((this.Fund >= hougong.FundCost) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) >= hougong.PointCost)) { this.PlanFacilityKind = null; this.BelongedFaction.DepositTechniquePointForFacility(hougong.PointCost); this.BeginToBuildAFacility(hougong); } else { this.PlanFacilityKind = hougong; if (GameObject.Chance(0x21) && ((this.BelongedFaction.TechniquePoint + this.BelongedFaction.TechniquePointForFacility) < this.PlanFacilityKind.PointCost)) { this.BelongedFaction.SaveTechniquePointForFacility(this.PlanFacilityKind.PointCost / this.PlanFacilityKind.Days); } } } } } } //nafei if (leader.WaitForFeiZi != null && leader.Status == PersonStatus.Normal) { if (this.Meinvkongjian - this.Feiziliebiao.Count <= 0 || !this.BelongedFaction.Leader.isLegalFeiZi(leader.WaitForFeiZi)) { leader.WaitForFeiZi.WaitForFeiZi = null; leader.WaitForFeiZi = null; } else if (this.fund >= 50000) { if (leader.LocationArchitecture == this && leader.Status == PersonStatus.Normal && this.nvxingwujiang().GameObjects.Contains(leader.WaitForFeiZi)) { leader.XuanZeMeiNv(leader.WaitForFeiZi); leader.WaitForFeiZi.WaitForFeiZi = null; leader.WaitForFeiZi = null; } else if (leader.WaitForFeiZi.BelongedFaction != this.BelongedFaction) { leader.WaitForFeiZi.WaitForFeiZi = null; leader.WaitForFeiZi = null; } } else { leader.WaitForFeiZi.WaitForFeiZi = null; leader.WaitForFeiZi = null; } } else { if (!leader.IsCaptive && this.Meinvkongjian - this.Feiziliebiao.Count > 0 && leader.Status == PersonStatus.Normal && ( GameObject.Random(uncruelty - Parameters.AINafeiUncreultyProbAdd) == 0 || GameObject.Chance((int)Math.Round(Parameters.AIHougongArchitectureCountProbMultiply * Math.Pow(this.BelongedFaction.ArchitectureCount, Parameters.AIHougongArchitectureCountProbPower)))) && this.Fund > 75000 ) { if (leader.LocationArchitecture == this) { PersonList candidate = new PersonList(); foreach (Person p in this.BelongedFaction.Persons) { Person spousePerson = p.Spouse == null ? null : p.Spouse; if (p.Merit > ((unAmbition - 1) * Parameters.AINafeiAbilityThresholdRate) && leader.isLegalFeiZi(p) && p.LocationArchitecture != null && !p.IsCaptive && !p.Hates(this.BelongedFaction.Leader) && (spousePerson == null || spousePerson.ID == leader.ID || !spousePerson.Alive || (leader.PersonalLoyalty < (int)PersonLoyalty.很高 && spousePerson.Merit < p.Merit * ((int)leader.PersonalLoyalty * Parameters.AINafeiStealSpouseThresholdRateMultiply + Parameters.AINafeiStealSpouseThresholdRateAdd))) && (!GlobalVariables.PersonNaturalDeath || (p.Age >= 16 && p.Age <= Parameters.AINafeiMaxAgeThresholdAdd + (int)leader.Ambition * Parameters.AINafeiMaxAgeThresholdMultiply))) { candidate.Add(p); } } candidate.PropertyName = "Merit"; candidate.IsNumber = true; candidate.SmallToBig = false; candidate.ReSort(); Person toTake = null; foreach (Person p in candidate) { if (p.Status == PersonStatus.Normal) { if ((!p.RecruitableBy(this.BelongedFaction, 0) && GameObject.Random((int)unAmbition) == 0) || GameObject.Chance((int)(Parameters.AINafeiSkipChanceAdd + (int)leader.Ambition * Parameters.AINafeiSkipChanceMultiply))) { toTake = p; break; } } } if (toTake != null) { if (leader.LocationArchitecture.Meinvkongjian > this.Meinvkongjian) { if (toTake.LocationArchitecture == leader.LocationArchitecture && toTake.LocationArchitecture.Fund >= 50000) { leader.XuanZeMeiNv(toTake); toTake.WaitForFeiZi = null; leader.WaitForFeiZi = null; } else { toTake.MoveToArchitecture(leader.LocationArchitecture); toTake.WaitForFeiZi = leader; leader.WaitForFeiZi = toTake; } } else { if (leader.LocationArchitecture != this) { leader.MoveToArchitecture(this); leader.WaitForFeiZi = toTake; } if (toTake.LocationArchitecture == this) { if (leader.LocationArchitecture == this && this.Fund >= 50000) { leader.XuanZeMeiNv(toTake); toTake.WaitForFeiZi = null; leader.WaitForFeiZi = null; } else { toTake.WaitForFeiZi = leader; } } else { toTake.MoveToArchitecture(this); toTake.WaitForFeiZi = leader; leader.WaitForFeiZi = toTake; } } } } else if (leader.LocationArchitecture != null && ((!leader.LocationArchitecture.HostileLine || GameObject.Chance(Parameters.AILeaveHostilelineForHougongChance) || (leader.LocationArchitecture == this && GameObject.Chance(Parameters.AIHostilelineHougongChance))) && (!leader.LocationArchitecture.FrontLine || GameObject.Chance(Parameters.AILeaveFrontlineForHougongChance) || (leader.LocationArchitecture == this && GameObject.Chance(Parameters.AIFrontlineHougongChance)))) ) { if (leader.LocationArchitecture.meifaxianhuaiyundefeiziliebiao().Count <= 0) { leader.MoveToArchitecture(this); } } } } //chongxing if (!leader.IsCaptive && !leader.huaiyun && meifaxianhuaiyundefeiziliebiao().Count > 0 && leader.LocationArchitecture != null && this.BelongedFaction.Leader.WaitForFeiZi == null && leader.Status == PersonStatus.Normal && ( GameObject.Chance((int)((int)leader.Ambition * Parameters.AIChongxingChanceMultiply + Parameters.AIChongxingChanceAdd)) || GameObject.Chance((int)Math.Round(Parameters.AIHougongArchitectureCountProbMultiply * Math.Pow(this.BelongedFaction.ArchitectureCount, Parameters.AIHougongArchitectureCountProbPower))) ) && (((!leader.LocationArchitecture.HostileLine || GameObject.Chance(Parameters.AILeaveHostilelineForHougongChance) || (leader.LocationArchitecture == this && GameObject.Chance(Parameters.AIHostilelineHougongChance))) && (!leader.LocationArchitecture.FrontLine || GameObject.Chance(Parameters.AILeaveFrontlineForHougongChance) || (leader.LocationArchitecture == this && GameObject.Chance(Parameters.AIFrontlineHougongChance)))) ) ) { if (leader.LocationArchitecture != this) { bool stay = false; PersonList candidate = leader.LocationArchitecture.meifaxianhuaiyundefeiziliebiao(); candidate.PropertyName = "Merit"; candidate.IsNumber = true; candidate.SmallToBig = false; candidate.ReSort(); foreach (Person p in candidate) { if ((GameObject.Random(leader.NumberOfChildren * (GlobalVariables.PersonNaturalDeath ? 1 : 0) + p.NumberOfChildren * 2) == 0 || GameObject.Chance(p.pregnantChance)) && leader.isLegalFeiZi(p)) { stay = true; leader.GoForHouGong(p); break; } } if (!stay) { leader.MoveToArchitecture(this); } } else { PersonList candidate = meifaxianhuaiyundefeiziliebiao(); candidate.PropertyName = "Merit"; candidate.IsNumber = true; candidate.SmallToBig = false; candidate.ReSort(); foreach (Person p in candidate) { if (GameObject.Random(leader.NumberOfChildren * (GlobalVariables.PersonNaturalDeath ? 1 : 0) + p.NumberOfChildren * 2) == 0 && leader.isLegalFeiZi(p)) { leader.GoForHouGong(p); break; } } } } }
private PersonList GetFirstHalfPersonList(string propertyName) { PersonList list = new PersonList(); if (this.Persons.Count > 0) { foreach (Person p in this.Persons) { list.Add(p); } if (list.Count > 1) { list.PropertyName = propertyName; list.IsNumber = true; list.ReSort(); } list.GameObjects.RemoveRange(list.Count / 2, list.Count - list.Count / 2); return (list); } return new PersonList(); }
private void CallInstigate() { if (this.WillArchitecture.Endurance >= (this.WillArchitecture.EnduranceCeiling * 0.2)) { Person current; PersonList list = new PersonList(); foreach (LinkNode node in this.WillArchitecture.AIAllLinkNodes.Values) { if ((((node.A.BelongedFaction == this.BelongedFaction) && (node.A.Fund >= node.A.InstigateArchitectureFund)) && node.A.BelongedSection.AIDetail.AllowOffensiveTactics) && (node.A.RecentlyAttacked <= 0)) { //using (IEnumerator enumerator2 = node.A.Persons.GetEnumerator()) IEnumerator enumerator2 = node.A.Persons.GetEnumerator(); { while (enumerator2.MoveNext()) { current = (Person) enumerator2.Current; list.Add(current); } } if (list.Count >= 10) { break; } } } if (list.Count > 0) { if (list.Count > 1) { list.PropertyName = "InstigateAbility"; list.IsNumber = true; list.ReSort(); } current = list[GameObject.Random(list.Count / 2)] as Person; if (GameObject.Chance(GameObject.Random(current.InstigateAbility - 150)) && (GameObject.Random(current.NonFightingNumber) > GameObject.Random(current.FightingNumber))) { current.GoForInstigate(this.WillArchitecture.Position); } } } }
private void AIPersonTransfer() { int num2; if ((this.MilitaryCount == 0) && ((this.IsImportant || (this.AreaCount > 1)) || (this.Population > this.RecruitmentPopulationBoundary))) { this.AIRecruitment(false); } if ((((this.BelongedFaction.ArchitectureCount > 1) && (this.PersonCount > this.MilitaryCount)) && (this.RecentlyAttacked > 0)) && ((this.Endurance == 0) || ((this.Endurance < 30) && GameObject.Chance(0x21)))) { int num = this.PersonCount - this.MilitaryCount; GameObjectList list = new GameObjectList(); list = this.Persons.GetList(); if (list.Count > 1) { list.IsNumber = true; list.SmallToBig = true; list.PropertyName = "FightingForce"; list.ReSort(); } Architecture capital = this.BelongedFaction.Capital; if (capital == this) { ArchitectureList otherArchitectureList = this.GetOtherArchitectureList(); if (otherArchitectureList.Count > 1) { otherArchitectureList.IsNumber = true; otherArchitectureList.PropertyName = "ArmyScaleWeighing"; otherArchitectureList.ReSort(); } capital = otherArchitectureList[0] as Architecture; } num2 = 0; while (num2 < num) { (list[num2] as Person).MoveToArchitecture(capital); this.RemovePerson(list[num2] as Person); if (GameObject.Chance(20)) { break; } num2++; } } else if (((this.PersonCount + this.MovingPersons.Count) < this.MilitaryCount) || (this.PlanArchitecture != null)) { if (this.RecentlyAttacked > 0) { int num3 = (this.MilitaryCount - this.PersonCount) - this.MovingPersons.Count; PersonList list3 = new PersonList(); foreach (Architecture architecture2 in GameObject.Chance(20) ? this.BelongedFaction.Architectures : this.BelongedSection.Architectures) { if ((architecture2 != this) && (((architecture2.BelongedSection.AIDetail != null) && architecture2.BelongedSection.AIDetail.AutoRun) && (((architecture2.RecentlyAttacked <= 0) && ((architecture2.PersonCount + architecture2.MovingPersons.Count) >= architecture2.MilitaryCount)) || (((architecture2.Fund < (100 * this.AreaCount)) && (architecture2.Domination >= (architecture2.DominationCeiling * 0.8))) && (architecture2.Endurance >= (architecture2.EnduranceCeiling * 0.2f)))))) { foreach (Person person in architecture2.Persons) { if ((!architecture2.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !architecture2.HasExperiencedLeaderMilitary(person))) && (person.Command >= 40)) { list3.Add(person); } } } } if (list3.Count > 0) { if (list3.Count > 1) { list3.IsNumber = true; list3.PropertyName = "FightingForce"; list3.ReSort(); } for (num2 = 0; (num2 < num3) && (num2 < list3.Count); num2++) { Architecture locationArchitecture = (list3[num2] as Person).LocationArchitecture; (list3[num2] as Person).MoveToArchitecture(this); locationArchitecture.RemovePerson(list3[num2] as Person); } } } } else if (this.HasPerson() && GameObject.Chance(10)) { PersonList list4 = new PersonList(); if (this.Kind.HasPopulation && (this.Population < (0x3e8 * this.AreaCount))) { if (this.IsCapital && (this.Fund >= this.ChangeCapitalCost)) { Architecture newCapital = this.BelongedFaction.SelectNewCapital(); if (newCapital != this) { this.DecreaseFund(this.ChangeCapitalCost); this.BelongedFaction.ChangeCapital(newCapital); } } foreach (Person person in this.Persons) { if (!this.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !this.HasExperiencedLeaderMilitary(person))) { list4.Add(person); } } } else { foreach (Person person in this.Persons) { if ((person.WorkKind == ArchitectureWorkKind.无) && (!this.HasFollowedLeaderMilitary(person) && (GameObject.Chance(10) || !this.HasExperiencedLeaderMilitary(person)))) { list4.Add(person); } } } if (list4.Count > 0) { ArchitectureList list5 = new ArchitectureList(); foreach (Architecture architecture2 in (base.Scenario.Date.Day == 1) ? this.BelongedFaction.Architectures : this.BelongedSection.Architectures) { if ((architecture2 != this) && ((((architecture2.IsRegionCore || architecture2.IsStateAdmin) || (architecture2.Kind.HasPopulation && (architecture2.Population > this.Population))) || GameObject.Chance(5)) || ((architecture2.Fund >= (100 * this.AreaCount)) && ((((architecture2.PersonCount + architecture2.MovingPersons.Count) < architecture2.MilitaryCount) || (architecture2.Domination < (architecture2.DominationCeiling * 0.8))) || (architecture2.Endurance < (architecture2.EnduranceCeiling * 0.2f)))))) { list5.Add(architecture2); } } if (list5.Count > 0) { if (list5.Count > 1) { list5.PropertyName = "ArmyScaleWeighing"; list5.IsNumber = true; list5.ReSort(); } for (num2 = 0; (num2 < list4.Count) && (num2 < list5.Count); num2++) { (list4[num2] as Person).MoveToArchitecture(list5[num2] as Architecture); this.RemovePerson(list4[num2] as Person); } } } } }
public PersonList ChildrenCanBeSelectedAsPrince() { PersonList haiziliebiao = new PersonList(); foreach (Person person in this.Scenario.Persons) { if (person.Alive && person.Available && person.Father == this.ID && person.BelongedCaptive == null && person.sex == false) { haiziliebiao.Add(person); } } haiziliebiao.PropertyName = "YearBorn"; haiziliebiao.IsNumber = true; haiziliebiao.SmallToBig = true; haiziliebiao.ReSort(); return haiziliebiao; }
public Faction ChangeLeaderAfterLeaderDeath() { Person leader = this.Leader; Architecture locationArchitecture = this.Leader.LocationArchitecture; this.Leader.Status = GameObjects.PersonDetail.PersonStatus.None; this.Leader.Available = false; //base.Scenario.Persons.Remove(this.Leader); base.Scenario.AvailablePersons.Remove(this.Leader); Person person2 = null; PersonList list = new PersonList(); if (person2 == null) { foreach (Person person3 in this.Persons) { if ((person3.Father >= 0) && (person3.Sex == this.Leader.Sex) && ((this.Leader.Father == person3.Father) || (person3.Father == this.Leader.ID))) { list.Add(person3); } } if (list.Count > 0) { if (list.Count > 1) { list.PropertyName = "YearBorn"; list.IsNumber = true; list.SmallToBig = true; list.ReSort(); } person2 = list[0] as Person; } } if (person2 == null) { list.Clear(); foreach (Person person3 in this.Persons) { if ((person3.Strain >= 0) && (person3.Sex == this.Leader.Sex) && (this.Leader.Strain == person3.Strain)) { list.Add(person3); } } if (list.Count > 0) { if (list.Count > 1) { list.PropertyName = "YearBorn"; list.IsNumber = true; list.SmallToBig = true; list.ReSort(); } person2 = list[0] as Person; } } if (person2 == null) { list.Clear(); foreach (Person person3 in this.Persons) { if ((person3.Brother >= 0) && (person3.Sex == this.Leader.Sex) && (this.Leader.Brother == person3.Brother)) { list.Add(person3); } } if (list.Count > 0) { if (list.Count > 1) { list.PropertyName = "Glamour"; list.IsNumber = true; list.ReSort(); } person2 = list[0] as Person; } } if (person2 == null) { foreach (Person person3 in this.Persons) { if ((person3.Mother >= 0) && (person3.Sex == this.Leader.Sex) && ((this.Leader.Mother == person3.Mother) || (person3.Mother == this.Leader.ID))) { list.Add(person3); } } if (list.Count > 0) { if (list.Count > 1) { list.PropertyName = "YearBorn"; list.IsNumber = true; list.SmallToBig = true; list.ReSort(); } person2 = list[0] as Person; } } if (GlobalVariables.PermitFactionMerge) { Faction maxFriendlyDiplomaticRelation = this.MaxFriendlyDiplomaticRelation; if (maxFriendlyDiplomaticRelation != null) { base.Scenario.YearTable.addChangeFactionEntry(base.Scenario.Date, this, maxFriendlyDiplomaticRelation); this.ChangeFaction(maxFriendlyDiplomaticRelation); foreach (Treasure treasure in leader.Treasures.GetList()) { treasure.HidePlace = locationArchitecture; leader.LoseTreasure(treasure); treasure.Available = false; } return maxFriendlyDiplomaticRelation; } } if (person2 == null) { list.Clear(); foreach (Person person3 in this.Persons) { if ((this.Leader.Ideal == person3.Ideal) && (person3.Sex == this.Leader.Sex) && ((person3.Brother < 0) || (person3.Brother == person3.ID))) { list.Add(person3); } } if (list.Count > 0) { if (list.Count > 1) { list.PropertyName = "Merit"; list.IsNumber = true; list.ReSort(); } person2 = list[0] as Person; } } if (person2 == null) { list.Clear(); foreach (Person person3 in this.Persons) { if ((person3.Sex == this.Leader.Sex) && (person3.Brother < 0) || (person3.Brother == person3.ID)) { list.Add(person3); } } if (list.Count > 0) { if (list.Count > 1) { list.PropertyName = "Merit"; list.IsNumber = true; list.ReSort(); } person2 = list[0] as Person; } } if (person2 == null) { list.Clear(); foreach (Person person3 in this.Persons) { if ((person3.Brother < 0) || (person3.Brother == person3.ID)) { list.Add(person3); } } if (list.Count > 0) { if (list.Count > 1) { list.PropertyName = "Merit"; list.IsNumber = true; list.ReSort(); } person2 = list[0] as Person; } } if (person2 != null) { this.Leader = person2; this.Leader.Loyalty = 100; if (!((this.Leader.LocationTroop == null) || this.Leader.IsCaptive)) { this.Leader.LocationTroop.RefreshWithPersonList(this.Leader.LocationTroop.Persons.GetList()); } foreach (Treasure treasure in leader.Treasures.GetList()) { leader.LoseTreasure(treasure); this.Leader.ReceiveTreasure(treasure); } ExtensionInterface.call("ChangeKing", new Object[] { this.Scenario, this }); base.Scenario.YearTable.addChangeKingEntry(base.Scenario.Date, this.Leader); return this; } foreach (Treasure treasure in leader.Treasures.GetList()) { treasure.HidePlace = locationArchitecture; leader.LoseTreasure(treasure); treasure.Available = false; } return null; }