public HfDestroyedSite(List <Property> properties, World world) : base(properties, world) { foreach (Property property in properties) { switch (property.Name) { case "attacker_hfid": Attacker = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break; case "defender_civ_id": DefenderCiv = world.GetEntity(Convert.ToInt32(property.Value)); break; case "site_civ_id": SiteCiv = world.GetEntity(Convert.ToInt32(property.Value)); break; case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break; } } Attacker.AddEvent(this); DefenderCiv.AddEvent(this); SiteCiv.AddEvent(this); Site.AddEvent(this); OwnerPeriod lastSiteOwnerPeriod = Site.OwnerHistory.LastOrDefault(); if (lastSiteOwnerPeriod != null) { lastSiteOwnerPeriod.EndYear = Year; lastSiteOwnerPeriod.EndCause = "destroyed"; lastSiteOwnerPeriod.Ender = Attacker; } if (DefenderCiv != null) { OwnerPeriod lastDefenderCivOwnerPeriod = DefenderCiv.SiteHistory.LastOrDefault(s => s.Site == Site); if (lastDefenderCivOwnerPeriod != null) { lastDefenderCivOwnerPeriod.EndYear = Year; lastDefenderCivOwnerPeriod.EndCause = "destroyed"; lastDefenderCivOwnerPeriod.Ender = Attacker; } } OwnerPeriod lastSiteCiveOwnerPeriod = SiteCiv.SiteHistory.LastOrDefault(s => s.Site == Site); if (lastSiteCiveOwnerPeriod != null) { lastSiteCiveOwnerPeriod.EndYear = Year; lastSiteCiveOwnerPeriod.EndCause = "destroyed"; lastSiteCiveOwnerPeriod.Ender = Attacker; } }
//TODO: Check and possibly move logic public void AddOwnedSite(OwnerPeriod ownerPeriod) { if (ownerPeriod.StartCause == "UNKNOWN" && SiteHistory.All(s => s.Site != ownerPeriod.Site)) { SiteHistory.Insert(0, ownerPeriod); } else { SiteHistory.Add(ownerPeriod); } if (ownerPeriod.Owner != this) { Groups.Add((Entity)ownerPeriod.Owner); } if (!IsCiv && Parent != null) { Parent.AddOwnedSite(ownerPeriod); Race = Parent.Race; } }