private void PrintSiteHistory() { if (_entity.SiteHistory.Count > 0) { Html.AppendLine(Bold("Site History") + LineBreak); TableMaker siteTable = new TableMaker(true); foreach (OwnerPeriod ownedSite in _entity.SiteHistory.OrderBy(sh => sh.StartYear)) { siteTable.StartRow(); siteTable.AddData(ownedSite.Owner.ToLink(true, _entity)); siteTable.AddData(ownedSite.StartCause); siteTable.AddData(ownedSite.Site.ToLink()); var startYear = ownedSite.StartYear >= 0 ? ownedSite.StartYear.ToString() : "in a time before time"; siteTable.AddData(startYear, 0, TableDataAlign.Right); if (ownedSite.EndYear >= 0) { siteTable.AddData(ownedSite.EndCause); siteTable.AddData(ownedSite.EndYear.ToString(), 0, TableDataAlign.Right); } if (ownedSite.Ender != null) { if (ownedSite.Ender is Entity entity) { siteTable.AddData(" by " + entity.PrintEntity()); } else { siteTable.AddData(" by " + ownedSite.Ender.ToLink(true, _entity)); } } siteTable.EndRow(); } Html.AppendLine(siteTable.GetTable() + LineBreak); } }
private void PrintSiteHistory() { if (_entity.SiteHistory.Count > 0) { Html.AppendLine(Bold("Site History") + " " + MakeLink("[Load]", LinkOption.LoadEntitySites) + LineBreak); TableMaker siteTable = new TableMaker(true); foreach (OwnerPeriod ownedSite in _entity.SiteHistory.OrderBy(sh => sh.StartYear)) { siteTable.StartRow(); siteTable.AddData(ownedSite.Owner.ToLink(true, _entity)); siteTable.AddData(ownedSite.StartCause); siteTable.AddData(ownedSite.Site.ToLink()); siteTable.AddData(ownedSite.StartYear.ToString(), 0, TableDataAlign.Right); if (ownedSite.EndYear >= 0) { siteTable.AddData(ownedSite.EndCause); siteTable.AddData(ownedSite.EndYear.ToString(), 0, TableDataAlign.Right); } if (ownedSite.Ender != null) { if (ownedSite.Ender is Entity) { siteTable.AddData(" by " + ((Entity)ownedSite.Ender).PrintEntity()); } else { siteTable.AddData(" by " + ownedSite.Ender.ToLink(true, _entity)); } } siteTable.EndRow(); } Html.AppendLine(siteTable.GetTable() + LineBreak); } }
private void PrintMaps() { if (_entity.SiteHistory.Count == 0) { return; } List <Bitmap> maps = MapPanel.CreateBitmaps(_world, _entity); TableMaker mapTable = new TableMaker(); mapTable.StartRow(); mapTable.AddData(MakeLink(BitmapToHtml(maps[0]), LinkOption.LoadMap)); mapTable.AddData(MakeLink(BitmapToHtml(maps[1]), LinkOption.LoadMap)); mapTable.EndRow(); Html.AppendLine(mapTable.GetTable() + "</br>"); maps[0].Dispose(); maps[1].Dispose(); }
private void PrintLeaders() { if (_entity.Leaders != null && _entity.Leaders.Count > 0) { Html.AppendLine(Bold("Leaderhistory") + " " + LineBreak); foreach (string leaderType in _entity.LeaderTypes) { Html.AppendLine(leaderType + "s" + LineBreak); TableMaker leaderTable = new TableMaker(true); foreach (HistoricalFigure leader in _entity.Leaders[_entity.LeaderTypes.IndexOf(leaderType)]) { leaderTable.StartRow(); leaderTable.AddData(leader.Positions.Last(position => position.Title == leaderType).Began.ToString(), 0, TableDataAlign.Right); leaderTable.AddData(leader.ToLink()); leaderTable.EndRow(); } Html.AppendLine(leaderTable.GetTable() + LineBreak); } } }
private void PrintWars() { if (_entity.Wars.Count(war => !_world.FilterBattles || war.Notable) > 0) { Html.AppendLine(Bold("Wars") + LineBreak); TableMaker warTable = new TableMaker(true); foreach (War war in _entity.Wars.Where(war => !_world.FilterBattles || war.Notable)) { warTable.StartRow(); string endString; if (war.EndYear == -1) { endString = "Present"; } else { endString = war.EndYear.ToString(); } warTable.AddData(war.StartYear + " - " + endString); warTable.AddData(war.ToLink()); if (war.Attacker == _entity) { warTable.AddData("waged against"); warTable.AddData(war.Defender.PrintEntity(), 0); warTable.AddData(""); } else if (war.Attacker.Parent == _entity) { warTable.AddData("waged against"); warTable.AddData(war.Defender.PrintEntity(), 0); warTable.AddData("by " + war.Attacker.ToLink()); } else if (war.Defender == _entity) { warTable.AddData("defended against"); warTable.AddData(war.Attacker.PrintEntity(), 0); warTable.AddData(""); } else if (war.Defender.Parent == _entity) { warTable.AddData("defended against"); warTable.AddData(war.Attacker.PrintEntity(), 0); warTable.AddData("by " + war.Defender.ToLink()); } int battleVictories = 0, battleLossses = 0, sitesDestroyed = 0, sitesLost = 0, kills, losses; if (war.Attacker == _entity || war.Attacker.Parent == _entity) { battleVictories = war.AttackerVictories.OfType <Battle>().Count(); battleLossses = war.DefenderVictories.OfType <Battle>().Count(); sitesDestroyed = war.AttackerVictories.OfType <SiteConquered>().Count(conquering => conquering.ConquerType != SiteConqueredType.Pillaging); sitesLost = war.DefenderVictories.OfType <SiteConquered>().Count(conquering => conquering.ConquerType != SiteConqueredType.Pillaging); } else if (war.Defender == _entity || war.Defender.Parent == _entity) { battleVictories = war.DefenderVictories.OfType <Battle>().Count(); battleLossses = war.AttackerVictories.OfType <Battle>().Count(); sitesDestroyed = war.DefenderVictories.OfType <SiteConquered>().Count(conquering => conquering.ConquerType != SiteConqueredType.Pillaging); sitesLost = war.AttackerVictories.OfType <SiteConquered>().Count(conquering => conquering.ConquerType != SiteConqueredType.Pillaging); } kills = war.Collections.OfType <Battle>().Where(battle => battle.Attacker == _entity || battle.Attacker?.Parent == _entity).Sum(battle => battle.DefenderDeathCount) + war.Collections.OfType <Battle>().Where(battle => battle.Defender == _entity || battle.Defender?.Parent == _entity).Sum(battle => battle.AttackerDeathCount); losses = war.Collections.OfType <Battle>().Where(battle => battle.Attacker == _entity || battle.Attacker?.Parent == _entity).Sum(battle => battle.AttackerDeathCount) + war.Collections.OfType <Battle>().Where(battle => battle.Defender == _entity || battle.Defender?.Parent == _entity).Sum(battle => battle.DefenderDeathCount); warTable.AddData("(V/L)"); warTable.AddData("Battles:"); warTable.AddData(battleVictories.ToString(), 0, TableDataAlign.Right); warTable.AddData("/"); warTable.AddData(battleLossses.ToString()); warTable.AddData("Sites:"); warTable.AddData(sitesDestroyed.ToString(), 0, TableDataAlign.Right); warTable.AddData("/"); warTable.AddData(sitesLost.ToString()); warTable.AddData("Deaths:"); warTable.AddData(kills.ToString(), 0, TableDataAlign.Right); warTable.AddData("/"); warTable.AddData(losses.ToString()); warTable.EndRow(); } Html.AppendLine(warTable.GetTable() + LineBreak); } }
private void PrintBattles() { Battle unnotableDeathBattle = null; //Temporarily make the battle that the HF died in Notable so it shows up. if (_historicalFigure.Battles.Count > 0 && _historicalFigure.Battles.Last().Collection.OfType <HfDied>().Count(death => death.HistoricalFigure == _historicalFigure) == 1 && !_historicalFigure.Battles.Last().Notable) { unnotableDeathBattle = _historicalFigure.Battles.Last(); unnotableDeathBattle.Notable = true; } if (_historicalFigure.Battles.Count(battle => !_world.FilterBattles || battle.Notable) > 0) { Html.AppendLine(Bold("Battles") + MakeLink("[Load]", LinkOption.LoadHfBattles)); if (_world.FilterBattles) { Html.Append(" (Notable)"); } Html.Append(LineBreak); TableMaker battleTable = new TableMaker(true); foreach (Battle battle in _historicalFigure.Battles.Where(battle => !_world.FilterBattles || battle.Notable || battle.Collection.OfType <HfDied>().Count(death => death.HistoricalFigure == _historicalFigure) > 0)) { battleTable.StartRow(); battleTable.AddData(battle.StartYear.ToString()); battleTable.AddData(battle.ToLink()); if (battle.ParentCollection != null) { battleTable.AddData("as part of"); battleTable.AddData(battle.ParentCollection.ToLink()); } string involvement = ""; if (battle.NotableAttackers.Count > 0 && battle.NotableAttackers.Contains(_historicalFigure)) { if (battle.Collection.OfType <FieldBattle>().Any(fieldBattle => fieldBattle.AttackerGeneral == _historicalFigure) || battle.Collection.OfType <AttackedSite>().Any(attack => attack.AttackerGeneral == _historicalFigure)) { involvement += "Led the attack"; } else { involvement += "Fought in the attack"; } } else if (battle.NotableDefenders.Count > 0 && battle.NotableDefenders.Contains(_historicalFigure)) { if (battle.Collection.OfType <FieldBattle>().Any(fieldBattle => fieldBattle.DefenderGeneral == _historicalFigure) || battle.Collection.OfType <AttackedSite>().Any(attack => attack.DefenderGeneral == _historicalFigure)) { involvement += "Led the defense"; } else { involvement += "Aided in the defense"; } } else { involvement += "A non combatant"; } if (battle.GetSubEvents().OfType <HfDied>().Any(death => death.HistoricalFigure == _historicalFigure)) { involvement += " and died"; } battleTable.AddData(involvement); if (battle.NotableAttackers.Contains(_historicalFigure)) { battleTable.AddData("against"); battleTable.AddData(battle.Defender.PrintEntity()); if (battle.Victor == battle.Attacker) { battleTable.AddData("and won"); } else { battleTable.AddData("and lost"); } } else if (battle.NotableDefenders.Contains(_historicalFigure)) { battleTable.AddData("against"); battleTable.AddData(battle.Attacker.PrintEntity()); if (battle.Victor == battle.Defender) { battleTable.AddData("and won"); } else { battleTable.AddData("and lost"); } } battleTable.AddData("Deaths: " + (battle.AttackerDeathCount + battle.DefenderDeathCount) + ")"); battleTable.EndRow(); } Html.AppendLine(battleTable.GetTable() + LineBreak); } if (_world.FilterBattles && _historicalFigure.Battles.Count(battle => !battle.Notable) > 0) { Html.AppendLine(Bold("Battles") + " (Unnotable): " + _historicalFigure.Battles.Where(battle => !battle.Notable).Count() + LineBreak + LineBreak); } if (unnotableDeathBattle != null) { unnotableDeathBattle.Notable = false; } }