From 4274033d1680add3cf92acd7105514b0d6ba4052 Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Sun, 1 Jul 2018 22:14:07 +0200 Subject: [PATCH] Spell abstract --- AideDeJeu/AideDeJeu/Models/Spells/Spell.cs | 71 +------------------ AideDeJeu/AideDeJeu/Models/Spells/SpellHD.cs | 2 +- AideDeJeu/AideDeJeu/Models/Spells/SpellVO.cs | 2 +- .../AideDeJeu/Views/SpellDetailPage.xaml.cs | 2 +- .../Controllers/ValuesController.cs | 2 +- 5 files changed, 6 insertions(+), 73 deletions(-) diff --git a/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs b/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs index 53422a57..bcedfec3 100644 --- a/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs +++ b/AideDeJeu/AideDeJeu/Models/Spells/Spell.cs @@ -7,58 +7,8 @@ using System.Xml.Serialization; namespace AideDeJeuLib.Spells { - public class Spell : Item + public abstract class Spell : Item { - public string LevelType - { - get - { - if (int.Parse(Level) > 0) - { - if (string.IsNullOrEmpty(Rituel)) - { - return $"{Type} de niveau {Level}"; - } - else - { - return $"{Type} de niveau {Level} {Rituel}"; - } - } - else - { - return $"{Type}, tour de magie"; - } - } - 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) - (?.*?)\\w?(?\\(ritual\\))?"); - re = new Regex("^(?\\d) - (?.*?)\\s?(?\\(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; } @@ -68,25 +18,8 @@ namespace AideDeJeuLib.Spells public string Components { get; set; } public string Duration { get; set; } public string DescriptionHtml { get; set; } - public string Source { get; set; } - public override string Markdown - { - get - { - return - $"# {Name}\n" + - $"{NameVO}\n" + - $"_{LevelType}_\n" + - $"**Temps d'incantation :** {CastingTime}\n" + - $"**Portée :** {Range}\n" + - $"**Composantes :** {Components}\n" + - $"**Durée :** {Duration}\n\n" + - $"{DescriptionHtml}\n\n" + - $"**Source :** {Source}"; - - } - } + public abstract string LevelType { get; set; } } } diff --git a/AideDeJeu/AideDeJeu/Models/Spells/SpellHD.cs b/AideDeJeu/AideDeJeu/Models/Spells/SpellHD.cs index ad7eab44..debf174c 100644 --- a/AideDeJeu/AideDeJeu/Models/Spells/SpellHD.cs +++ b/AideDeJeu/AideDeJeu/Models/Spells/SpellHD.cs @@ -7,7 +7,7 @@ namespace AideDeJeuLib.Spells { public class SpellHD : Spell { - public new string LevelType + public override string LevelType { get { diff --git a/AideDeJeu/AideDeJeu/Models/Spells/SpellVO.cs b/AideDeJeu/AideDeJeu/Models/Spells/SpellVO.cs index 3550ee15..92db8d15 100644 --- a/AideDeJeu/AideDeJeu/Models/Spells/SpellVO.cs +++ b/AideDeJeu/AideDeJeu/Models/Spells/SpellVO.cs @@ -7,7 +7,7 @@ namespace AideDeJeuLib.Spells { public class SpellVO : Spell { - public new string LevelType + public override string LevelType { get { diff --git a/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs b/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs index 15872f21..8385ebe2 100644 --- a/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs +++ b/AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs @@ -26,7 +26,7 @@ namespace AideDeJeu.Views { InitializeComponent(); - var item = new Spell + var item = new SpellHD { Name = "", NameVO = "", diff --git a/AideDeJeu/AideDeJeuWeb/Controllers/ValuesController.cs b/AideDeJeu/AideDeJeuWeb/Controllers/ValuesController.cs index 03a3d7d4..7535bb92 100644 --- a/AideDeJeu/AideDeJeuWeb/Controllers/ValuesController.cs +++ b/AideDeJeu/AideDeJeuWeb/Controllers/ValuesController.cs @@ -17,7 +17,7 @@ namespace AideDeJeuWeb.Controllers { //var items = AideDeJeu.Tools.Helpers.GetResourceObject>("AideDeJeu.Data.spells_vf.json"); var md = await AideDeJeu.Tools.Helpers.GetResourceStringAsync("AideDeJeu.Data.spells_hd.md"); - var items = AideDeJeu.Tools.MarkdownExtensions.MarkdownToSpells(md); + var items = AideDeJeu.Tools.MarkdownExtensions.MarkdownToSpells(md); var fitems = items.Where(it => it.Source.Contains(classe)).OrderBy(it => it.Level).ThenBy(it => it.Name);