Пример #1
0
        private List <Block> CreateBlocks(Monster monster, Character ch, bool addDescription)
        {
            List <Block> blocks = new List <Block>();

            CreateTopSection(monster, ch, blocks);

            CreateDefenseSection(monster, blocks);

            CreateOffenseSection(monster, blocks);
            CreateTacticsSection(monster, blocks);
            CreateStatisticsSection(monster, blocks);
            CreateEcologySection(monster, blocks);
            CreateSpecialAbilitiesSection(monster, blocks);
            if (addDescription)
            {
                CreateDescriptionSection(monster, blocks);
            }



            if (SourceInfo.GetSourceType(monster.Source) != SourceType.Core)
            {
                Paragraph sourceParagraph = new Paragraph();

                sourceParagraph.Margin = new Thickness(0);
                String source = SourceInfo.GetSource(monster.Source);
                if (source == "")
                {
                    source = monster.Source;
                }
                CreateItemIfNotNull(sourceParagraph.Inlines, "Source ", source);
                blocks.Add(sourceParagraph);
            }


            return(blocks);
        }
Пример #2
0
        public static string CreateHtml(Spell spell, bool shortForm, bool showTitle)
        {
            StringBuilder blocks = new StringBuilder();

            blocks.CreateHtmlHeader();


            if (!shortForm)
            {
                if (showTitle)
                {
                    blocks.CreateHeader(spell.name);
                }


                blocks.CreateItemIfNotNull("School ", true, spell.school, null, false);


                blocks.CreateItemIfNotNull(" (", false, spell.subschool, ")", false);
                blocks.CreateItemIfNotNull(" [", false, spell.descriptor, "]", false);

                blocks.AppendLineBreak();

                blocks.CreateItemIfNotNull("Level ", spell.spell_level);
                blocks.CreateItemIfNotNull("Preparation Time ", spell.preparation_time);
                blocks.CreateItemIfNotNull("Casting Time ", spell.casting_time);
                blocks.CreateItemIfNotNull("Components ", spell.components);
                blocks.CreateItemIfNotNull("Range ", spell.range);
                blocks.CreateItemIfNotNull("Area ", spell.area);
                blocks.CreateItemIfNotNull("Targets ", spell.targets);
                blocks.CreateItemIfNotNull("Effects ", spell.effect);

                blocks.CreateItemIfNotNull("Duration ", spell.duration);
                blocks.CreateItemIfNotNull("Saving Throw ", spell.saving_throw);

                blocks.CreateItemIfNotNull("Spell Resistance ", spell.spell_resistence);

                if (spell.source != "PFRPG Core")
                {
                    blocks.CreateItemIfNotNull("Source ", SourceInfo.GetSource(spell.source));
                }

                if (spell.description_formated != null && spell.description_formated.Length > 0)
                {
                    blocks.Append(spell.description_formated);
                }
                else if (spell.description != null && spell.description.Length > 0)
                {
                    blocks.AppendHtml(spell.description);
                }
            }
            else
            {
                if (showTitle)
                {
                    blocks.AppendEscapedTag("p", "bolded", spell.name);
                }

                if (spell.description_formated != null && spell.description_formated.Length > 0)
                {
                    blocks.Append(spell.description_formated);
                }
                else if (spell.description != null && spell.description.Length > 0)
                {
                    blocks.AppendHtml(spell.description);
                }
            }

            blocks.CreateHtmlFooter();


            return(blocks.ToString());
        }
Пример #3
0
        public List <Block> CreateBlocks(MagicItem item, bool showTitle)
        {
            List <Block> blocks = new List <Block>();

            if (showTitle)
            {
                blocks.Add(CreateHeaderParagraph(item.Name, item.Group));
            }


            Paragraph details = new Paragraph();

            details.Margin = new Thickness(0, 2, 0, 0);

            CreateItemIfNotNull(details.Inlines, "Aura ", true, item.Aura, " ", false);
            CreateItemIfNotNull(details.Inlines, "[", false, item.AuraStrength, "]; ", false);
            CreateItemIfNotNull(details.Inlines, "CL ", true, (item.CL == -1)?"Varies":PastTenseNumber(item.CL), "", true);
            CreateItemIfNotNull(details.Inlines, "Slot ", true, item.Slot, "; ", false);
            CreateItemIfNotNull(details.Inlines, "Price ", true, item.Price, "; ", false);
            CreateItemIfNotNull(details.Inlines, "Weight ", true, item.Weight, "", true);


            blocks.Add(details);

            if (NotNullString(item.DescHTML) || NotNullString(item.Description))
            {
                blocks.AddRange(CreateSectionHeader("DESCRIPTION"));

                if (NotNullString(item.DescHTML))
                {
                    blocks.AddRange(CreateFlowFromDescription(item.DescHTML));
                }
                else
                {
                    Paragraph description = new Paragraph();
                    description.Margin = new Thickness(0, 2, 0, 0);

                    string text = FixBodyString(item.Description);

                    CreateItemIfNotNull(description.Inlines, null, true, text, null, true);


                    blocks.Add(description);
                }
            }

            if (item.Requirements != null && item.Requirements.Length > 0 &&
                item.Cost != null && item.Cost.Length > 0)
            {
                blocks.AddRange(CreateSectionHeader("CONSTRUCTION"));

                Paragraph construction = new Paragraph();
                construction.Margin = new Thickness(0, 2, 0, 0);

                CreateItemIfNotNull(construction.Inlines, "Requirements ", true, item.Requirements, "; ", false);
                CreateItemIfNotNull(construction.Inlines, "Cost ", true, item.Cost, "", true);

                blocks.Add(construction);
            }

            if (NotNullString(item.Destruction))
            {
                blocks.AddRange(CreateSectionHeader("DESTRUCTION"));

                Paragraph desctruction = new Paragraph();
                desctruction.Margin = new Thickness(0, 2, 0, 0);


                CreateItemIfNotNull(desctruction.Inlines, null, false, FixBodyString(item.Destruction), null, true);


                blocks.Add(desctruction);
            }

            if (SourceInfo.GetSourceType(item.Source) != SourceType.Core)
            {
                Paragraph source = new Paragraph();
                source.Margin = new Thickness(0, 2, 0, 0);
                CreateItemIfNotNull(source.Inlines, "Source: ", SourceInfo.GetSource(item.Source));
                blocks.Add(source);
            }


            return(blocks);
        }
Пример #4
0
        public List <Block> CreateBlocks(Spell spell, bool shortForm, bool showTitle)
        {
            List <Block> blocks = new List <Block>();

            if (!shortForm)
            {
                if (showTitle)
                {
                    blocks.Add(CreateHeaderParagraph(spell.name));
                }

                Paragraph details = new Paragraph();
                details.Margin = new Thickness(0, 4, 0, 0);
                Span span1 = new Span();
                span1.Inlines.Add(new Bold(new Run("School ")));

                if (_LinkHandler == null)
                {
                    span1.Inlines.Add(new Run(spell.school));
                }
                else
                {
                    Hyperlink link = new Hyperlink(new Run(spell.school));
                    link.Click      += new RoutedEventHandler(link_Click);
                    link.DataContext = spell.school;

                    Rule rule = Rule.Rules.FirstOrDefault
                                    (a => String.Compare(a.Name, spell.school, true) == 0 &&
                                    String.Compare(a.Type, "Magic") == 0);

                    if (rule != null)
                    {
                        link.Tag = rule;
                        ToolTip t = (ToolTip)App.Current.MainWindow.FindResource("ObjectToolTip");

                        if (t != null)
                        {
                            ToolTipService.SetShowDuration(link, 360000);
                            link.ToolTip         = t;
                            link.ToolTipOpening += new ToolTipEventHandler(link_ToolTipOpening);
                        }
                    }

                    span1.Inlines.Add(link);
                }

                CreateItemIfNotNull(span1.Inlines, " (", false, spell.subschool, ")", false);
                CreateItemIfNotNull(span1.Inlines, " [", false, spell.descriptor, "]", false);

                if (showTitle)
                {
                    span1.Inlines.Add("     ");
                }
                else
                {
                    span1.Inlines.Add(new LineBreak());
                }
                span1.Inlines.Add(new Bold(new Run("Level ")));
                span1.Inlines.Add(spell.spell_level);
                span1.Inlines.Add(new LineBreak());
                details.Inlines.Add(span1);
                CreateItemIfNotNull(details.Inlines, "Preparation Time ", spell.preparation_time);
                CreateItemIfNotNull(details.Inlines, "Casting Time ", spell.casting_time);
                CreateItemIfNotNull(details.Inlines, "Components ", spell.components);
                if (spell.range != null && spell.range.Length > 0)
                {
                    details.Inlines.Add(new Bold(new Run("Range ")));
                    details.Inlines.Add(spell.range);
                    details.Inlines.Add(new LineBreak());
                }
                if (spell.area != null && spell.area.Length > 0)
                {
                    details.Inlines.Add(new Bold(new Run("Area ")));
                    details.Inlines.Add(spell.area);
                    details.Inlines.Add(new LineBreak());
                }
                if (spell.targets != null && spell.targets.Length > 0)
                {
                    details.Inlines.Add(new Bold(new Run("Targets ")));
                    details.Inlines.Add(spell.targets);
                    details.Inlines.Add(new LineBreak());
                }
                if (spell.effect != null && spell.effect.Length > 0)
                {
                    details.Inlines.Add(new Bold(new Run("Effect ")));
                    details.Inlines.Add(spell.effect);
                    details.Inlines.Add(new LineBreak());
                }

                CreateItemIfNotNull(details.Inlines, "Duration ", spell.duration);
                if (spell.saving_throw != null && spell.saving_throw.Length > 0)
                {
                    details.Inlines.Add(new Bold(new Run("Saving Throw ")));
                    details.Inlines.Add(spell.saving_throw);
                    details.Inlines.Add(new LineBreak());
                }
                if (spell.spell_resistence != null && spell.spell_resistence.Length > 0)
                {
                    details.Inlines.Add(new Bold(new Run("Spell Resistance ")));
                    details.Inlines.Add(spell.spell_resistence);
                    details.Inlines.Add(new LineBreak());
                }

                if (spell.source != "PFRPG Core")
                {
                    CreateItemIfNotNull(details.Inlines, "Source ", SourceInfo.GetSource(spell.source));
                }


                blocks.Add(details);

                List <Block> flow = new List <Block>();

                Thickness th = new Thickness(0, showTitle ? 5 : 0, 0, 0);

                if (spell.description_formated != null && spell.description_formated.Length > 0)
                {
                    flow = CreateFlowFromDescription(spell.description_formated);

                    if (flow.Count > 0)
                    {
                        flow[0].Margin = th;
                    }

                    blocks.AddRange(flow);
                }
                else if (spell.description != null && spell.description.Length > 0)
                {
                    Paragraph p = new Paragraph();
                    p.Margin = th;

                    p.Inlines.Add(new Run(spell.description));
                    blocks.Add(p);
                }
            }
            else
            {
                if (showTitle)
                {
                    Paragraph titleParagraph = new Paragraph();
                    titleParagraph.Inlines.Add(new Bold(new Run(spell.name)));
                    titleParagraph.Margin  = new Thickness(0);
                    titleParagraph.Padding = new Thickness(0);


                    blocks.Add(titleParagraph);
                }
                List <Block> flow = new List <Block>();;
                if (spell.description_formated != null && spell.description_formated.Length > 0)
                {
                    flow = CreateFlowFromDescription(spell.description_formated);


                    Block     block = flow[0];
                    Thickness m     = block.Margin;
                    m.Top        = 0;
                    block.Margin = m;

                    blocks.AddRange(flow);
                }
                else if (spell.description != null && spell.description.Length > 0)
                {
                    Paragraph p = new Paragraph();

                    Thickness th = new Thickness(0, showTitle ? 5 : 0, 0, 0);
                    p.Margin = th;

                    p.Inlines.Add(new Run(spell.description));
                    flow.Add(p);
                }

                foreach (Block b in flow)
                {
                    b.TextAlignment = TextAlignment.Left;
                }

                blocks.AddRange(flow);
            }



            return(blocks);
        }
Пример #5
0
        private bool SourceFilter(Weapon wp)
        {
            SourceType type = SourceInfo.GetSourceType(wp.Source);

            return(type == SourceType.Core || type == SourceType.APG);
        }
Пример #6
0
        public List <Block> CreateBlocks(Feat feat, bool showTitle)
        {
            List <Block> blocks = new List <Block>();

            string featString = null;

            if (feat.Types != null)
            {
                featString = "";
                bool first = true;
                foreach (String featType in feat.Types)
                {
                    if (feat.Type != "General")
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            featString += ", ";
                        }

                        featString += featType;
                    }
                }
            }

            Paragraph details = new Paragraph();

            details.Margin = new Thickness(0, 2, 0, 0);
            if (showTitle)
            {
                Run titleRun = new Run(feat.Name);
                titleRun.FontStyle  = FontStyles.Italic;
                titleRun.FontWeight = FontWeights.Bold;
                titleRun.FontSize   = titleRun.FontSize * 1.8;

                string text = feat.Name;


                if (featString != null && featString.Length > 0)
                {
                    text += " (" + featString + ")";
                }



                blocks.Add(CreateHeaderParagraph(text));
            }
            else
            {
                if (featString != null && featString.Length > 0)
                {
                    details.Inlines.Add(new Italic(new Run(featString)));
                    details.Inlines.Add(new LineBreak());
                }
            }



            details.Inlines.AddRange(CreateItemIfNotNull(null, feat.Summary));
            if (feat.Prerequistites != null)
            {
                details.Inlines.AddRange(CreateItemIfNotNull("Prerequisitites: ", feat.Prerequistites.Trim(new char[] { '-' })));
            }
            details.Inlines.AddRange(CreateItemIfNotNull("Benefit: ", feat.Benefit));
            details.Inlines.AddRange(CreateItemIfNotNull("Normal: ", feat.Normal));
            details.Inlines.AddRange(CreateItemIfNotNull("Special: ", feat.Special));

            if (feat.Source != "Pathfinder Core Rulebook")
            {
                CreateItemIfNotNull(details.Inlines, "Source: ", SourceInfo.GetSource(feat.Source));
            }


            blocks.Add(details);



            return(blocks);
        }
Пример #7
0
        public static String CreateHtml(Feat feat, bool showTitle)
        {
            StringBuilder blocks = new StringBuilder();

            blocks.CreateHtmlHeader();

            string featString = null;

            if (feat.Types != null)
            {
                featString = "";
                bool first = true;
                foreach (String featType in feat.Types)
                {
                    if (feat.Type != "General")
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            featString += ", ";
                        }

                        featString += featType;
                    }
                }
            }

            if (showTitle)
            {
                string text = feat.Name;


                if (featString != null && featString.Length > 0)
                {
                    text += " (" + featString + ")";
                }



                blocks.CreateHeader(text);
            }
            else
            {
                if (featString != null && featString.Length > 0)
                {
                    blocks.AppendEscapedTag("p", "altheader", featString);
                }
            }

            blocks.AppendOpenTag("p");

            blocks.CreateItemIfNotNull(null, feat.Summary);
            if (feat.Prerequistites != null)
            {
                blocks.CreateItemIfNotNull("Prerequisitites: ", feat.Prerequistites.Trim(new char[] { '-' }));
            }
            blocks.CreateItemIfNotNull("Benefit: ", feat.Benefit);
            blocks.CreateItemIfNotNull("Normal: ", feat.Normal);
            blocks.CreateItemIfNotNull("Special: ", feat.Special);

            if (feat.Source != "Pathfinder Core Rulebook")
            {
                blocks.CreateItemIfNotNull("Source: ", SourceInfo.GetSource(feat.Source));
            }



            blocks.AppendCloseTag("p");
            blocks.CreateHtmlFooter();


            return(blocks.ToString());
        }
Пример #8
0
        public List <Block> CreateBlocks(Rule rule, bool showTitle)
        {
            List <Block> blocks = new List <Block>();


            string name = rule.Name;

            string extraText = "";

            if (rule.AbilityType != null && rule.AbilityType.Length > 0)
            {
                extraText += "(" + rule.AbilityType + ")";
            }

            if (rule.Type == "Skills")
            {
                extraText += "(" + rule.Ability + (rule.Untrained ? "" : "; Trained Only") + ")";
            }

            if (extraText.Length > 0)
            {
                name = name + " " + extraText;
            }

            if (showTitle)
            {
                if (NotNullString(rule.Subtype))
                {
                    blocks.Add(CreateHeaderParagraph(name, rule.Subtype));
                }
                else
                {
                    blocks.Add(CreateHeaderParagraph(name));
                }
            }



            string detailsText = rule.Details;

            if (detailsText == null)
            {
                detailsText = "";
            }

            detailsText = Regex.Replace(detailsText, "&mdash;|&ndash;", "­–");
            detailsText = Regex.Replace(detailsText, "\t", "");
            detailsText = Regex.Replace(detailsText, "&hellip;", "...");


            if (detailsText.Length <= 2 || detailsText.Substring(0, 2) != "<p")
            {
                detailsText = "<p>" + detailsText + "</p>";
            }
            else
            {
                detailsText = detailsText.Replace("\n", "");
                detailsText = detailsText.Replace("\r", "");
            }


            blocks.AddRange(CreateFlowFromDescription(detailsText));


            Paragraph details = new Paragraph();

            if (showTitle)
            {
                details.Margin = new Thickness(0, 2, 0, 0);
            }
            else
            {
                if (rule.Subtype != null)
                {
                    extraText = rule.Subtype + " " + extraText;
                }

                details.Inlines.Add(new Italic(new Run(extraText)));
                details.Inlines.Add(new LineBreak());
            }

            if (SourceInfo.GetSourceType(rule.Source) != SourceType.Core)
            {
                CreateItemIfNotNull(details.Inlines, "Source: ", SourceInfo.GetSource(rule.Source));
            }

            CreateItemIfNotNull(details.Inlines, "Format: ", true, rule.Format, "; ", false);
            CreateItemIfNotNull(details.Inlines, "Location: ", true, rule.Location, ".", true);
            CreateItemIfNotNull(details.Inlines, "Format: ", true, rule.Format2, "; ", false);
            CreateItemIfNotNull(details.Inlines, "Location: ", true, rule.Location2, ".", true);


            blocks.Add(details);

            return(blocks);
        }
Пример #9
0
        public static String CreateHtml(MagicItem item, bool showTitle)
        {
            StringBuilder blocks = new StringBuilder();

            blocks.CreateHtmlHeader();

            if (showTitle)
            {
                blocks.CreateHeader(item.Name, item.Group);
            }


            /*Paragraph details = new Paragraph();
             * details.Margin = new Thickness(0, 2, 0, 0);*/

            blocks.AppendOpenTag("p");
            blocks.CreateItemIfNotNull("Aura ", true, item.Aura, " ", false);
            blocks.CreateItemIfNotNull("[", false, item.AuraStrength, "]; ", false);
            blocks.CreateItemIfNotNull("CL ", true, item.CL.PastTense(), "", true);
            blocks.CreateItemIfNotNull("Slot ", true, item.Slot, "; ", false);
            blocks.CreateItemIfNotNull("Price ", true, item.Price, "; ", false);
            blocks.CreateItemIfNotNull("Weight ", true, item.Weight, "", true);
            blocks.AppendCloseTag("p");



            if (!String.IsNullOrEmpty(item.DescHTML) || !String.IsNullOrEmpty(item.Description))
            {
                blocks.CreateSectionHeader("DESCRIPTION");

                if (!String.IsNullOrEmpty(item.DescHTML) && item.DescHTML != "NULL")
                {
                    blocks.AppendOpenTagWithClass("p", "description");
                    blocks.Append(item.DescHTML);
                    blocks.AppendCloseTag("p");
                }
                else if (item.Description != "NULL")
                {
                    blocks.AppendOpenTagWithClass("p", "description");

                    blocks.CreateItemIfNotNull(null, true, item.Description, null, true);


                    blocks.AppendCloseTag("p");
                }
            }

            if (item.Requirements != null && item.Requirements.Length > 0 &&
                item.Cost != null && item.Cost.Length > 0)
            {
                blocks.CreateSectionHeader("CONSTRUCTION");


                blocks.AppendOpenTag("p");
                blocks.CreateItemIfNotNull("Requirements ", true, item.Requirements, "; ", false);
                blocks.CreateItemIfNotNull("Cost ", true, item.Cost, "", true);
                blocks.AppendCloseTag("p");
            }

            if (!String.IsNullOrEmpty(item.Destruction) && item.Destruction != "NULL")
            {
                blocks.CreateSectionHeader("DESTRUCTION");


                blocks.AppendOpenTag("p");

                blocks.CreateItemIfNotNull(null, false, item.Destruction, null, true);

                blocks.AppendCloseTag("p");
            }

            if (SourceInfo.GetSourceType(item.Source) != SourceType.Core)
            {
                blocks.CreateItemIfNotNull("Source: ", SourceInfo.GetSource(item.Source));
            }

            blocks.CreateHtmlFooter();

            return(blocks.ToString());
        }