mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Refonte parsing ok
This commit is contained in:
parent
83120c1749
commit
6bb3737b1f
18 changed files with 520 additions and 177 deletions
|
|
@ -327,6 +327,10 @@
|
|||
<EmbeddedResource Include="..\..\Data\l5r_rituals_hd.md" Link="Data\l5r_rituals_hd.md" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\..\Data\sandbox.md" Link="Data\sandbox.md" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Views\MainNavigationPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
|
|
|
|||
|
|
@ -10,11 +10,219 @@ using Markdig.Parsers;
|
|||
using System.IO;
|
||||
using Markdig.Renderers.Normalize;
|
||||
using Markdig.Renderers.Normalize.Inlines;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AideDeJeu.Tools
|
||||
{
|
||||
public static class MarkdownExtensions
|
||||
{
|
||||
public static Item ToItem(string md)
|
||||
{
|
||||
var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build();
|
||||
var document = MarkdownParser.Parse(md, pipeline);
|
||||
|
||||
var enumerator = document.GetEnumerator();
|
||||
try
|
||||
{
|
||||
enumerator.MoveNext();
|
||||
while (enumerator.Current != null)
|
||||
{
|
||||
var block = enumerator.Current;
|
||||
|
||||
if (block is HtmlBlock)
|
||||
{
|
||||
if (block.IsNewItem())
|
||||
{
|
||||
var item = ParseItem(ref enumerator);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
enumerator.MoveNext();
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
enumerator.Dispose();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item ParseItem(ref ContainerBlock.Enumerator enumerator)
|
||||
{
|
||||
var currentItem = enumerator.Current.GetNewItem();
|
||||
//item.Parse(ref enumerator);
|
||||
|
||||
enumerator.MoveNext();
|
||||
while (enumerator.Current != null)
|
||||
{
|
||||
var block = enumerator.Current;
|
||||
|
||||
if (block is HtmlBlock)
|
||||
{
|
||||
if (block.IsClosingItem())
|
||||
{
|
||||
return currentItem;
|
||||
}
|
||||
else if (block.IsNewItem())
|
||||
{
|
||||
var subItem = ParseItem(ref enumerator);
|
||||
|
||||
var propertyName = subItem.GetType().Name;
|
||||
|
||||
if (currentItem.GetType().GetProperty(propertyName) != null)
|
||||
{
|
||||
PropertyInfo prop = currentItem.GetType().GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance);
|
||||
if (null != prop && prop.CanWrite)
|
||||
{
|
||||
prop.SetValue(currentItem, subItem, null);
|
||||
}
|
||||
}
|
||||
else if (currentItem is Items)
|
||||
{
|
||||
var items = currentItem as Items;
|
||||
items.Add(subItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else // if (block is ContainerBlock)
|
||||
{
|
||||
ParseItemProperties(currentItem, block);
|
||||
//var listBlock = block as ContainerBlock;
|
||||
//foreach (var inblock in listBlock)
|
||||
//{
|
||||
// if (inblock is ListItemBlock)
|
||||
// {
|
||||
// var listItemBlock = inblock as ListItemBlock;
|
||||
// foreach (var ininblock in listItemBlock)
|
||||
// {
|
||||
// if (ininblock is ParagraphBlock)
|
||||
// {
|
||||
// var parBlock = ininblock as ParagraphBlock;
|
||||
// ParseItemProperties(currentItem, parBlock.Inline);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
currentItem.Markdown += enumerator.Current.ToMarkdownString();
|
||||
|
||||
enumerator.MoveNext();
|
||||
}
|
||||
|
||||
// bad !
|
||||
return currentItem;
|
||||
}
|
||||
|
||||
public static void ParseItemProperties(Item item, Block block)
|
||||
{
|
||||
switch(block)
|
||||
{
|
||||
case ContainerBlock blocks:
|
||||
ParseItemProperties(item, blocks);
|
||||
break;
|
||||
case LeafBlock leaf:
|
||||
ParseItemProperties(item, leaf.Inline);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ParseItemProperties(Item item, ContainerBlock blocks)
|
||||
{
|
||||
foreach(var block in blocks)
|
||||
{
|
||||
ParseItemProperties(item, block);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ParseItemProperties(Item item, ContainerInline inlines)
|
||||
{
|
||||
PropertyInfo prop = null;
|
||||
foreach (var inline in inlines)
|
||||
{
|
||||
if(inline is HtmlInline)
|
||||
{
|
||||
var tag = (inline as HtmlInline).Tag;
|
||||
if (tag.StartsWith("</"))
|
||||
{
|
||||
prop = null;
|
||||
}
|
||||
else if (tag.StartsWith("<") && !tag.StartsWith("</"))
|
||||
{
|
||||
var propertyName = tag.Substring(1, tag.Length - 2);
|
||||
prop = item.GetType().GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (null != prop && prop.CanWrite)
|
||||
{
|
||||
prop.SetValue(item, inline.ToMarkdownString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static bool IsNewItem(this Block block)
|
||||
{
|
||||
var htmlBlock = block as HtmlBlock;
|
||||
if (htmlBlock.Type == HtmlBlockType.NonInterruptingBlock)
|
||||
{
|
||||
var tag = htmlBlock.Lines.Lines.FirstOrDefault().Slice.ToString();
|
||||
if (!string.IsNullOrEmpty(tag))
|
||||
{
|
||||
if (tag.StartsWith("<") && !tag.StartsWith("</"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsClosingItem(this Block block)
|
||||
{
|
||||
var htmlBlock = block as HtmlBlock;
|
||||
if (htmlBlock.Type == HtmlBlockType.NonInterruptingBlock)
|
||||
{
|
||||
var tag = htmlBlock.Lines.Lines.FirstOrDefault().Slice.ToString();
|
||||
if (!string.IsNullOrEmpty(tag))
|
||||
{
|
||||
if (tag.StartsWith("</"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Item GetNewItem(this Block block)
|
||||
{
|
||||
var htmlBlock = block as HtmlBlock;
|
||||
if (htmlBlock.Type == HtmlBlockType.NonInterruptingBlock)
|
||||
{
|
||||
var tag = htmlBlock.Lines.Lines.FirstOrDefault().Slice.ToString();
|
||||
if (!string.IsNullOrEmpty(tag))
|
||||
{
|
||||
if (tag.StartsWith("<") && !tag.StartsWith("</"))
|
||||
{
|
||||
var name = $"AideDeJeuLib.{tag.Substring(1, tag.Length - 2)}, AideDeJeu";
|
||||
var type = Type.GetType(name);
|
||||
var instance = Activator.CreateInstance(type) as Item;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public static Item ToItem(string md)
|
||||
{
|
||||
var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build();
|
||||
|
|
@ -99,7 +307,7 @@ namespace AideDeJeu.Tools
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
public static string ToMarkdownString(this Block block)
|
||||
|
|
@ -205,21 +413,21 @@ namespace AideDeJeu.Tools
|
|||
public static string ToMarkdownString(this Markdig.Extensions.Tables.Table tableBlock)
|
||||
{
|
||||
var ret = string.Empty;
|
||||
foreach(Markdig.Extensions.Tables.TableRow row in tableBlock)
|
||||
foreach (Markdig.Extensions.Tables.TableRow row in tableBlock)
|
||||
{
|
||||
var line = "|";
|
||||
foreach(Markdig.Extensions.Tables.TableCell cell in row)
|
||||
foreach (Markdig.Extensions.Tables.TableCell cell in row)
|
||||
{
|
||||
foreach(Markdig.Syntax.ParagraphBlock block in cell)
|
||||
foreach (Markdig.Syntax.ParagraphBlock block in cell)
|
||||
{
|
||||
line += block.ToMarkdownString().Replace("\n", "");
|
||||
}
|
||||
line += "|";
|
||||
}
|
||||
if(row.IsHeader)
|
||||
if (row.IsHeader)
|
||||
{
|
||||
line += "\n|";
|
||||
for(int i = 0; i < row.Count; i++)
|
||||
for (int i = 0; i < row.Count; i++)
|
||||
{
|
||||
line += "---|";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,18 @@ namespace AideDeJeuLib
|
|||
{
|
||||
public class Generic : Item
|
||||
{
|
||||
public string Text { get; set; }
|
||||
//public string Text { get; set; }
|
||||
|
||||
public override string Markdown
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
//$"# {Name}\n\n" +
|
||||
//$"{AltName}\n\n" +
|
||||
Text;
|
||||
}
|
||||
}
|
||||
//public override string Markdown
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return
|
||||
// //$"# {Name}\n\n" +
|
||||
// //$"{AltName}\n\n" +
|
||||
// Text;
|
||||
// }
|
||||
//}
|
||||
|
||||
public void ParseBlock(Block block)
|
||||
{
|
||||
|
|
@ -35,7 +35,7 @@ namespace AideDeJeuLib
|
|||
this.Name = headingBlock.Inline.ToMarkdownString();
|
||||
this.NameLevel = headingBlock.Level - 1;
|
||||
}
|
||||
this.Text += block.ToMarkdownString();
|
||||
this.Markdown += block.ToMarkdownString();
|
||||
}
|
||||
else if (block is ListBlock)
|
||||
{
|
||||
|
|
@ -58,11 +58,11 @@ namespace AideDeJeuLib
|
|||
{
|
||||
new Tuple<string, Action<Generic, string>>("AltName: ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + s; m.AltName = s;
|
||||
this.Markdown += "- " + s; m.AltName = s;
|
||||
}),
|
||||
new Tuple<string, Action<Generic, string>>("", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str;
|
||||
this.Markdown += "- " + str;
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -78,16 +78,16 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
}
|
||||
this.Text += "\n";
|
||||
this.Markdown += "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Text += block.ToMarkdownString();
|
||||
this.Markdown += block.ToMarkdownString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Text += block.ToMarkdownString();
|
||||
this.Markdown += block.ToMarkdownString();
|
||||
}
|
||||
}
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace AideDeJeuLib
|
|||
{
|
||||
public class Equipment : Item
|
||||
{
|
||||
public string Text { get; set; }
|
||||
//public string Text { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Price { get; set; }
|
||||
public string ArmorClass { get; set; }
|
||||
|
|
@ -24,16 +24,16 @@ namespace AideDeJeuLib
|
|||
public string WeightCapacity { get; set; }
|
||||
public string Speed { get; set; }
|
||||
|
||||
public override string Markdown
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
//$"# {Name}\n\n" +
|
||||
//$"{AltName}\n\n" +
|
||||
Text;
|
||||
}
|
||||
}
|
||||
//public override string Markdown
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return
|
||||
// //$"# {Name}\n\n" +
|
||||
// //$"{AltName}\n\n" +
|
||||
// Text;
|
||||
// }
|
||||
//}
|
||||
|
||||
public void ParseBlock(Block block)
|
||||
{
|
||||
|
|
@ -44,7 +44,7 @@ namespace AideDeJeuLib
|
|||
{
|
||||
this.Name = headingBlock.Inline.ToMarkdownString();
|
||||
}
|
||||
this.Text += block.ToMarkdownString();
|
||||
this.Markdown += block.ToMarkdownString();
|
||||
}
|
||||
else if (block is ListBlock)
|
||||
{
|
||||
|
|
@ -67,63 +67,63 @@ namespace AideDeJeuLib
|
|||
{
|
||||
new Tuple<string, Action<Equipment, string>>("AltName: ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + s; m.AltName = s;
|
||||
this.Markdown += "- " + s; m.AltName = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Type** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Type = s;
|
||||
this.Markdown += "- " + str; m.Type = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Prix** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Price = s;
|
||||
this.Markdown += "- " + str; m.Price = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Classe d'armure** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.ArmorClass = s;
|
||||
this.Markdown += "- " + str; m.ArmorClass = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Discrétion** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Discretion = s;
|
||||
this.Markdown += "- " + str; m.Discretion = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Poids** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Weight = s;
|
||||
this.Markdown += "- " + str; m.Weight = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Force** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Force = s;
|
||||
this.Markdown += "- " + str; m.Force = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Rareté** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Rarity = s;
|
||||
this.Markdown += "- " + str; m.Rarity = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Dégâts** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Damages = s;
|
||||
this.Markdown += "- " + str; m.Damages = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Propriétés** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Properties = s;
|
||||
this.Markdown += "- " + str; m.Properties = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Unité** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Unity = s; //m.Name += $" ({s})";
|
||||
this.Markdown += "- " + str; m.Unity = s; //m.Name += $" ({s})";
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Capacité** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Capacity = s;
|
||||
this.Markdown += "- " + str; m.Capacity = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Capacité de charge** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.WeightCapacity = s;
|
||||
this.Markdown += "- " + str; m.WeightCapacity = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("**Vitesse** ", (m, s) =>
|
||||
{
|
||||
this.Text += "- " + str; m.Speed = s;
|
||||
this.Markdown += "- " + str; m.Speed = s;
|
||||
}),
|
||||
new Tuple<string, Action<Equipment, string>>("", (m, s) =>
|
||||
{
|
||||
this.Text += str;
|
||||
this.Markdown += str;
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
@ -139,16 +139,16 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
}
|
||||
this.Text += "\n";
|
||||
this.Markdown += "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Text += block.ToMarkdownString();
|
||||
this.Markdown += block.ToMarkdownString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Text += block.ToMarkdownString();
|
||||
this.Markdown += block.ToMarkdownString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace AideDeJeuLib
|
|||
{
|
||||
public class HomeItem : Item
|
||||
{
|
||||
public override string Markdown
|
||||
public new string Markdown
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using System.Xml;
|
|||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public abstract class Item
|
||||
public class Item
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int NameLevel { get; set; }
|
||||
|
|
@ -32,7 +32,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
public abstract string Markdown { get; }
|
||||
public abstract void Parse(ref Markdig.Syntax.ContainerBlock.Enumerator enumerator);
|
||||
public string Markdown { get; set; }
|
||||
public virtual void Parse(ref Markdig.Syntax.ContainerBlock.Enumerator enumerator) { }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ using Markdig.Syntax.Inlines;
|
|||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class Items : Item, IEnumerable<Item>
|
||||
public class Items : Item, IList<Item>
|
||||
{
|
||||
private IEnumerable<Item> _Items;
|
||||
private List<Item> _Items;
|
||||
|
||||
public Items(IEnumerable<Item> items)
|
||||
public Items(List<Item> items)
|
||||
{
|
||||
_Items = items;
|
||||
}
|
||||
|
|
@ -24,17 +24,22 @@ namespace AideDeJeuLib
|
|||
_Items = new List<Item>();
|
||||
}
|
||||
|
||||
private string _Markdown = "";
|
||||
public override string Markdown
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Markdown;
|
||||
}
|
||||
}
|
||||
//private string _Markdown = "";
|
||||
//public override string Markdown
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return _Markdown;
|
||||
// }
|
||||
//}
|
||||
|
||||
public string Header { get; set; }
|
||||
|
||||
public int Count => _Items.Count();
|
||||
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
public Item this[int index] { get => _Items[index]; set => _Items[index] = value; }
|
||||
|
||||
public IEnumerator<Item> GetEnumerator()
|
||||
{
|
||||
|
|
@ -92,5 +97,45 @@ namespace AideDeJeuLib
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public int IndexOf(Item item)
|
||||
{
|
||||
return _Items.IndexOf(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, Item item)
|
||||
{
|
||||
_Items.Insert(index, item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
_Items.RemoveAt(index);
|
||||
}
|
||||
|
||||
public void Add(Item item)
|
||||
{
|
||||
_Items.Add(item);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_Items.Clear();
|
||||
}
|
||||
|
||||
public bool Contains(Item item)
|
||||
{
|
||||
return _Items.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(Item[] array, int arrayIndex)
|
||||
{
|
||||
_Items.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public bool Remove(Item item)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,15 +26,16 @@ namespace AideDeJeuLib
|
|||
var match = regex.Match(value);
|
||||
Name = match.Groups["name"].Value;
|
||||
Link = match.Groups["link"].Value;
|
||||
Markdown = $"# {NameLink}\n\n";
|
||||
}
|
||||
}
|
||||
public override string Markdown
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"# {NameLink}\n\n";
|
||||
}
|
||||
}
|
||||
//public override string Markdown
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return $"# {NameLink}\n\n";
|
||||
// }
|
||||
//}
|
||||
|
||||
public override void Parse(ref ContainerBlock.Enumerator enumerator)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,34 +8,34 @@ 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) : "");
|
||||
}
|
||||
}
|
||||
//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) : "");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,34 +8,34 @@ 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) : "");
|
||||
}
|
||||
}
|
||||
//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) : "");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
17
AideDeJeu/AideDeJeu/Models/Spells/Description.cs
Normal file
17
AideDeJeu/AideDeJeu/Models/Spells/Description.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ using System.Xml.Serialization;
|
|||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public abstract class Spell : Item
|
||||
public class Spell : Item
|
||||
{
|
||||
public string Level { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
|
@ -23,7 +23,15 @@ namespace AideDeJeuLib
|
|||
public string DescriptionHtml { get; set; }
|
||||
public string Source { get; set; }
|
||||
public string Classes { get; set; }
|
||||
public Description Description { get; set; }
|
||||
|
||||
public abstract string LevelType { 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,24 +51,24 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
}
|
||||
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 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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,24 +32,24 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
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 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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ namespace AideDeJeu.ViewModels
|
|||
spell.Type.ToLower().Contains(ecole.ToLower()) &&
|
||||
spell.Source.Contains(source) &&
|
||||
spell.Classes.Contains(classe) &&
|
||||
spell.Rituel.Contains(rituel) &&
|
||||
(spell.Rituel == null || spell.Rituel.Contains(rituel)) &&
|
||||
(
|
||||
(Helpers.RemoveDiacritics(spell.Name).ToLower().Contains(Helpers.RemoveDiacritics(SearchText ?? string.Empty).ToLower())) ||
|
||||
(Helpers.RemoveDiacritics(spell.AltNameText ?? string.Empty).ToLower().Contains(Helpers.RemoveDiacritics(SearchText ?? string.Empty).ToLower()))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,15 @@ namespace AideDeJeu.ViewModels
|
|||
//return Tools.MarkdownExtensions.ToItem(md);
|
||||
if (md != null)
|
||||
{
|
||||
_AllItems[source] = Tools.MarkdownExtensions.ToItem(md);
|
||||
var item = Tools.MarkdownExtensions.ToItem(md);
|
||||
if (item != null)
|
||||
{
|
||||
_AllItems[source] = item;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,3 +70,7 @@
|
|||
## [Spells](spells_vo.md)
|
||||
|
||||
## [Monsters, Animals and NPC](monsters_vo.md)
|
||||
|
||||
<br>
|
||||
|
||||
# [Sandbox](sandbox.md)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Spells>
|
||||
<SpellsHD>
|
||||
|
||||
<Spell>
|
||||
|
||||
|
|
@ -16,7 +16,31 @@
|
|||
|
||||
### Description
|
||||
|
||||
<Description>
|
||||
Vous agrandissez ou rétrécissez une créature ou un objet situé à portée et dans votre champ de vision pendant toute la durée du sort. Choisissez soit une créature, soit un objet qui n'est ni porté ni transporté. Si la cible n'est pas consentante, elle a droit à un [jet de sauvegarde] de [Constitution]. Si elle le réussit, le sort est sans effet.
|
||||
|
||||
Si la cible est une créature, tout ce qu'elle porte et tout ce qu'elle transporte change de taille avec elle. En revanche, si elle lâche un objet, il reprend sa taille normale sur-le-champ.
|
||||
|
||||
**_Agrandir._** La cible double dans toutes les dimensions, et son poids est multiplié par huit. Cette croissance augmente sa catégorie de taille d'un cran, de M à G par exemple. Si la cible n'a pas assez de place pour doubler de volume, elle atteint la taille maximale possible dans l'espace dont elle dispose. Elle bénéficie d'un avantage lors des tests de [Force] et des [jets de sauvegarde] de [Force] jusqu'à la fin du sort. Les armes de la cible grandissent pour s'adapter à sa nouvelle taille. Tant qu'elles sont ainsi agrandies, elles infligent 1d4 dégâts de plus.
|
||||
|
||||
**_Rétrécir._** La cible réduit de moitié dans toutes les dimensions et son poids est divisé par huit. Ce rétrécissement réduit sa catégorie de taille d'un cran, de M à P par exemple. La cible subit un désavantage lors des tests de [Force] et des [jets de sauvegarde] de [Force] jusqu'à la fin du sort. Les armes de la cible rétrécissent pour s'adapter à sa nouvelle taille. Tant qu'elles sont ainsi réduites, elles infligent 1d4 dégâts de moins (avec un minimum de 1 dégât).
|
||||
|
||||
</Spell>
|
||||
|
||||
<Spell>
|
||||
|
||||
# <Name>Agrandir/rétrécir</Name>
|
||||
|
||||
- <AltName>[Enlarge/Reduce](spells_vo.md#enlargereduce)</AltName>
|
||||
|
||||
- <Type>Transmutation</Type> de niveau <Level>2</Level>
|
||||
- **Temps d'incantation :** <CastingTime>1 action</CastingTime>
|
||||
- **Portée :** <Range>9 mètres</Range>
|
||||
- **Composantes :** <Components>V, S, M (une pincée de limaille de fer)</Components>
|
||||
- **Durée :** <Duration>concentration, jusqu'à 1 minute</Duration>
|
||||
- Classes: <Classes>[Ensorceleur], [Magicien]</Classes>
|
||||
- Source: <Source>(HD)(SRD)</Source>
|
||||
|
||||
### Description
|
||||
|
||||
Vous agrandissez ou rétrécissez une créature ou un objet situé à portée et dans votre champ de vision pendant toute la durée du sort. Choisissez soit une créature, soit un objet qui n'est ni porté ni transporté. Si la cible n'est pas consentante, elle a droit à un [jet de sauvegarde] de [Constitution]. Si elle le réussit, le sort est sans effet.
|
||||
|
||||
|
|
@ -26,8 +50,32 @@ Si la cible est une créature, tout ce qu'elle porte et tout ce qu'elle transpor
|
|||
|
||||
**_Rétrécir._** La cible réduit de moitié dans toutes les dimensions et son poids est divisé par huit. Ce rétrécissement réduit sa catégorie de taille d'un cran, de M à P par exemple. La cible subit un désavantage lors des tests de [Force] et des [jets de sauvegarde] de [Force] jusqu'à la fin du sort. Les armes de la cible rétrécissent pour s'adapter à sa nouvelle taille. Tant qu'elles sont ainsi réduites, elles infligent 1d4 dégâts de moins (avec un minimum de 1 dégât).
|
||||
|
||||
</Description>
|
||||
</Spell>
|
||||
|
||||
<Spell>
|
||||
|
||||
# <Name>Agrandir/rétrécir</Name>
|
||||
|
||||
- <AltName>[Enlarge/Reduce](spells_vo.md#enlargereduce)</AltName>
|
||||
|
||||
- <Type>Transmutation</Type> de niveau <Level>2</Level>
|
||||
- **Temps d'incantation :** <CastingTime>1 action</CastingTime>
|
||||
- **Portée :** <Range>9 mètres</Range>
|
||||
- **Composantes :** <Components>V, S, M (une pincée de limaille de fer)</Components>
|
||||
- **Durée :** <Duration>concentration, jusqu'à 1 minute</Duration>
|
||||
- Classes: <Classes>[Ensorceleur], [Magicien]</Classes>
|
||||
- Source: <Source>(HD)(SRD)</Source>
|
||||
|
||||
### Description
|
||||
|
||||
Vous agrandissez ou rétrécissez une créature ou un objet situé à portée et dans votre champ de vision pendant toute la durée du sort. Choisissez soit une créature, soit un objet qui n'est ni porté ni transporté. Si la cible n'est pas consentante, elle a droit à un [jet de sauvegarde] de [Constitution]. Si elle le réussit, le sort est sans effet.
|
||||
|
||||
Si la cible est une créature, tout ce qu'elle porte et tout ce qu'elle transporte change de taille avec elle. En revanche, si elle lâche un objet, il reprend sa taille normale sur-le-champ.
|
||||
|
||||
**_Agrandir._** La cible double dans toutes les dimensions, et son poids est multiplié par huit. Cette croissance augmente sa catégorie de taille d'un cran, de M à G par exemple. Si la cible n'a pas assez de place pour doubler de volume, elle atteint la taille maximale possible dans l'espace dont elle dispose. Elle bénéficie d'un avantage lors des tests de [Force] et des [jets de sauvegarde] de [Force] jusqu'à la fin du sort. Les armes de la cible grandissent pour s'adapter à sa nouvelle taille. Tant qu'elles sont ainsi agrandies, elles infligent 1d4 dégâts de plus.
|
||||
|
||||
**_Rétrécir._** La cible réduit de moitié dans toutes les dimensions et son poids est divisé par huit. Ce rétrécissement réduit sa catégorie de taille d'un cran, de M à P par exemple. La cible subit un désavantage lors des tests de [Force] et des [jets de sauvegarde] de [Force] jusqu'à la fin du sort. Les armes de la cible rétrécissent pour s'adapter à sa nouvelle taille. Tant qu'elles sont ainsi réduites, elles infligent 1d4 dégâts de moins (avec un minimum de 1 dégât).
|
||||
|
||||
</Spell>
|
||||
|
||||
</Spells>
|
||||
</SpellsHD>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue