mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-11-02 00:16:07 +00:00
Nettoyage
This commit is contained in:
parent
dbdb55d732
commit
1f90de960e
9 changed files with 2 additions and 731 deletions
|
|
@ -133,7 +133,7 @@ namespace AideDeJeuLib.Cards
|
|||
var contents = new List<CardContent>();
|
||||
contents.AddRange(new CardContent[]
|
||||
{
|
||||
new SubtitleCardContent(spell.LevelType),
|
||||
//new SubtitleCardContent(spell.LevelType),
|
||||
new RuleCardContent(),
|
||||
new PropertyCardContent("Durée d'incantation", spell.CastingTime),
|
||||
new PropertyCardContent("Portée", spell.Range),
|
||||
|
|
|
|||
|
|
@ -35,288 +35,5 @@ namespace AideDeJeuLib
|
|||
public string Senses { get; set; }
|
||||
public string Languages { get; set; }
|
||||
public string Challenge { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public IEnumerable<string> SpecialFeatures { get; set; }
|
||||
public IEnumerable<string> Actions { get; set; }
|
||||
public IEnumerable<string> Reactions { get; set; }
|
||||
public IEnumerable<string> LegendaryActions { get; set; }
|
||||
|
||||
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
{
|
||||
List<string> features = null;
|
||||
//List<string> specialFeatures = null;
|
||||
//List<string> actions = null;
|
||||
//List<string> reactions = null;
|
||||
//List<string> legendaryActions = null;
|
||||
enumerator.MoveNext();
|
||||
//try
|
||||
//{
|
||||
while (enumerator.Current != null)
|
||||
{
|
||||
var block = enumerator.Current;
|
||||
//Debug.WriteLine(block.GetType());
|
||||
//DumpBlock(block);
|
||||
if (block is Markdig.Syntax.HeadingBlock)
|
||||
{
|
||||
var headingBlock = block as Markdig.Syntax.HeadingBlock;
|
||||
//DumpHeadingBlock(headingBlock);
|
||||
if (headingBlock.HeaderChar == '#' && headingBlock.Level == 1)
|
||||
{
|
||||
if (this.Name != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.Name = headingBlock.Inline.ToMarkdownString();
|
||||
//Console.WriteLine(spell.Name);
|
||||
}
|
||||
if (headingBlock.HeaderChar == '#' && headingBlock.Level == 2)
|
||||
{
|
||||
switch (headingBlock.Inline.ToMarkdownString())
|
||||
{
|
||||
case "Capacités":
|
||||
case "Special Features":
|
||||
SpecialFeatures = features = new List<string>();
|
||||
break;
|
||||
case "Actions":
|
||||
Actions = features = new List<string>();
|
||||
break;
|
||||
case "Réaction":
|
||||
case "Réactions":
|
||||
case "Reaction":
|
||||
case "Reactions":
|
||||
Reactions = features = new List<string>();
|
||||
break;
|
||||
case "Actions légendaires":
|
||||
case "Legendary Actions":
|
||||
LegendaryActions = features = new List<string>();
|
||||
break;
|
||||
default:
|
||||
App.Current.MainPage.DisplayAlert("Erreur de parsing", headingBlock.Inline.ToMarkdownString(), "OK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (block is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
if (block.IsNewItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraphBlock = block as Markdig.Syntax.ParagraphBlock;
|
||||
features?.Add(paragraphBlock.ToMarkdownString());
|
||||
////DumpParagraphBlock(paragraphBlock);
|
||||
//Console.WriteLine(paragraphBlock.IsBreakable);
|
||||
//spell.DescriptionHtml += paragraphBlock.Inline.ToContainerString();
|
||||
//if(paragraphBlock.IsBreakable)
|
||||
//{
|
||||
// spell.DescriptionHtml += "\n";
|
||||
//}
|
||||
}
|
||||
else if (block is Markdig.Syntax.ListBlock)
|
||||
{
|
||||
var listBlock = block as Markdig.Syntax.ListBlock;
|
||||
//DumpListBlock(listBlock);
|
||||
if (listBlock.BulletType == '-')
|
||||
{
|
||||
this.Source = "";
|
||||
foreach (var inblock in listBlock)
|
||||
{
|
||||
//DumpBlock(inblock);
|
||||
var regex = new Regex("(?<key>.*?): (?<value>.*)");
|
||||
if (inblock is Markdig.Syntax.ListItemBlock)
|
||||
{
|
||||
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
|
||||
foreach (var ininblock in listItemBlock)
|
||||
{
|
||||
//DumpBlock(ininblock);
|
||||
if (ininblock is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
|
||||
//DumpParagraphBlock(paragraphBlock);
|
||||
var str = paragraphBlock.Inline.ToMarkdownString();
|
||||
|
||||
var properties = new List<Tuple<string, System.Action<Monster, string>>>()
|
||||
{
|
||||
new Tuple<string, Action<Monster, string>>("**Classe d'armure** ", (m, s) => m.ArmorClass = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Points de vie** ", (m, s) => m.HitPoints = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Vitesse** ", (m, s) => m.Speed = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Résistance aux dégâts** ", (m, s) => m.DamageResistances = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Résistances aux dégâts** ", (m, s) => m.DamageResistances = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Résistance contre les dégâts** ", (m, s) => m.DamageResistances = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Résistances contre les dégâts** ", (m, s) => m.DamageResistances = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité contre les dégâts** ", (m, s) => m.DamageImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité contre des dégâts** ", (m, s) => m.DamageImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité aux dégâts** ", (m, s) => m.DamageImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité à l'état** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunités à l'état** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité contre l'état** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité contre les états** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunités contre les états** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Vulnérabilité aux dégâts** ", (m, s) => m.DamageVulnerabilities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Vulnérabilité contre les dégâts** ", (m, s) => m.DamageVulnerabilities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Vulnérabilité** ", (m, s) => m.DamageVulnerabilities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Sens** ", (m, s) => m.Senses = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Langue** ", (m, s) => m.Languages = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Langues** ", (m, s) => m.Languages = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Dangerosité** ", (m, s) => m.Challenge = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Jets de sauvegarde** ", (m, s) => m.SavingThrows = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Jet de sauvegarde** ", (m, s) => m.SavingThrows = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Compétences** ", (m, s) => m.Skills = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Compétence** ", (m, s) => m.Skills = s),
|
||||
|
||||
new Tuple<string, Action<Monster, string>>("**Armor Class** ", (m, s) => m.ArmorClass = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Hit Points** ", (m, s) => m.HitPoints = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Speed** ", (m, s) => m.Speed = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Damage Resistance** ", (m, s) => m.DamageResistances = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Damage Resistances** ", (m, s) => m.DamageResistances = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Résistance contre les dégâts** ", (m, s) => m.DamageResistances = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Résistances contre les dégâts** ", (m, s) => m.DamageResistances = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Damage Immunities** ", (m, s) => m.DamageImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité contre des dégâts** ", (m, s) => m.DamageImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité aux dégâts** ", (m, s) => m.DamageImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Condition Immunities** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunités à l'état** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité contre l'état** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunité contre les états** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Immunités contre les états** ", (m, s) => m.ConditionImmunities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Damage Vulnerabilities** ", (m, s) => m.DamageVulnerabilities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Vulnérabilité contre les dégâts** ", (m, s) => m.DamageVulnerabilities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Vulnérabilité** ", (m, s) => m.DamageVulnerabilities = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Senses** ", (m, s) => m.Senses = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Languages** ", (m, s) => m.Languages = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Langues** ", (m, s) => m.Languages = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Challenge** ", (m, s) => m.Challenge = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Saving Throws** ", (m, s) => m.SavingThrows = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Jet de sauvegarde** ", (m, s) => m.SavingThrows = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Skills** ", (m, s) => m.Skills = s),
|
||||
new Tuple<string, Action<Monster, string>>("**Compétence** ", (m, s) => m.Skills = s),
|
||||
|
||||
new Tuple<string, Action<Monster, string>>("AltName: ", (m, s) => m.AltName = s),
|
||||
|
||||
new Tuple<string, Action<Monster, string>>("", (m,s) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(m.Alignment))
|
||||
{
|
||||
App.Current.MainPage.DisplayAlert("Erreur de parsing", s, "OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Assert(monster.Alignment == null, str);
|
||||
var regexx = new Regex("(?<type>.*) de taille (?<size>.*), (?<alignment>.*)");
|
||||
var matchh = regexx.Match(s);
|
||||
m.Alignment = matchh.Groups["alignment"].Value;
|
||||
m.Size = matchh.Groups["size"].Value;
|
||||
m.Type = matchh.Groups["type"].Value;
|
||||
if(string.IsNullOrEmpty(m.Alignment))
|
||||
{
|
||||
regexx = new Regex("(?<size>.*?) (?<type>.*?), (?<alignment>.*)");
|
||||
matchh = regexx.Match(s);
|
||||
m.Alignment = matchh.Groups["alignment"].Value;
|
||||
m.Size = matchh.Groups["size"].Value;
|
||||
m.Type = matchh.Groups["type"].Value;
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
if (str.StartsWith(property.Item1))
|
||||
{
|
||||
property.Item2.Invoke(this, str.Substring(property.Item1.Length));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DumpListItemBlock(inblock as Markdig.Syntax.ListItemBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var inblock in listBlock)
|
||||
{
|
||||
if (inblock is Markdig.Syntax.ListItemBlock)
|
||||
{
|
||||
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
|
||||
foreach (var ininblock in listItemBlock)
|
||||
{
|
||||
//DumpBlock(ininblock);
|
||||
if (ininblock is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
|
||||
features?.Add(listBlock.BulletType + " " + paragraphBlock.ToMarkdownString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (block is Markdig.Extensions.Tables.Table)
|
||||
{
|
||||
var tableBlock = block as Markdig.Extensions.Tables.Table;
|
||||
var table = tableBlock.ToTable();
|
||||
if (table.ContainsKey("FOR"))
|
||||
{
|
||||
this.Strength = table["FOR"].FirstOrDefault();
|
||||
this.Dexterity = table["DEX"].FirstOrDefault();
|
||||
this.Constitution = table["CON"].FirstOrDefault();
|
||||
this.Intelligence = table["INT"].FirstOrDefault();
|
||||
this.Wisdom = table["SAG"].FirstOrDefault();
|
||||
this.Charisma = table["CHA"].FirstOrDefault();
|
||||
}
|
||||
else if (table.ContainsKey("STR"))
|
||||
{
|
||||
this.Strength = table["STR"].FirstOrDefault();
|
||||
this.Dexterity = table["DEX"].FirstOrDefault();
|
||||
this.Constitution = table["CON"].FirstOrDefault();
|
||||
this.Intelligence = table["INT"].FirstOrDefault();
|
||||
this.Wisdom = table["WIS"].FirstOrDefault();
|
||||
this.Charisma = table["CHA"].FirstOrDefault();
|
||||
}
|
||||
//else
|
||||
//{
|
||||
features?.Add(tableBlock.ToMarkdownString());
|
||||
//}
|
||||
}
|
||||
else if (block is Markdig.Syntax.LinkReferenceDefinitionGroup)
|
||||
{
|
||||
|
||||
var linkReferenceDefinitionGroup = block as Markdig.Syntax.LinkReferenceDefinitionGroup;
|
||||
|
||||
foreach (var linkBlock in linkReferenceDefinitionGroup)
|
||||
{
|
||||
var linkReferenceDefinition = linkBlock as Markdig.Syntax.LinkReferenceDefinition;
|
||||
//linkReferenceDefinition.
|
||||
}
|
||||
}
|
||||
else if (block is Markdig.Syntax.LinkReferenceDefinition)
|
||||
{
|
||||
//Debug.WriteLine(block.GetType());
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.WriteLine(block.GetType());
|
||||
}
|
||||
enumerator.MoveNext();
|
||||
}
|
||||
//}
|
||||
//finally
|
||||
|
||||
////if (monster != null)
|
||||
//{
|
||||
// this.SpecialFeatures = specialFeatures;
|
||||
// this.Actions = actions;
|
||||
// this.Reactions = reactions;
|
||||
// this.LegendaryActions = legendaryActions;
|
||||
// //yield return monster;
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Markdig.Syntax;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class MonsterHD : Monster
|
||||
{
|
||||
//public override string Markdown
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return
|
||||
// $"# {Name}\n" +
|
||||
// $"{AltName}\n" +
|
||||
// $"{Type} de taille {Size}, {Alignment}\n" +
|
||||
// $"**Classe d'armure** {ArmorClass}\n" +
|
||||
// $"**Points de vie** {HitPoints}\n" +
|
||||
// $"**Vitesse** {Speed}\n\n" +
|
||||
// $"|FOR|DEX|CON|INT|SAG|CHA|\n" +
|
||||
// $"|---|---|---|---|---|---|\n" +
|
||||
// $"|{Strength}|{Dexterity}|{Constitution}|{Intelligence}|{Wisdom}|{Charisma}|\n\n" +
|
||||
// (Skills != null ? $"**Compétences** {Skills}\n" : "") +
|
||||
// (SavingThrows != null ? $"**Jets de sauvegarde** {SavingThrows}\n" : "") +
|
||||
// (DamageVulnerabilities != null ? $"**Vulnérabilité aux dégâts** {DamageVulnerabilities}\n" : "") +
|
||||
// (DamageImmunities != null ? $"**Immunité contre les dégâts** {DamageImmunities}\n" : "") +
|
||||
// (ConditionImmunities != null ? $"**Immunité contre les états** {ConditionImmunities}\n" : "") +
|
||||
// (DamageResistances != null ? $"**Résistance aux dégâts** {DamageResistances}\n" : "") +
|
||||
// $"**Sens** {Senses}\n" +
|
||||
// $"**Langues** {Languages}\n" +
|
||||
// $"**Dangerosité** {Challenge}\n\n" +
|
||||
// (SpecialFeatures != null ? $"## Capacités\n\n" + SpecialFeatures.Aggregate((s1, s2) => s1 + "\n\n" + s2) : "") +
|
||||
// (Actions != null ? $"## Actions\n\n" + Actions.Aggregate((s1, s2) => s1 + "\n\n" + s2) : "") +
|
||||
// (Reactions != null ? $"## Réactions\n\n" + Reactions.Aggregate((s1, s2) => s1 + "\n\n" + s2) : "") +
|
||||
// (LegendaryActions != null ? $"## Actions Légendaires\n\n" + LegendaryActions.Aggregate((s1, s2) => s1 + "\n\n" + s2) : "");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Markdig.Syntax;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class MonsterVO : Monster
|
||||
{
|
||||
//public override string Markdown
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return
|
||||
// $"# {Name}\n" +
|
||||
// $"{AltName}\n" +
|
||||
// $"{Size} {Type}, {Alignment}\n" +
|
||||
// $"**Armor Class** {ArmorClass}\n" +
|
||||
// $"**Hit Points** {HitPoints}\n" +
|
||||
// $"**Speed** {Speed}\n\n" +
|
||||
// $"|STR|DEX|CON|INT|WIS|CHA|\n" +
|
||||
// $"|---|---|---|---|---|---|\n" +
|
||||
// $"|{Strength}|{Dexterity}|{Constitution}|{Intelligence}|{Wisdom}|{Charisma}|\n\n" +
|
||||
// (Skills != null ? $"**Skills** {Skills}\n" : "") +
|
||||
// (SavingThrows != null ? $"**Saving Throws** {SavingThrows}\n" : "") +
|
||||
// (DamageVulnerabilities != null ? $"**Damage Vulnerabilities** {DamageVulnerabilities}\n" : "") +
|
||||
// (DamageImmunities != null ? $"**Damage Immunities** {DamageImmunities}\n" : "") +
|
||||
// (ConditionImmunities != null ? $"**Condition Immunities** {ConditionImmunities}\n" : "") +
|
||||
// (DamageResistances != null ? $"**Damage Resistances** {DamageResistances}\n" : "") +
|
||||
// $"**Senses** {Senses}\n" +
|
||||
// $"**Languages** {Languages}\n" +
|
||||
// $"**Challenge** {Challenge}\n\n" +
|
||||
// (SpecialFeatures != null ? $"## Special Features\n\n" + SpecialFeatures.Aggregate((s1, s2) => s1 + "\n\n" + s2) : "") +
|
||||
// (Actions != null ? $"## Actions\n\n" + Actions.Aggregate((s1, s2) => s1 + "\n\n" + s2) : "") +
|
||||
// (Reactions != null ? $"## Reactions\n\n" + Reactions.Aggregate((s1, s2) => s1 + "\n\n" + s2) : "") +
|
||||
// (LegendaryActions != null ? $"## Legendary Actions\n\n" + LegendaryActions.Aggregate((s1, s2) => s1 + "\n\n" + s2) : "");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Markdig.Syntax;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class Description : Item
|
||||
{
|
||||
//public override string Markdown => string.Empty;
|
||||
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,15 +23,5 @@ namespace AideDeJeuLib
|
|||
public string DescriptionHtml { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string Classes { get; set; }
|
||||
public Description Description { get; set; }
|
||||
|
||||
public virtual string LevelType { get; set; }
|
||||
|
||||
//public override string Markdown => throw new NotImplementedException();
|
||||
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,178 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using AideDeJeu.Tools;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class SpellHD : Spell
|
||||
{
|
||||
public override string LevelType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (int.Parse(Level) > 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Ritual))
|
||||
{
|
||||
return $"{Type} de niveau {Level}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{Type} de niveau {Level} {Ritual}";
|
||||
}
|
||||
}
|
||||
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.Ritual = 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.Ritual = match.Groups["rituel"].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//public override string Markdown
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return
|
||||
// $"# {Name}\n" +
|
||||
// $"{AltName}\n\n" +
|
||||
// $"_{LevelType}_\n" +
|
||||
// $"**Temps d'incantation :** {CastingTime}\n" +
|
||||
// $"**Portée :** {Range}\n" +
|
||||
// $"**Composantes :** {Components}\n" +
|
||||
// $"**Durée :** {Duration}\n" +
|
||||
// $"**Classes :** {Classes}\n" +
|
||||
// $"**Source :** {Source}\n" +
|
||||
// $"\n" +
|
||||
// $"{DescriptionHtml}";
|
||||
// }
|
||||
//}
|
||||
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
{
|
||||
enumerator.MoveNext();
|
||||
while (enumerator.Current != null)
|
||||
{
|
||||
var block = enumerator.Current;
|
||||
if (block is Markdig.Syntax.HeadingBlock)
|
||||
{
|
||||
var headingBlock = block as Markdig.Syntax.HeadingBlock;
|
||||
if (headingBlock.HeaderChar == '#' && headingBlock.Level == 1)
|
||||
{
|
||||
if (this.Name != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.Name = headingBlock.Inline.ToMarkdownString();
|
||||
}
|
||||
}
|
||||
if (block is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
if (block.IsNewItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraphBlock = block as Markdig.Syntax.ParagraphBlock;
|
||||
|
||||
this.DescriptionHtml += paragraphBlock.ToMarkdownString() + "\n";
|
||||
}
|
||||
if (block is Markdig.Syntax.ListBlock)
|
||||
{
|
||||
var listBlock = block as Markdig.Syntax.ListBlock;
|
||||
if (listBlock.BulletType == '-')
|
||||
{
|
||||
this.Source = "";
|
||||
foreach (var inblock in listBlock)
|
||||
{
|
||||
var regex = new Regex("(?<key>.*?): (?<value>.*)");
|
||||
if (inblock is Markdig.Syntax.ListItemBlock)
|
||||
{
|
||||
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
|
||||
foreach (var ininblock in listItemBlock)
|
||||
{
|
||||
if (ininblock is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
|
||||
var str = paragraphBlock.Inline.ToMarkdownString();
|
||||
|
||||
var properties = new List<Tuple<string, Action<Spell, string>>>()
|
||||
{
|
||||
new Tuple<string, Action<Spell, string>>("AltName: ", (m, s) => m.AltName = s),
|
||||
new Tuple<string, Action<Spell, string>>("**Temps d'incantation :** ", (m, s) => m.CastingTime = s),
|
||||
new Tuple<string, Action<Spell, string>>("**Composantes :** ", (m, s) => m.Components = s),
|
||||
new Tuple<string, Action<Spell, string>>("**Durée :** ", (m, s) => m.Duration = s),
|
||||
new Tuple<string, Action<Spell, string>>("LevelType: ", (m, s) => m.LevelType = s),
|
||||
new Tuple<string, Action<Spell, string>>("**Portée :** ", (m, s) => m.Range = s),
|
||||
new Tuple<string, Action<Spell, string>>("Source: ", (m, s) => m.Source = s),
|
||||
new Tuple<string, Action<Spell, string>>("Classes: ", (m, s) => m.Classes = s),
|
||||
new Tuple<string, Action<Spell, string>>("", (m,s) =>
|
||||
{
|
||||
})
|
||||
};
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
if (str.StartsWith(property.Item1))
|
||||
{
|
||||
property.Item2.Invoke(this, str.Substring(property.Item1.Length));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var inblock in listBlock)
|
||||
{
|
||||
if (inblock is Markdig.Syntax.ListItemBlock)
|
||||
{
|
||||
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
|
||||
foreach (var ininblock in listItemBlock)
|
||||
{
|
||||
if (ininblock is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
|
||||
this.DescriptionHtml += listBlock.BulletType + " " + paragraphBlock.ToMarkdownString() + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (block is Markdig.Extensions.Tables.Table)
|
||||
{
|
||||
var tableBlock = block as Markdig.Extensions.Tables.Table;
|
||||
this.DescriptionHtml += "\n\n" + tableBlock.ToMarkdownString() + "\n\n";
|
||||
}
|
||||
enumerator.MoveNext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using AideDeJeu.Tools;
|
||||
using Markdig.Syntax;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class SpellVO : Spell
|
||||
{
|
||||
public override string LevelType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Ritual))
|
||||
{
|
||||
return $"Level {Level} - {Type}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"Level {Level} - {Type} {Ritual}";
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
var re = new Regex("^(?<level>\\d) - (?<type>.*?)\\s?(?<rituel>\\(ritual\\))?$");
|
||||
var match = re.Match(value);
|
||||
this.Type = match.Groups["type"].Value;
|
||||
this.Level = match.Groups["level"].Value;
|
||||
this.Ritual = match.Groups["rituel"].Value;
|
||||
}
|
||||
}
|
||||
|
||||
//public override string Markdown
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return
|
||||
// $"# {Name}\n" +
|
||||
// $"{AltName}\n\n" +
|
||||
// $"_{LevelType}_\n" +
|
||||
// $"**Casting Time :** {CastingTime}\n" +
|
||||
// $"**Range :** {Range}\n" +
|
||||
// $"**Components :** {Components}\n" +
|
||||
// $"**Duration :** {Duration}\n" +
|
||||
// $"**Classes :** {Classes}\n" +
|
||||
// $"**Source :** {Source}\n" +
|
||||
// $"\n" +
|
||||
// $"{DescriptionHtml}";
|
||||
// }
|
||||
//}
|
||||
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
{
|
||||
enumerator.MoveNext();
|
||||
while (enumerator.Current != null)
|
||||
{
|
||||
var block = enumerator.Current;
|
||||
if (block is Markdig.Syntax.HeadingBlock)
|
||||
{
|
||||
var headingBlock = block as Markdig.Syntax.HeadingBlock;
|
||||
if (headingBlock.HeaderChar == '#' && headingBlock.Level == 1)
|
||||
{
|
||||
if (this.Name != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.Name = headingBlock.Inline.ToMarkdownString();
|
||||
}
|
||||
}
|
||||
if (block is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
if (block.IsNewItem())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraphBlock = block as Markdig.Syntax.ParagraphBlock;
|
||||
|
||||
this.DescriptionHtml += paragraphBlock.ToMarkdownString() + "\n";
|
||||
}
|
||||
if (block is Markdig.Syntax.ListBlock)
|
||||
{
|
||||
var listBlock = block as Markdig.Syntax.ListBlock;
|
||||
if (listBlock.BulletType == '-')
|
||||
{
|
||||
this.Source = "";
|
||||
foreach (var inblock in listBlock)
|
||||
{
|
||||
var regex = new Regex("(?<key>.*?): (?<value>.*)");
|
||||
if (inblock is Markdig.Syntax.ListItemBlock)
|
||||
{
|
||||
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
|
||||
foreach (var ininblock in listItemBlock)
|
||||
{
|
||||
if (ininblock is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
|
||||
var str = paragraphBlock.Inline.ToMarkdownString();
|
||||
|
||||
var properties = new List<Tuple<string, Action<Spell, string>>>()
|
||||
{
|
||||
new Tuple<string, Action<Spell, string>>("AltName: ", (m, s) => m.AltName = s),
|
||||
new Tuple<string, Action<Spell, string>>("**Casting Time :** ", (m, s) => m.CastingTime = s),
|
||||
new Tuple<string, Action<Spell, string>>("**Components :** ", (m, s) => m.Components = s),
|
||||
new Tuple<string, Action<Spell, string>>("**Duration :** ", (m, s) => m.Duration = s),
|
||||
new Tuple<string, Action<Spell, string>>("LevelType: ", (m, s) => m.LevelType = s),
|
||||
new Tuple<string, Action<Spell, string>>("**Range :** ", (m, s) => m.Range = s),
|
||||
new Tuple<string, Action<Spell, string>>("Source: ", (m, s) => m.Source = s),
|
||||
new Tuple<string, Action<Spell, string>>("Classes: ", (m, s) => m.Classes = s),
|
||||
new Tuple<string, Action<Spell, string>>("", (m,s) =>
|
||||
{
|
||||
})
|
||||
};
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
if (str.StartsWith(property.Item1))
|
||||
{
|
||||
property.Item2.Invoke(this, str.Substring(property.Item1.Length));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var inblock in listBlock)
|
||||
{
|
||||
if (inblock is Markdig.Syntax.ListItemBlock)
|
||||
{
|
||||
var listItemBlock = inblock as Markdig.Syntax.ListItemBlock;
|
||||
foreach (var ininblock in listItemBlock)
|
||||
{
|
||||
if (ininblock is Markdig.Syntax.ParagraphBlock)
|
||||
{
|
||||
var paragraphBlock = ininblock as Markdig.Syntax.ParagraphBlock;
|
||||
this.DescriptionHtml += listBlock.BulletType + " " + paragraphBlock.ToMarkdownString() + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (block is Markdig.Extensions.Tables.Table)
|
||||
{
|
||||
var tableBlock = block as Markdig.Extensions.Tables.Table;
|
||||
this.DescriptionHtml += "\n\n" + tableBlock.ToMarkdownString() + "\n\n";
|
||||
}
|
||||
enumerator.MoveNext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ namespace AideDeJeu.Views
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
var item = new MonsterHD
|
||||
var item = new Item
|
||||
{
|
||||
Name = "",
|
||||
AltName = "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue