Example #1
0
        private void PrintWars()
        {
            if (_entity.Wars.Count(war => !_world.FilterBattles || war.Notable) > 0)
            {
                Html.AppendLine(Bold("Wars") + " " + MakeLink("[Load]", LinkOption.LoadEntityWars) + 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() ?? " an unknown civilization ");
                        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() ?? " an unknown civilization ");
                        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;
            }
        }