Exemple #1
0
        public IEnumerable <FrameworkElement> CreatePrintView(ITemplate template)
        {
            bool hasRankModifier         = template.CombatConflictRank != 0 || template.IntrigueConflictRank != 0;
            bool hasRingModifier         = template.Air != 0 || template.Earth != 0 || template.Fire != 0 || template.Water != 0 || template.Void != 0;
            bool hasSkillModifier        = template.Artisan != 0 || template.Martial != 0 || template.Scholar != 0 || template.Social != 0 || template.Trade != 0;
            bool hasAdvantageModifier    = template.SuggestedAdvantages.Any() && template.AdvantageRemplacements != 0;
            bool hasDisadvantageModifier = template.SuggestedDisadvantages.Any() && template.DisadvantageRemplacements != 0;
            bool hasAbilityModifier      = template.AbilityTypes.Any() && template.AbilityAdditions != 0;
            bool hasDemeanorModifier     = template.SuggestedDemeanors.Any();

            var grid = CreateGrid(BoolHelpers.CountTrue(hasRankModifier, hasRingModifier, hasSkillModifier, hasAdvantageModifier,
                                                        hasDisadvantageModifier, hasAbilityModifier, hasDemeanorModifier) + 1);

            var name = CreateObjectName(template.Name.Trim());

            Grid.SetRow(name, 0);
            grid.Children.Add(name);

            int row = 1;

            if (hasRankModifier)
            {
                var rankMods = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                rankMods.Inlines.Add(new Run("Conflict Rank: ")
                {
                    FontWeight = FontWeights.Bold
                });
                rankMods.Inlines.Add(FormatModifierList(new List <(string name, int mod)>
                {
                    ("Combat", template.CombatConflictRank),
                    ("Intrigue", template.IntrigueConflictRank)
                }));

                Grid.SetRow(rankMods, row);
                grid.Children.Add(rankMods);
                row++;
            }

            if (hasRingModifier)
            {
                var ringMods = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                ringMods.Inlines.Add(new Run("Rings: ")
                {
                    FontWeight = FontWeights.Bold
                });
                ringMods.Inlines.Add(FormatModifierList(new List <(string name, int mod)>
                {
                    (Ring.Air.ToString(), template.Air),
                    (Ring.Earth.ToString(), template.Earth),
                    (Ring.Fire.ToString(), template.Fire),
                    (Ring.Water.ToString(), template.Water),
                    (Ring.Void.ToString(), template.Void),
                }));

                Grid.SetRow(ringMods, row);
                grid.Children.Add(ringMods);
                row++;
            }

            if (hasSkillModifier)
            {
                var skillMods = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                skillMods.Inlines.Add(new Run("Skills: ")
                {
                    FontWeight = FontWeights.Bold
                });
                skillMods.Inlines.Add(FormatModifierList(new List <(string name, int mod)>
                {
                    (SkillGroup.Artisan.ToString(), template.Artisan),
                    (SkillGroup.Martial.ToString(), template.Martial),
                    (SkillGroup.Scholar.ToString(), template.Scholar),
                    (SkillGroup.Social.ToString(), template.Social),
                    (SkillGroup.Trade.ToString(), template.Trade),
                }));

                Grid.SetRow(skillMods, row);
                grid.Children.Add(skillMods);
                row++;
            }

            if (hasAdvantageModifier)
            {
                var advantageMods = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                advantageMods.Inlines.Add(new Run("Advantages (add/replace 0-" + template.AdvantageRemplacements + "): ")
                {
                    FontWeight = FontWeights.Bold
                });
                foreach (var inline in FormatTraitList(template.SuggestedAdvantages))
                {
                    advantageMods.Inlines.Add(inline);
                }

                Grid.SetRow(advantageMods, row);
                grid.Children.Add(advantageMods);
                row++;
            }

            if (hasDisadvantageModifier)
            {
                var disadvantageMods = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                disadvantageMods.Inlines.Add(new Run("Disadvantages (add/replace 0-" + template.DisadvantageRemplacements + "): ")
                {
                    FontWeight = FontWeights.Bold
                });
                foreach (var inline in FormatTraitList(template.SuggestedDisadvantages))
                {
                    disadvantageMods.Inlines.Add(inline);
                }

                Grid.SetRow(disadvantageMods, row);
                grid.Children.Add(disadvantageMods);
                row++;
            }

            if (hasAbilityModifier)
            {
                var abilityMods = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                abilityMods.Inlines.Add(new Run("Abilities (add 0-" + template.AbilityAdditions + "): ")
                {
                    FontWeight = FontWeights.Bold
                });
                abilityMods.Inlines.Add(string.Join(", ", template.AbilityTypes.Select(at => at.ToString())));

                Grid.SetRow(abilityMods, row);
                grid.Children.Add(abilityMods);
                row++;
            }

            if (hasDemeanorModifier)
            {
                var demeanorMods = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                demeanorMods.Inlines.Add(new Run("Demeanor (replace 1): ")
                {
                    FontWeight = FontWeights.Bold
                });
                demeanorMods.Inlines.Add(string.Join(", ", template.SuggestedDemeanors.Select(d => d.Name.Trim()).OrderBy(s => s)));

                Grid.SetRow(demeanorMods, row);
                grid.Children.Add(demeanorMods);
                row++;
            }

            return(new List <FrameworkElement> {
                grid
            });
        }
Exemple #2
0
        public IEnumerable <FrameworkElement> CreatePrintView(IDemeanor demeanor)
        {
            bool hasModifier    = demeanor.Air != 0 || demeanor.Earth != 0 || demeanor.Fire != 0 || demeanor.Water != 0 || demeanor.Void != 0;
            bool hasUnmasking   = !string.IsNullOrWhiteSpace(demeanor.Unmasking);
            bool hasDescription = !string.IsNullOrWhiteSpace(demeanor.Description);

            var grid = CreateGrid(BoolHelpers.CountTrue(hasModifier, hasUnmasking, hasDescription) + 1);

            int currentRow = 0;
            var name       = CreateObjectName(demeanor.Name.Trim());

            Grid.SetRow(name, currentRow);
            grid.Children.Add(name);
            currentRow++;

            if (hasDescription)
            {
                var description = new TextBlock
                {
                    Text          = demeanor.Description.Trim(),
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 4, 0, 0)
                };
                Grid.SetRow(description, currentRow);
                grid.Children.Add(description);
                currentRow++;
            }

            if (hasModifier)
            {
                var mods = new List <(Ring ring, int mod)>();
                mods.Add((Ring.Air, demeanor.Air));
                mods.Add((Ring.Earth, demeanor.Earth));
                mods.Add((Ring.Fire, demeanor.Fire));
                mods.Add((Ring.Water, demeanor.Water));
                mods.Add((Ring.Void, demeanor.Void));

                mods.Sort((t1, t2) =>
                {
                    int returnValue = t2.mod.CompareTo(t1.mod);
                    if (returnValue == 0)
                    {
                        returnValue = t1.ring.CompareTo(t2.ring);
                    }

                    return(returnValue);
                });

                string modText   = string.Join(", ", mods.Where(t => t.mod != 0).Select(t => GetModifierString(t.ring, t.mod)));
                var    modifiers = new TextBlock
                {
                    TextWrapping  = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Justify,
                    Margin        = new Thickness(0, 3, 0, 0)
                };
                modifiers.Inlines.Add(new Run("Social Check TN Modifers: ")
                {
                    FontWeight = FontWeights.Bold
                });
                modifiers.Inlines.Add(modText);

                Grid.SetRow(modifiers, currentRow);
                grid.Children.Add(modifiers);
                currentRow++;
            }

            if (hasUnmasking)
            {
                var unmasking = new TextBlock
                {
                    TextWrapping = TextWrapping.Wrap,
                    Margin       = new Thickness(0, 3, 0, 0)
                };
                unmasking.Inlines.Add(new Run("Common Unmasking: ")
                {
                    FontWeight = FontWeights.Bold
                });
                unmasking.Inlines.Add(demeanor.Unmasking);

                Grid.SetRow(unmasking, currentRow);
                grid.Children.Add(unmasking);
            }

            DoMeasure(grid);
            return(new List <FrameworkElement> {
                grid
            });
        }