private void PrintCurrentLeadership()
        {
            if (_entity.EntityPositionAssignments.Any() && _entity.EntityPositionAssignments.Where(epa => epa.HistoricalFigure != null).Any())
            {
                Html.AppendLine("<b>Current Leadership</b><br />");
                Html.AppendLine("<ul>");
                foreach (EntityPositionAssignment assignment in _entity.EntityPositionAssignments)
                {
                    EntityPosition position = _entity.EntityPositions.FirstOrDefault(pos => pos.Id == assignment.PositionId);
                    if (position != null && assignment.HistoricalFigure != null)
                    {
                        string positionName = position.GetTitleByCaste(assignment.HistoricalFigure.Caste);

                        Html.AppendLine("<li>" + assignment.HistoricalFigure.ToLink() + ", " + positionName + "</li>");

                        if (!string.IsNullOrEmpty(position.Spouse))
                        {
                            HistoricalFigureLink spouseLink = assignment.HistoricalFigure.RelatedHistoricalFigures.FirstOrDefault(hfLink => hfLink.Type == HistoricalFigureLinkType.Spouse);
                            if (spouseLink != null)
                            {
                                HistoricalFigure spouse = spouseLink.HistoricalFigure;
                                if (spouse != null)
                                {
                                    string spousePositionName = position.GetTitleByCaste(spouse.Caste, true);
                                    Html.AppendLine("<li>" + spouse.ToLink() + ", " + spousePositionName + "</li>");
                                }
                            }
                        }
                    }
                }
                Html.AppendLine("</ul>");
            }
        }
Exemple #2
0
        public RemoveHfHfLink(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "hfid": HistoricalFigure = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "hfid_target": HistoricalFigureTarget = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "link_type":
                    HistoricalFigureLinkType linkType;
                    if (Enum.TryParse(Formatting.InitCaps(property.Value.Replace("_", " ")).Replace(" ", ""), out linkType))
                    {
                        LinkType = linkType;
                    }
                    else
                    {
                        world.ParsingErrors.Report("Unknown HF HF Link Type: " + property.Value);
                    }
                    break;
                }
            }

            //Fill in LinkType by looking at related historical figures.
            if (LinkType == HistoricalFigureLinkType.Unknown && HistoricalFigure != HistoricalFigure.Unknown && HistoricalFigureTarget != HistoricalFigure.Unknown)
            {
                List <HistoricalFigureLink> historicalFigureToTargetLinks = HistoricalFigure.RelatedHistoricalFigures.Where(link => link.Type != HistoricalFigureLinkType.Child).Where(link => link.HistoricalFigure == HistoricalFigureTarget).ToList();
                HistoricalFigureLink        historicalFigureToTargetLink  = null;
                if (historicalFigureToTargetLinks.Count <= 1)
                {
                    historicalFigureToTargetLink = historicalFigureToTargetLinks.FirstOrDefault();
                }

                HfAbducted abduction = HistoricalFigureTarget.Events.OfType <HfAbducted>().SingleOrDefault(abduction1 => abduction1.Snatcher == HistoricalFigure);
                if (historicalFigureToTargetLink != null && abduction == null)
                {
                    LinkType = historicalFigureToTargetLink.Type;
                }
                else if (abduction != null)
                {
                    LinkType = HistoricalFigureLinkType.Prisoner;
                }
            }

            HistoricalFigure.AddEvent(this);
            HistoricalFigureTarget.AddEvent(this);
        }