public Duel(List <Property> properties, World world) : base(properties, world) { foreach (Property property in properties) { switch (property.Name) { case "ordinal": Ordinal = String.Intern(property.Value); break; case "coords": Coordinates = Formatting.ConvertToLocation(property.Value); break; case "parent_eventcol": ParentCollection = world.GetEventCollection(Convert.ToInt32(property.Value)); break; case "subregion_id": Region = world.GetRegion(Convert.ToInt32(property.Value)); break; case "feature_layer_id": UndergroundRegion = world.GetUndergroundRegion(Convert.ToInt32(property.Value)); break; case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break; case "attacking_hfid": Attacker = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break; case "defending_hfid": Defender = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break; } } //foreach (WorldEvent collectionEvent in Collection) this.AddEvent(collectionEvent); if (ParentCollection != null && ParentCollection.GetType() == typeof(Battle)) { foreach (HfDied death in Collection.OfType <HfDied>()) { Battle battle = ParentCollection as Battle; War parentWar = battle.ParentCollection as War; if (battle.NotableAttackers.Contains(death.HistoricalFigure)) { battle.AttackerDeathCount++; battle.Attackers.Single(squad => squad.Race == death.HistoricalFigure.Race).Deaths++; if (parentWar != null) { parentWar.AttackerDeathCount++; } } else if (battle.NotableDefenders.Contains(death.HistoricalFigure)) { battle.DefenderDeathCount++; battle.Defenders.Single(squad => squad.Race == death.HistoricalFigure.Race).Deaths++; if (parentWar != null) { parentWar.DefenderDeathCount++; } } if (parentWar != null) { (ParentCollection.ParentCollection as War).DeathCount++; } } } Attacker.AddEventCollection(this); Defender.AddEventCollection(this); Region.AddEventCollection(this); UndergroundRegion.AddEventCollection(this); Site.AddEventCollection(this); }
public SiteConquered(List <Property> properties, World world) : base(properties, world) { Initialize(); foreach (Property property in properties) { switch (property.Name) { case "ordinal": Ordinal = Convert.ToInt32(property.Value); break; case "war_eventcol": ParentCollection = world.GetEventCollection(Convert.ToInt32(property.Value)); break; case "site_id": Site = world.GetSite(Convert.ToInt32(property.Value)); break; case "attacking_enid": Attacker = world.GetEntity(Convert.ToInt32(property.Value)); break; case "defending_enid": Defender = world.GetEntity(Convert.ToInt32(property.Value)); break; } } if (Collection.OfType <PlunderedSite>().Any()) { ConquerType = SiteConqueredType.Pillaging; } else if (Collection.OfType <DestroyedSite>().Any()) { ConquerType = SiteConqueredType.Destruction; } else if (Collection.OfType <NewSiteLeader>().Any() || Collection.OfType <SiteTakenOver>().Any()) { ConquerType = SiteConqueredType.Conquest; } else if (Collection.OfType <SiteTributeForced>().Any()) { ConquerType = SiteConqueredType.TributeEnforcement; } else { ConquerType = SiteConqueredType.Invasion; } if (ConquerType == SiteConqueredType.Pillaging || ConquerType == SiteConqueredType.Invasion || ConquerType == SiteConqueredType.TributeEnforcement) { Notable = false; } Site.Warfare.Add(this); if (ParentCollection is War) { War war = ParentCollection as War; war.DeathCount += Collection.OfType <HfDied>().Count(); if (Attacker == war.Attacker) { war.AttackerVictories.Add(this); } else { war.DefenderVictories.Add(this); } } }