From 751ed87c826181abaae8a9c12422354de8a7e248 Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Fri, 15 Jun 2018 23:46:28 +0200 Subject: [PATCH] Parsing level / type --- AideDeJeu/AideDeJeu/Models/Spells/Spell.cs | 36 ++++++++++++++++++- .../AideDeJeu/Tools/FormatedTextHelpers.cs | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs b/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs index 1ece3e1d..0b0fde02 100644 --- a/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs +++ b/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs @@ -9,7 +9,41 @@ namespace AideDeJeuLib.Spells { public class Spell : Item { - public string LevelType { get; set; } + public string LevelType + { + get + { + return string.Format("{0} - {1}", this.Level, this.Type); + } + set + { + var re = new Regex("(?.*) de niveau (?\\d).?(?\\(rituel\\))?"); + var match = re.Match(value); + this.Type = match.Groups["type"].Value; + this.Level = match.Groups["level"].Value; + this.Rituel = match.Groups["rituel"].Value; + if (string.IsNullOrEmpty(this.Type)) + { + re = new Regex("(?.*), (?tour de magie)"); + match = re.Match(value); + if(match.Groups["level"].Value == "tour de magie") + { + this.Type = match.Groups["type"].Value; + this.Level = "0"; // match.Groups["level"].Value; + this.Rituel = match.Groups["rituel"].Value; + } + else + { + System.Diagnostics.Debug.WriteLine(value); + re = new Regex("level (?\\d) - (?.*?) ?(?\\(ritual\\))?"); + match = re.Match(value); + this.Type = match.Groups["type"].Value; + this.Level = match.Groups["level"].Value; + this.Rituel = match.Groups["rituel"].Value; + } + } + } + } public string Level { get; set; } public string Type { get; set; } public string Concentration { get; set; } diff --git a/AideDeJeu/AideDeJeu/Tools/FormatedTextHelpers.cs b/AideDeJeu/AideDeJeu/Tools/FormatedTextHelpers.cs index 0fb4caa4..aca4a902 100644 --- a/AideDeJeu/AideDeJeu/Tools/FormatedTextHelpers.cs +++ b/AideDeJeu/AideDeJeu/Tools/FormatedTextHelpers.cs @@ -54,6 +54,7 @@ namespace AideDeJeu.Tools { HtmlNodesToFormatedString(node.ChildNodes, fs, attributes); fs.Spans.Add(new Span() { Text = "\r\n" }); + fs.Spans.Add(new Span() { Text = "\r\n" }); } else if (node.NodeType == XmlNodeType.Element) {