mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-11-04 01:00:23 +00:00 
			
		
		
		
	Ajout de la plupart des attributs d'un monstre
This commit is contained in:
		
							parent
							
								
									5f3ad39729
								
							
						
					
					
						commit
						aa88df78ad
					
				
					 6 changed files with 264 additions and 71 deletions
				
			
		| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
using System;
 | 
					using HtmlAgilityPack;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Globalization;
 | 
					using System.Globalization;
 | 
				
			||||||
using System.Text;
 | 
					using System.Text;
 | 
				
			||||||
| 
						 | 
					@ -31,4 +32,55 @@ namespace AideDeJeu.Tools
 | 
				
			||||||
            return null;
 | 
					            return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public class HtmlNodeToFormattedStringConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var node = value as HtmlNode;
 | 
				
			||||||
 | 
					            if (node != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
 | 
					                FormatedTextHelpers.HtmlNodeToFormatedString(node, fs);
 | 
				
			||||||
 | 
					                return fs;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public class HtmlNodesToFormattedStringConverter : IValueConverter
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            var nodes = value as IEnumerable<HtmlNode>;
 | 
				
			||||||
 | 
					            if (nodes != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
 | 
					                foreach (var node in nodes)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    FormatedTextHelpers.HtmlNodeToFormatedString(node, fs);
 | 
				
			||||||
 | 
					                    fs.Spans.Add(new Span() { Text = "\r\n" });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                return fs;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,9 +10,18 @@ namespace AideDeJeu.Tools
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public static class FormatedTextHelpers
 | 
					    public static class FormatedTextHelpers
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        public static void HtmlToFormatedString(HtmlNode parentNode, FormattedString fs, FontAttributes attributes = FontAttributes.None)
 | 
					        public static void HtmlNodesToFormatedString(HtmlNodeCollection nodes, FormattedString fs, FontAttributes attributes = FontAttributes.None)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            foreach (var node in parentNode.ChildNodes)
 | 
					            if (nodes != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                foreach (var node in nodes)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    HtmlNodeToFormatedString(node, fs, attributes);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static void HtmlNodeToFormatedString(HtmlNode node, FormattedString fs, FontAttributes attributes = FontAttributes.None)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (node.NodeType == HtmlNodeType.Text)
 | 
					            if (node.NodeType == HtmlNodeType.Text)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -34,19 +43,62 @@ namespace AideDeJeu.Tools
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else if (node.NodeType == HtmlNodeType.Element && node.Name == "strong")
 | 
					            else if (node.NodeType == HtmlNodeType.Element && node.Name == "strong")
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                    HtmlToFormatedString(node, fs, attributes | FontAttributes.Bold);
 | 
					                HtmlNodesToFormatedString(node.ChildNodes, fs, attributes | FontAttributes.Bold);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else if (node.NodeType == HtmlNodeType.Element && node.Name == "em")
 | 
					            else if (node.NodeType == HtmlNodeType.Element && node.Name == "em")
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                    HtmlToFormatedString(node, fs, attributes | FontAttributes.Italic);
 | 
					                HtmlNodesToFormatedString(node.ChildNodes, fs, attributes | FontAttributes.Italic);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            else if (node.NodeType == HtmlNodeType.Element)
 | 
					            else if (node.NodeType == HtmlNodeType.Element)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                    HtmlToFormatedString(node, fs, attributes);
 | 
					                HtmlNodesToFormatedString(node.ChildNodes, fs, attributes);
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //public static void HtmlToFormatedString(HtmlNode parentNode, FormattedString fs, FontAttributes attributes = FontAttributes.None)
 | 
				
			||||||
 | 
					        //{
 | 
				
			||||||
 | 
					        //    if (parentNode.NodeType == HtmlNodeType.Element)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					        //        foreach (var node in parentNode.ChildNodes)
 | 
				
			||||||
 | 
					        //        {
 | 
				
			||||||
 | 
					        //            if (node.NodeType == HtmlNodeType.Text)
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                var resname = "content";
 | 
				
			||||||
 | 
					        //                if (attributes.HasFlag(FontAttributes.Bold))
 | 
				
			||||||
 | 
					        //                {
 | 
				
			||||||
 | 
					        //                    resname += "bold";
 | 
				
			||||||
 | 
					        //                }
 | 
				
			||||||
 | 
					        //                if (attributes.HasFlag(FontAttributes.Italic))
 | 
				
			||||||
 | 
					        //                {
 | 
				
			||||||
 | 
					        //                    resname += "ital";
 | 
				
			||||||
 | 
					        //                }
 | 
				
			||||||
 | 
					        //                var fd = FontData.FromResource(resname);
 | 
				
			||||||
 | 
					        //                fs.Spans.Add(new Span() { FontFamily = fd.FontFamily, FontAttributes = attributes | fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor, Text = node.InnerText });
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            else if (node.NodeType == HtmlNodeType.Element && node.Name == "br")
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                fs.Spans.Add(new Span() { Text = "\r\n" });
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            else if (node.NodeType == HtmlNodeType.Element && node.Name == "strong")
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                HtmlToFormatedString(node, fs, attributes | FontAttributes.Bold);
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            else if (node.NodeType == HtmlNodeType.Element && node.Name == "em")
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                HtmlToFormatedString(node, fs, attributes | FontAttributes.Italic);
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //            else if (node.NodeType == HtmlNodeType.Element)
 | 
				
			||||||
 | 
					        //            {
 | 
				
			||||||
 | 
					        //                HtmlToFormatedString(node, fs, attributes);
 | 
				
			||||||
 | 
					        //            }
 | 
				
			||||||
 | 
					        //        }
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //    else if (parentNode.NodeType == HtmlNodeType.Text)
 | 
				
			||||||
 | 
					        //    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //    }
 | 
				
			||||||
 | 
					        //}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public class FontData
 | 
					        public class FontData
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            public double FontSize { get; set; }
 | 
					            public double FontSize { get; set; }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,6 +25,9 @@ namespace AideDeJeu.ViewModels
 | 
				
			||||||
                OnPropertyChanged(nameof(Speed));
 | 
					                OnPropertyChanged(nameof(Speed));
 | 
				
			||||||
                OnPropertyChanged(nameof(SavingThrows));
 | 
					                OnPropertyChanged(nameof(SavingThrows));
 | 
				
			||||||
                OnPropertyChanged(nameof(Skills));
 | 
					                OnPropertyChanged(nameof(Skills));
 | 
				
			||||||
 | 
					                OnPropertyChanged(nameof(DamageResistances));
 | 
				
			||||||
 | 
					                OnPropertyChanged(nameof(DamageImmunities));
 | 
				
			||||||
 | 
					                OnPropertyChanged(nameof(ConditionImmunities));
 | 
				
			||||||
                OnPropertyChanged(nameof(Senses));
 | 
					                OnPropertyChanged(nameof(Senses));
 | 
				
			||||||
                OnPropertyChanged(nameof(Languages));
 | 
					                OnPropertyChanged(nameof(Languages));
 | 
				
			||||||
                OnPropertyChanged(nameof(Challenge));
 | 
					                OnPropertyChanged(nameof(Challenge));
 | 
				
			||||||
| 
						 | 
					@ -84,7 +87,7 @@ namespace AideDeJeu.ViewModels
 | 
				
			||||||
                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
					                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
				
			||||||
                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
					                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
				
			||||||
                var fs = new FormattedString();
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = "Jets de sauvegarde : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = "Jets de sauvegarde ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = Item.SavingThrows, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = Item.SavingThrows, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
				
			||||||
                return fs;
 | 
					                return fs;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -97,12 +100,54 @@ namespace AideDeJeu.ViewModels
 | 
				
			||||||
                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
					                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
				
			||||||
                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
					                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
				
			||||||
                var fs = new FormattedString();
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = "Compétences : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = "Compétence ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = Item.Skills, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = Item.Skills, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
				
			||||||
                return fs;
 | 
					                return fs;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public FormattedString DamageImmunities
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
				
			||||||
 | 
					                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
				
			||||||
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
 | 
					                fs.Spans.Add(new Span() { Text = "Immunité contre les dégâts ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
				
			||||||
 | 
					                fs.Spans.Add(new Span() { Text = Item.DamageImmunities, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
				
			||||||
 | 
					                return fs;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public FormattedString ConditionImmunities
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
				
			||||||
 | 
					                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
				
			||||||
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
 | 
					                fs.Spans.Add(new Span() { Text = "Immunité contre les états ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
				
			||||||
 | 
					                fs.Spans.Add(new Span() { Text = Item.ConditionImmunities, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
				
			||||||
 | 
					                return fs;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public FormattedString DamageResistances
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            get
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
				
			||||||
 | 
					                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
				
			||||||
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
 | 
					                fs.Spans.Add(new Span() { Text = "Résistance aux dégâts ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
				
			||||||
 | 
					                fs.Spans.Add(new Span() { Text = Item.DamageResistances, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
				
			||||||
 | 
					                return fs;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public FormattedString Senses
 | 
					        public FormattedString Senses
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get
 | 
					            get
 | 
				
			||||||
| 
						 | 
					@ -110,7 +155,7 @@ namespace AideDeJeu.ViewModels
 | 
				
			||||||
                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
					                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
				
			||||||
                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
					                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
				
			||||||
                var fs = new FormattedString();
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = "Sens : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = "Sens ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = Item.Senses, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = Item.Senses, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
				
			||||||
                return fs;
 | 
					                return fs;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -123,7 +168,7 @@ namespace AideDeJeu.ViewModels
 | 
				
			||||||
                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
					                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
				
			||||||
                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
					                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
				
			||||||
                var fs = new FormattedString();
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = "Langues : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = "Langues ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = Item.Languages, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = Item.Languages, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
				
			||||||
                return fs;
 | 
					                return fs;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -136,12 +181,14 @@ namespace AideDeJeu.ViewModels
 | 
				
			||||||
                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
					                var fd = FormatedTextHelpers.FontData.FromResource("content");
 | 
				
			||||||
                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
					                var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
 | 
				
			||||||
                var fs = new FormattedString();
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = "Puissance : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = "Dangerosité ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
 | 
				
			||||||
                fs.Spans.Add(new Span() { Text = Item.Challenge, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
					                fs.Spans.Add(new Span() { Text = Item.Challenge, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
 | 
				
			||||||
                return fs;
 | 
					                return fs;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //public FormattedString Description
 | 
					        //public FormattedString Description
 | 
				
			||||||
        //{
 | 
					        //{
 | 
				
			||||||
        //    get
 | 
					        //    get
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ namespace AideDeJeu.ViewModels
 | 
				
			||||||
                var fs = new FormattedString();
 | 
					                var fs = new FormattedString();
 | 
				
			||||||
                if (Item?.DescriptionDiv != null)
 | 
					                if (Item?.DescriptionDiv != null)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    FormatedTextHelpers.HtmlToFormatedString(Item?.DescriptionDiv, fs, FontAttributes.None);
 | 
					                    FormatedTextHelpers.HtmlNodeToFormatedString(Item?.DescriptionDiv, fs, FontAttributes.None);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                return fs;
 | 
					                return fs;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,6 +8,8 @@
 | 
				
			||||||
    <ContentPage.Resources>
 | 
					    <ContentPage.Resources>
 | 
				
			||||||
        <ResourceDictionary>
 | 
					        <ResourceDictionary>
 | 
				
			||||||
            <tools:NullToFalseConverter x:Key="NullToFalseConverter" />
 | 
					            <tools:NullToFalseConverter x:Key="NullToFalseConverter" />
 | 
				
			||||||
 | 
					            <tools:HtmlNodeToFormattedStringConverter x:Key="HtmlNodeToFormattedStringConverter" />
 | 
				
			||||||
 | 
					            <tools:HtmlNodesToFormattedStringConverter x:Key="HtmlNodesToFormattedStringConverter" />
 | 
				
			||||||
        </ResourceDictionary>
 | 
					        </ResourceDictionary>
 | 
				
			||||||
    </ContentPage.Resources>
 | 
					    </ContentPage.Resources>
 | 
				
			||||||
    <ScrollView Orientation="Vertical" BackgroundColor="#fdf1dc">
 | 
					    <ScrollView Orientation="Vertical" BackgroundColor="#fdf1dc">
 | 
				
			||||||
| 
						 | 
					@ -15,9 +17,9 @@
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            <skia:SKCanvasView PaintSurface="PaintHeaderBar" HorizontalOptions="FillAndExpand" HeightRequest="8" />
 | 
					            <skia:SKCanvasView PaintSurface="PaintHeaderBar" HorizontalOptions="FillAndExpand" HeightRequest="8" />
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            <Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsubsection}" />
 | 
					            <Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsection}" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <Label Text=" " />
 | 
					            <!--<Label Text=" " />-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <Label FormattedText="{Binding TypeSizeAlignment}" />
 | 
					            <Label FormattedText="{Binding TypeSizeAlignment}" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +64,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <Label FormattedText="{Binding SavingThrows}" IsVisible="{Binding Item.SavingThrows, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
					            <Label FormattedText="{Binding SavingThrows}" IsVisible="{Binding Item.SavingThrows, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
            <Label FormattedText="{Binding Skills}" IsVisible="{Binding Item.Skills, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
					            <Label FormattedText="{Binding Skills}" IsVisible="{Binding Item.Skills, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
 | 
					            <Label FormattedText="{Binding DamageResistances}" IsVisible="{Binding Item.DamageResistances, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
 | 
					            <Label FormattedText="{Binding DamageImmunities}" IsVisible="{Binding Item.DamageImmunities, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
 | 
					            <Label FormattedText="{Binding ConditionImmunities}" IsVisible="{Binding Item.ConditionImmunities, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
            <Label FormattedText="{Binding Senses}" IsVisible="{Binding Item.Senses, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
					            <Label FormattedText="{Binding Senses}" IsVisible="{Binding Item.Senses, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
            <Label FormattedText="{Binding Languages}" IsVisible="{Binding Item.Languages, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
					            <Label FormattedText="{Binding Languages}" IsVisible="{Binding Item.Languages, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
            <!--<Label FormattedText="{Binding Power}" Style="{StaticResource Key=content}" />-->
 | 
					            <!--<Label FormattedText="{Binding Power}" Style="{StaticResource Key=content}" />-->
 | 
				
			||||||
| 
						 | 
					@ -69,14 +74,28 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
 | 
					            <skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <Label FormattedText="{Binding Item.SpecialFeatures, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <Label Text="Actions" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
 | 
				
			||||||
 | 
					            <Label FormattedText="{Binding Item.Actions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.Actions, Converter={StaticResource NullToFalseConverter}}" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <Label Text="Actions légendaires" Style="{StaticResource Key=subsubsection}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
 | 
				
			||||||
 | 
					            <Label FormattedText="{Binding Item.LegendaryActions, Converter={StaticResource HtmlNodesToFormattedStringConverter}}" IsVisible="{Binding Item.LegendaryActions, Converter={StaticResource NullToFalseConverter}}" />
 | 
				
			||||||
 | 
					            <!--<ListView ItemsSource="{Binding Item.SpecialFeatures}">
 | 
				
			||||||
 | 
					                <ListView.ItemTemplate>
 | 
				
			||||||
 | 
					                    <DataTemplate>
 | 
				
			||||||
 | 
					                        <Label BindingContext="{Binding}" FormattedText="{Binding Converter={StaticResource HtmlNodeToFormattedStringConverter}}" />
 | 
				
			||||||
 | 
					                    </DataTemplate>
 | 
				
			||||||
 | 
					                </ListView.ItemTemplate>
 | 
				
			||||||
 | 
					            </ListView>-->
 | 
				
			||||||
 | 
					            <skia:SKCanvasView PaintSurface="PaintHeaderBar" HorizontalOptions="FillAndExpand" HeightRequest="8" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <Label Text="{Binding Item.Description}" Style="{StaticResource Key=content}" />
 | 
					            <Label Text="{Binding Item.Description}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
            <Label Text="{Binding Item.Picture}" Style="{StaticResource Key=content}" />
 | 
					            <!--<Label Text="{Binding Item.Picture}" Style="{StaticResource Key=content}" />-->
 | 
				
			||||||
            <Label Text="{Binding Item.Legendary}" Style="{StaticResource Key=content}" />
 | 
					            <Label Text="{Binding Item.Legendary}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
            <Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
 | 
					            <Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <skia:SKCanvasView PaintSurface="PaintHeaderBar" HorizontalOptions="FillAndExpand" HeightRequest="8" />
 | 
					            <Image Source="{Binding Item.Picture}" />
 | 
				
			||||||
 | 
					 | 
				
			||||||
            <Image Source="{Binding Image}" />
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        </StackLayout>
 | 
					        </StackLayout>
 | 
				
			||||||
    </ScrollView>
 | 
					    </ScrollView>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,12 +28,19 @@ namespace AideDeJeuLib.Monsters
 | 
				
			||||||
        public string Charisma { get; set; }
 | 
					        public string Charisma { get; set; }
 | 
				
			||||||
        public string SavingThrows { get; set; }
 | 
					        public string SavingThrows { get; set; }
 | 
				
			||||||
        public string Skills { get; set; }
 | 
					        public string Skills { get; set; }
 | 
				
			||||||
 | 
					        public string DamageImmunities { get; set; }
 | 
				
			||||||
 | 
					        public string ConditionImmunities { get; set; }
 | 
				
			||||||
 | 
					        public string DamageResistances { get; set; }
 | 
				
			||||||
        public string Senses { get; set; }
 | 
					        public string Senses { get; set; }
 | 
				
			||||||
        public string Languages { get; set; }
 | 
					        public string Languages { get; set; }
 | 
				
			||||||
        public string Challenge { get; set; }
 | 
					        public string Challenge { get; set; }
 | 
				
			||||||
        public string Description { get; set; }
 | 
					        public string Description { get; set; }
 | 
				
			||||||
        public string Picture { get; set; }
 | 
					        public string Picture { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public List<HtmlNode> SpecialFeatures { get; set; }
 | 
				
			||||||
 | 
					        public List<HtmlNode> Actions { get; set; }
 | 
				
			||||||
 | 
					        public List<HtmlNode> LegendaryActions { get; set; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static Monster FromHtml(HtmlNode divBloc)
 | 
					        public static Monster FromHtml(HtmlNode divBloc)
 | 
				
			||||||
| 
						 | 
					@ -66,51 +73,67 @@ namespace AideDeJeuLib.Monsters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            monster.SavingThrows = divRed?.SelectSingleNode("strong[contains(text(),'Jets de sauvegarde')]")?.NextSibling?.InnerText;
 | 
					            monster.SavingThrows = divRed?.SelectSingleNode("strong[contains(text(),'Jets de sauvegarde')]")?.NextSibling?.InnerText;
 | 
				
			||||||
            monster.Skills = divRed?.SelectSingleNode("strong[contains(text(),'Compétences')]")?.NextSibling?.InnerText;
 | 
					            monster.Skills = divRed?.SelectSingleNode("strong[contains(text(),'Compétences')]")?.NextSibling?.InnerText;
 | 
				
			||||||
 | 
					            monster.DamageResistances = divRed?.SelectSingleNode("strong[contains(text(),'Résistances aux dégâts')]")?.NextSibling?.InnerText;
 | 
				
			||||||
 | 
					            monster.DamageImmunities = divRed?.SelectSingleNode("strong[contains(text(),'Immunités aux dégâts')]")?.NextSibling?.InnerText;
 | 
				
			||||||
 | 
					            monster.ConditionImmunities = divRed?.SelectSingleNode("strong[contains(text(),'Immunités aux conditions')]")?.NextSibling?.InnerText;
 | 
				
			||||||
            monster.Senses = divRed?.SelectSingleNode("strong[contains(text(),'Sens')]")?.NextSibling?.InnerText;
 | 
					            monster.Senses = divRed?.SelectSingleNode("strong[contains(text(),'Sens')]")?.NextSibling?.InnerText;
 | 
				
			||||||
            monster.Languages = divRed?.SelectSingleNode("strong[contains(text(),'Langues')]")?.NextSibling?.InnerText;
 | 
					            monster.Languages = divRed?.SelectSingleNode("strong[contains(text(),'Langues')]")?.NextSibling?.InnerText;
 | 
				
			||||||
            monster.Power = divRed?.SelectSingleNode("strong[contains(text(),'Puissance')]")?.NextSibling?.InnerText;
 | 
					            monster.Challenge = divRed?.SelectSingleNode("strong[contains(text(),'Puissance')]")?.NextSibling?.InnerText;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            List<string> actions = new List<string>();
 | 
					            List<HtmlNode> nodes = new List<HtmlNode>();
 | 
				
			||||||
            List<string> beforeActions = null;
 | 
					            List<HtmlNode> specialFeatures = null;
 | 
				
			||||||
            List<string> commonActions = null;
 | 
					            List<HtmlNode> actions = null;
 | 
				
			||||||
            List<string> legendaryActions = null;
 | 
					            List<HtmlNode> legendaryActions = null;
 | 
				
			||||||
            var p = divSansSerif.SelectSingleNode("p");
 | 
					            var node = divSansSerif.SelectSingleNode("p");
 | 
				
			||||||
            while(p != null)
 | 
					            while(node != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if(p.NodeType == HtmlNodeType.Element && p.Name == "p")
 | 
					                if(node.NodeType == HtmlNodeType.Element && node.Name == "div")
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    actions.Add(p.InnerText);
 | 
					                    if(node.InnerText == "ACTIONS")
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					                        specialFeatures = nodes;
 | 
				
			||||||
 | 
					                        nodes = new List<HtmlNode>();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                else if(p.NodeType == HtmlNodeType.Element && p.Name == "div")
 | 
					                    else if (node.InnerText == "ACTIONS LÉGENDAIRES")
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                    if(p.InnerText == "ACTIONS")
 | 
					                        actions = nodes;
 | 
				
			||||||
                    {
 | 
					                        nodes = new List<HtmlNode>();
 | 
				
			||||||
                        beforeActions = actions;
 | 
					 | 
				
			||||||
                        actions = new List<string>();
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    else if (p.InnerText == "ACTIONS LÉGENDAIRES")
 | 
					 | 
				
			||||||
                    {
 | 
					 | 
				
			||||||
                        commonActions = actions;
 | 
					 | 
				
			||||||
                        actions = new List<string>();
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                p = p.NextSibling;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            if(commonActions == null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                if(beforeActions == null)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    beforeActions = actions;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    commonActions = actions;
 | 
					 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                legendaryActions = actions;
 | 
					                    nodes.Add(node);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                node = node.NextSibling;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(actions == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                if(specialFeatures == null)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    specialFeatures = nodes;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    actions = nodes;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                legendaryActions = nodes;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            monster.SpecialFeatures = specialFeatures;
 | 
				
			||||||
 | 
					            monster.Actions = actions;
 | 
				
			||||||
 | 
					            monster.LegendaryActions = legendaryActions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var divDescription = divBloc?.SelectSingleNode("div[contains(@class,'description')]");
 | 
				
			||||||
 | 
					            monster.Description = divDescription?.InnerText;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var divSource = divBloc?.SelectSingleNode("div[contains(@class,'source')]");
 | 
				
			||||||
 | 
					            monster.Source = divSource?.InnerText;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            var img = divBloc?.SelectSingleNode("div[contains(@class,'center')]/img[contains(@class,'picture')]");
 | 
				
			||||||
 | 
					            monster.Picture = img?.GetAttributeValue("src", null);
 | 
				
			||||||
            return monster;
 | 
					            return monster;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue