1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 06:56:10 +00:00

Spell abstract

This commit is contained in:
Yan Maniez 2018-07-01 22:14:07 +02:00
parent d2f99b15c5
commit 4274033d16
5 changed files with 6 additions and 73 deletions

View file

@ -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("(?<type>.*) de niveau (?<level>\\d).?(?<rituel>\\(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("(?<type>.*), (?<level>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 (?<level>\\d) - (?<type>.*?)\\w?(?<rituel>\\(ritual\\))?");
re = new Regex("^(?<level>\\d) - (?<type>.*?)\\s?(?<rituel>\\(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; }
}
}

View file

@ -7,7 +7,7 @@ namespace AideDeJeuLib.Spells
{
public class SpellHD : Spell
{
public new string LevelType
public override string LevelType
{
get
{

View file

@ -7,7 +7,7 @@ namespace AideDeJeuLib.Spells
{
public class SpellVO : Spell
{
public new string LevelType
public override string LevelType
{
get
{

View file

@ -26,7 +26,7 @@ namespace AideDeJeu.Views
{
InitializeComponent();
var item = new Spell
var item = new SpellHD
{
Name = "",
NameVO = "",

View file

@ -17,7 +17,7 @@ namespace AideDeJeuWeb.Controllers
{
//var items = AideDeJeu.Tools.Helpers.GetResourceObject<IEnumerable<Spell>>("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<SpellHD>(md);
var fitems = items.Where(it => it.Source.Contains(classe)).OrderBy(it => it.Level).ThenBy(it => it.Name);