private void ReadWorships() { if (CurrentLine.Contains("Worship List")) { ReadLine(); while (CurrentLine != null && CurrentLine.StartsWith(" ")) { string worshipName = Formatting.InitCaps(Formatting.ReplaceNonAscii(CurrentLine.Substring(2, CurrentLine.IndexOf(",") - 2))); HistoricalFigure worship = null; try { worship = World.GetHistoricalFigure(worshipName); } catch (Exception e) { worship = World.HistoricalFiguresByName.FirstOrDefault(h => h.Name.Equals(worshipName, StringComparison.OrdinalIgnoreCase) && h.Deity); if (worship == null) { Log.AppendLine(e.Message + ", a Worship of " + CurrentCiv.Name); ReadLine(); continue; } } worship.WorshippedBy = CurrentCiv; CurrentCiv.Worshipped.Add(worship); ReadLine(); } } }
private void ReadWorships() { if (CurrentLine.Contains("Worship List")) { ReadLine(); while (CurrentLine != null && CurrentLine.StartsWith(" ")) { string worshipName = Formatting.InitCaps(Formatting.ReplaceNonAscii(CurrentLine.Substring(2, CurrentLine.IndexOf(",") - 2))); HistoricalFigure worship = null; try { worship = World.GetHistoricalFigure(worshipName); } catch (Exception e) { Log.AppendLine(e.Message + ", a Worship of " + CurrentCiv.Name); ReadLine(); continue; } worship.WorshippedBy = CurrentCiv; CurrentCiv.Worshipped.Add(worship); ReadLine(); } } }
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; if (battle.NotableAttackers.Contains(death.HistoricalFigure)) { battle.AttackerDeathCount++; battle.Attackers.Single(squad => squad.Race == death.HistoricalFigure.Race).Deaths++; (battle.ParentCollection as War).AttackerDeathCount++; } else if (battle.NotableDefenders.Contains(death.HistoricalFigure)) { battle.DefenderDeathCount++; battle.Defenders.Single(squad => squad.Race == death.HistoricalFigure.Race).Deaths++; (battle.ParentCollection as War).DefenderDeathCount++; } (ParentCollection.ParentCollection as War).DeathCount++; } }
public string Print(bool link = true, DwarfObject pov = null, WorldEvent worldEvent = null) { var identityString = "the "; if (Race != null && Race != CreatureInfo.Unknown) { identityString += Race.NameSingular.ToLower(); } else { identityString += HistoricalFigure.GetRaceString(); } if (!string.IsNullOrWhiteSpace(Profession)) { identityString += " " + Profession.ToLower(); } var icon = !string.IsNullOrWhiteSpace(Caste) ? GetIcon() : HistoricalFigure.GetIcon(); if (!string.IsNullOrWhiteSpace(icon)) { identityString += " " + icon; } identityString += " " + Name; if (Entity != null) { identityString += " of "; identityString += Entity.ToLink(link, pov, worldEvent); } return(identityString); }
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++; } } } }
private void ReadLeaders() { while (LeaderStart()) { string leaderType = Formatting.InitCaps(CurrentLine.Substring(1, CurrentLine.IndexOf("List") - 2)); CurrentCiv.LeaderTypes.Add(leaderType); CurrentCiv.Leaders.Add(new List <HistoricalFigure>()); ReadLine(); while (CurrentLine != null && CurrentLine.StartsWith(" ")) { if (CurrentLine.Contains("[*]")) { string leaderName = Formatting.ReplaceNonAscii(CurrentLine.Substring(CurrentLine.IndexOf("[*]") + 4, CurrentLine.IndexOf("(b") - CurrentLine.IndexOf("[*]") - 5)); HistoricalFigure leader = null; try { leader = World.GetHistoricalFigure(leaderName); } catch (Exception e) { Log.AppendLine(e.Message + ", a Leader of " + CurrentCiv.Name); ReadLine(); continue; } int reignBegan = Convert.ToInt32(CurrentLine.Substring(CurrentLine.IndexOf(":") + 2, CurrentLine.IndexOf("), ") - CurrentLine.IndexOf(":") - 2)); if (CurrentCiv.Leaders[CurrentCiv.LeaderTypes.Count - 1].Count > 0) //End of previous leader's reign { CurrentCiv.Leaders[CurrentCiv.LeaderTypes.Count - 1].Last().Positions.Last().Ended = reignBegan - 1; } if (leader.Positions.Count > 0 && leader.Positions.Last().Ended == -1) //End of leader's last leader position (move up rank etc.) { HistoricalFigure.Position lastPosition = leader.Positions.Last(); lastPosition.Ended = reignBegan; lastPosition.Length = lastPosition.Began - reignBegan; } HistoricalFigure.Position newPosition = new HistoricalFigure.Position(CurrentCiv, reignBegan, -1, leaderType); if (leader.DeathYear != -1) { newPosition.Ended = leader.DeathYear; newPosition.Length = leader.DeathYear - newPosition.Ended; } else { newPosition.Length = World.Events.Last().Year - newPosition.Began; } leader.Positions.Add(newPosition); CurrentCiv.Leaders[CurrentCiv.LeaderTypes.Count - 1].Add(leader); } ReadLine(); } } }
public void CheckSiteOwnership() { //Check if a site was gained without a proper event from the xml if (Owner != null) { if (Site.OwnerHistory.Count == 0) { new OwnerPeriod(Site, Owner, 1, "founded"); } else if (Site.OwnerHistory.Last().Owner != Owner) { bool found = false; HistoricalFigure lastKnownOwner = Site.OwnerHistory.Last().Owner as HistoricalFigure; if (lastKnownOwner != null) { if (lastKnownOwner.DeathYear != -1) { new OwnerPeriod(Site, Owner, lastKnownOwner.DeathYear, "after death of last owner (" + lastKnownOwner.DeathCause + ") took over"); found = true; } else if (lastKnownOwner.Race == "Demon" && Site.Type == "Vault" && Owner is Entity && Owner.Race == "Unknown") { // SPOILER Devil owns the place, Entity is a group of angles found = true; } } else if (Site.CurrentOwner == null) { new OwnerPeriod(Site, Owner, Site.OwnerHistory.Last().EndYear, "slowly repopulated after the site was " + Site.OwnerHistory.Last().EndCause); found = true; } if (!found) { ChangeHFState lastSettledEvent = Site.Events.OfType <ChangeHFState>().LastOrDefault(); if (lastSettledEvent != null) { new OwnerPeriod(Site, Owner, lastSettledEvent.Year, "settled in "); } else { World.ParsingErrors.Report("Site ownership conflict: " + Site.Name + ". Actually owned by " + Owner.ToLink(false) + " instead of " + Site.OwnerHistory.Last().Owner.ToLink(false)); } } } } //check for loss of period ownership, since some some loss of ownership eventsList are missing if (Owner == null && Site.OwnerHistory.Count > 0 && Site.OwnerHistory.Last().EndYear == -1) { Site.OwnerHistory.Last().EndYear = World.Events.Last().Year - 1; Site.OwnerHistory.Last().EndCause = "UNKNOWN"; } }
public void ProcessHFtoSiteLinks() { for (int i = 0; i < HFtoSiteLinks.Count; i++) { Property link = HFtoSiteLinks[i]; HistoricalFigure hf = HFtoSiteLinkHFs[i]; SiteLink relatedSite = new SiteLink(link.SubProperties, this); hf.RelatedSites.Add(relatedSite); } HFtoSiteLinkHFs.Clear(); HFtoSiteLinks.Clear(); }
public void ProcessReputations() { for (int i = 0; i < Reputations.Count; i++) { Property reputation = Reputations[i]; HistoricalFigure hf = ReputationHFs[i]; EntityReputation entityReputation = new EntityReputation(reputation.SubProperties, this); hf.Reputations.Add(entityReputation); } ReputationHFs.Clear(); Reputations.Clear(); }
public void ProcessHFtoHFLinks() { for (int i = 0; i < HFtoHFLinks.Count; i++) { Property link = HFtoHFLinks[i]; HistoricalFigure HF = HFtoHFLinkHFs[i]; HistoricalFigureLink relation = new HistoricalFigureLink(link.SubProperties, this); HF.RelatedHistoricalFigures.Add(relation); } HFtoHFLinkHFs.Clear(); HFtoHFLinks.Clear(); }
public void ProcessHFtoHfLinks() { for (int i = 0; i < _hFtoHfLinks.Count; i++) { Property link = _hFtoHfLinks[i]; HistoricalFigure hf = _hFtoHfLinkHFs[i]; HistoricalFigureLink relation = new HistoricalFigureLink(link.SubProperties, this); hf.RelatedHistoricalFigures.Add(relation); } _hFtoHfLinkHFs.Clear(); _hFtoHfLinks.Clear(); }
public void ProcessHFtoSiteLinks() { for (int i = 0; i < _hFtoSiteLinks.Count; i++) { Property link = _hFtoSiteLinks[i]; HistoricalFigure hf = _hFtoSiteLinkHFs[i]; SiteLink hfToSiteLink = new SiteLink(link.SubProperties, this); hf.RelatedSites.Add(hfToSiteLink); hfToSiteLink.Site?.RelatedHistoricalFigures.Add(hf); } _hFtoSiteLinkHFs.Clear(); _hFtoSiteLinks.Clear(); }
public void ProcessHFCurrentIdentities() { for (int i = 0; i < CurrentIdentityHFs.Count; i++) { HistoricalFigure hf = CurrentIdentityHFs[i]; int id = CurrentIdentityIDs[i]; if (hf.CurrentIdentity != null) { throw new Exception("Current Identity already exists."); } hf.CurrentIdentity = GetHistoricalFigure(id); } CurrentIdentityHFs.Clear(); CurrentIdentityIDs.Clear(); }
public void ProcessHFUsedIdentities() { for (int i = 0; i < UsedIdentityHFs.Count; i++) { HistoricalFigure hf = UsedIdentityHFs[i]; int id = UsedIdentityIDs[i]; if (hf.UsedIdentity != null) { throw new Exception("UsedIdentity already exists."); } hf.UsedIdentity = GetHistoricalFigure(id); } UsedIdentityHFs.Clear(); UsedIdentityIDs.Clear(); }
public void Resolve(World world, HistoricalFigure historicalFigure) { Entity = world.GetEntity(EntityId); if (Entity != null) { foreach (var honorId in HonorIds) { var honor = Entity.Honors.FirstOrDefault(h => h.Id == honorId); if (honor != null) { honor.HonoredHfs.Add(historicalFigure); Honors.Add(honor); } } } }
public void ProcessHFtoEntityLinks() { for (int i = 0; i < _hFtoEntityLinks.Count; i++) { Property link = _hFtoEntityLinks[i]; HistoricalFigure hf = _hFtoEntityLinkHFs[i]; EntityLink relatedEntity = new EntityLink(link.SubProperties, this); if (relatedEntity.Entity != null) { if (relatedEntity.Type != EntityLinkType.Enemy || relatedEntity.Type == EntityLinkType.Enemy && relatedEntity.Entity.IsCiv) { hf.RelatedEntities.Add(relatedEntity); } } } _hFtoEntityLinkHFs.Clear(); _hFtoEntityLinks.Clear(); }
public void ProcessHFtoEntityLinks() { for (int i = 0; i < HFtoEntityLinks.Count; i++) { Property link = HFtoEntityLinks[i]; HistoricalFigure hf = HFtoEntityLinkHFs[i]; EntityLink relatedEntity = new EntityLink(link.SubProperties, this); if (relatedEntity.Entity == null) { continue; } else if (relatedEntity.Type != EntityLinkType.Enemy || (relatedEntity.Type == EntityLinkType.Enemy && relatedEntity.Entity.IsCiv)) { hf.RelatedEntities.Add(relatedEntity); } } HFtoEntityLinkHFs.Clear(); HFtoEntityLinks.Clear(); }
private void ReadOfficials() { if (CurrentLine.Contains(":")) //Read in Officials, law-givers, mayors etc, ex: law-giver: Oled Sugarynestled, human { while (!SitesAndPops.EndOfStream && CurrentLine.Contains(":") && !SiteStart()) { HistoricalFigure siteOfficial = null; string officialName = Formatting.ReplaceNonAscii(CurrentLine.Substring(CurrentLine.IndexOf(":") + 2, CurrentLine.IndexOf(",") - CurrentLine.IndexOf(":") - 2)); try { siteOfficial = World.GetHistoricalFigure(officialName); } catch (Exception e) { World.ParsingErrors.Report(e.Message + ", Official of " + Site.Name); ReadLine(); continue; } string siteOfficialPosition = CurrentLine.Substring(1, CurrentLine.IndexOf(":") - 1); Site.Officials.Add(new Site.Official(siteOfficial, siteOfficialPosition)); ReadLine(); } } }
private void ProcessCollections() { World.Wars = World.EventCollections.OfType <War>().ToList(); World.Battles = World.EventCollections.OfType <Battle>().ToList(); World.BeastAttacks = World.EventCollections.OfType <BeastAttack>().ToList(); foreach (EventCollection eventCollection in World.EventCollections) { //Sub Event Collections aren't created until after the main collection //So only IDs are stored in the main collection until here now that all collections have been created //and can now be added to their Parent collection foreach (int collectionID in eventCollection.CollectionIDs) { eventCollection.Collections.Add(World.GetEventCollection(collectionID)); } } //Attempt at calculating beast historical figure for beast attacks. //Find beast by looking at eventsList and fill in some event properties from the beast attacks's properties //Calculated here so it can look in Duel collections contained in beast attacks foreach (BeastAttack beastAttack in World.EventCollections.OfType <BeastAttack>()) { //Find Beast by looking at fights, Beast always engages the first fight in a Beast Attack? if (beastAttack.GetSubEvents().OfType <HFSimpleBattleEvent>().Any()) { beastAttack.Beast = beastAttack.GetSubEvents().OfType <HFSimpleBattleEvent>().First().HistoricalFigure1; if (beastAttack.Beast.BeastAttacks == null) { beastAttack.Beast.BeastAttacks = new List <BeastAttack>(); } beastAttack.Beast.BeastAttacks.Add(beastAttack); } if (beastAttack.GetSubEvents().OfType <HFDied>().Count() > 1) { var slayers = beastAttack.GetSubEvents().OfType <HFDied>().GroupBy(death => death.Slayer).Select(hf => new { HF = hf.Key, Count = hf.Count() }); if (slayers.Count(slayer => slayer.Count > 1) == 1) { HistoricalFigure beast = slayers.Single(slayer => slayer.Count > 1).HF; beastAttack.Beast = beast; } } //Fill in some various event info from collections. int insertIndex; foreach (ItemStolen theft in beastAttack.Collection.OfType <ItemStolen>()) { if (theft.Site == null) { theft.Site = beastAttack.Site; } else { beastAttack.Site = theft.Site; } if (theft.Thief == null) { theft.Thief = beastAttack.Beast; } else { beastAttack.Beast = theft.Thief; } if (beastAttack.Site != null) { insertIndex = beastAttack.Site.Events.BinarySearch(theft); if (insertIndex < 0) { beastAttack.Site.Events.Add(theft); } } if (beastAttack.Beast != null) { insertIndex = beastAttack.Beast.Events.BinarySearch(theft); if (insertIndex < 0) { beastAttack.Beast.Events.Add(theft); } } } foreach (CreatureDevoured devoured in beastAttack.Collection.OfType <CreatureDevoured>()) { if (devoured.Eater == null) { devoured.Eater = beastAttack.Beast; } else { beastAttack.Beast = devoured.Eater; } if (beastAttack.Beast != null) { insertIndex = beastAttack.Beast.Events.BinarySearch(devoured); if (insertIndex < 0) { beastAttack.Beast.Events.Add(devoured); } } } } //Assign a Conquering Event its corresponding battle //Battle = first Battle prior to the conquering? foreach (SiteConquered conquer in World.EventCollections.OfType <SiteConquered>()) { for (int i = conquer.ID - 1; i >= 0; i--) { EventCollection collection = World.GetEventCollection(i); if (collection == null) { continue; } if (collection.GetType() == typeof(Battle)) { conquer.Battle = collection as Battle; conquer.Battle.Conquering = conquer; if (conquer.Battle.Defender == null && conquer.Defender != null) { conquer.Battle.Defender = conquer.Defender; } break; } } } }
public Official(HistoricalFigure historicalFigure, string position) { HistoricalFigure = historicalFigure; Position = position; }
public void AddHFUsedIdentity(HistoricalFigure hf, int identityID) { UsedIdentityHFs.Add(hf); UsedIdentityIDs.Add(identityID); }
public void AddHFCurrentIdentity(HistoricalFigure hf, int identityID) { CurrentIdentityHFs.Add(hf); CurrentIdentityIDs.Add(identityID); }
public void AddReputation(HistoricalFigure hf, Property link) { ReputationHFs.Add(hf); Reputations.Add(link); }
public void AddHFtoSiteLink(HistoricalFigure hf, Property link) { HFtoSiteLinkHFs.Add(hf); HFtoSiteLinks.Add(link); }
public void FixUnloadedHistoricalFigure(HistoricalFigure hf) { if (hf.ID == notYetLoadedHFID) HistoricalFigure = hf; }
public void AddHFtoEntityLink(HistoricalFigure hf, Property link) { _hFtoEntityLinkHFs.Add(hf); _hFtoEntityLinks.Add(link); }
public HistoricalFigureLink(HistoricalFigure hf, HistoricalFigureLinkType type) { HistoricalFigure = hf; Type = type; }
public HistoricalFigureLink(HistoricalFigure historicalFigureTarget, HistoricalFigureLinkType type, int strength = 0) { HistoricalFigure = historicalFigureTarget; Type = type; Strength = strength; }
public HistoricalFigureHTMLPrinter(HistoricalFigure hf, World world) { World = world; HistoricalFigure = hf; }