mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-31 23:45:39 +00:00
Spécialisation SpellVO / SpellHD
This commit is contained in:
parent
32830b4a08
commit
d2f99b15c5
10 changed files with 187 additions and 27 deletions
|
|
@ -13,12 +13,13 @@ namespace AideDeJeuLib
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Item
|
public abstract class Item
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string NameVO { get; set; }
|
public string NameVO { get; set; }
|
||||||
|
|
||||||
public Properties Properties { get; set; }
|
public Properties Properties { get; set; }
|
||||||
|
|
||||||
|
public abstract string Markdown { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,5 +37,13 @@ namespace AideDeJeuLib.Monsters
|
||||||
public IEnumerable<string> Actions { get; set; }
|
public IEnumerable<string> Actions { get; set; }
|
||||||
public IEnumerable<string> Reactions { get; set; }
|
public IEnumerable<string> Reactions { get; set; }
|
||||||
public IEnumerable<string> LegendaryActions { get; set; }
|
public IEnumerable<string> LegendaryActions { get; set; }
|
||||||
|
|
||||||
|
public override string Markdown
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,21 @@ namespace AideDeJeuLib.Spells
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return string.Format("{0} - {1}", this.Level, this.Type);
|
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
|
set
|
||||||
{
|
{
|
||||||
|
|
@ -57,5 +71,22 @@ namespace AideDeJeuLib.Spells
|
||||||
|
|
||||||
public string Source { 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}";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
69
AideDeJeu/AideDeJeu/Models/Spells/SpellHD.cs
Normal file
69
AideDeJeu/AideDeJeu/Models/Spells/SpellHD.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace AideDeJeuLib.Spells
|
||||||
|
{
|
||||||
|
public class SpellHD : Spell
|
||||||
|
{
|
||||||
|
public new 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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}";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
51
AideDeJeu/AideDeJeu/Models/Spells/SpellVO.cs
Normal file
51
AideDeJeu/AideDeJeu/Models/Spells/SpellVO.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace AideDeJeuLib.Spells
|
||||||
|
{
|
||||||
|
public class SpellVO : Spell
|
||||||
|
{
|
||||||
|
public new string LevelType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Rituel))
|
||||||
|
{
|
||||||
|
return $"Level {Level} - {Type}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $"Level {Level} - {Type} {Rituel}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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.Rituel = match.Groups["rituel"].Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Markdown
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return
|
||||||
|
$"# {Name}\n" +
|
||||||
|
$"{NameVO}\n" +
|
||||||
|
$"_{LevelType}_\n" +
|
||||||
|
$"**Casting Time :** {CastingTime}\n" +
|
||||||
|
$"**Range :** {Range}\n" +
|
||||||
|
$"**Components :** {Components}\n" +
|
||||||
|
$"**Duration :** {Duration}\n\n" +
|
||||||
|
$"{DescriptionHtml}\n\n" +
|
||||||
|
$"**Source :** {Source}";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,11 +14,11 @@ namespace AideDeJeu.Tools
|
||||||
{
|
{
|
||||||
public static class MarkdownExtensions
|
public static class MarkdownExtensions
|
||||||
{
|
{
|
||||||
public static IEnumerable<Spell> MarkdownToSpells(string md)
|
public static IEnumerable<TSpell> MarkdownToSpells<TSpell>(string md) where TSpell : Spell, new()
|
||||||
{
|
{
|
||||||
var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build();
|
var pipeline = new MarkdownPipelineBuilder().UsePipeTables().Build();
|
||||||
var document = Markdig.Parsers.MarkdownParser.Parse(md, pipeline);
|
var document = Markdig.Parsers.MarkdownParser.Parse(md, pipeline);
|
||||||
return document.ToSpells();
|
return document.ToSpells<TSpell>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Monster> MarkdownToMonsters(string md)
|
public static IEnumerable<Monster> MarkdownToMonsters(string md)
|
||||||
|
|
@ -35,10 +35,10 @@ namespace AideDeJeu.Tools
|
||||||
return md;
|
return md;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Spell> ToSpells(this Markdig.Syntax.MarkdownDocument document)
|
public static IEnumerable<TSpell> ToSpells<TSpell>(this Markdig.Syntax.MarkdownDocument document) where TSpell : Spell, new()
|
||||||
{
|
{
|
||||||
var spells = new List<Spell>();
|
var spells = new List<TSpell>();
|
||||||
Spell spell = null;
|
TSpell spell = null;
|
||||||
foreach (var block in document)
|
foreach (var block in document)
|
||||||
{
|
{
|
||||||
//DumpBlock(block);
|
//DumpBlock(block);
|
||||||
|
|
@ -53,7 +53,7 @@ namespace AideDeJeu.Tools
|
||||||
spells.Add(spell);
|
spells.Add(spell);
|
||||||
//yield return spell;
|
//yield return spell;
|
||||||
}
|
}
|
||||||
spell = new Spell();
|
spell = new TSpell();
|
||||||
spell.Name = headingBlock.Inline.ToMarkdownString();
|
spell.Name = headingBlock.Inline.ToMarkdownString();
|
||||||
//Console.WriteLine(spell.Name);
|
//Console.WriteLine(spell.Name);
|
||||||
}
|
}
|
||||||
|
|
@ -93,17 +93,17 @@ namespace AideDeJeu.Tools
|
||||||
//DumpParagraphBlock(paragraphBlock);
|
//DumpParagraphBlock(paragraphBlock);
|
||||||
var str = paragraphBlock.Inline.ToMarkdownString();
|
var str = paragraphBlock.Inline.ToMarkdownString();
|
||||||
|
|
||||||
var properties = new List<Tuple<string, Action<Spell, string>>>()
|
var properties = new List<Tuple<string, Action<TSpell, string>>>()
|
||||||
{
|
{
|
||||||
new Tuple<string, Action<Spell, string>>("NameVO: ", (m, s) => m.NameVO = s),
|
new Tuple<string, Action<TSpell, string>>("NameVO: ", (m, s) => m.NameVO = s),
|
||||||
new Tuple<string, Action<Spell, string>>("CastingTime: ", (m, s) => m.CastingTime = s),
|
new Tuple<string, Action<TSpell, string>>("CastingTime: ", (m, s) => m.CastingTime = s),
|
||||||
new Tuple<string, Action<Spell, string>>("Components: ", (m, s) => m.Components = s),
|
new Tuple<string, Action<TSpell, string>>("Components: ", (m, s) => m.Components = s),
|
||||||
new Tuple<string, Action<Spell, string>>("Duration: ", (m, s) => m.Duration = s),
|
new Tuple<string, Action<TSpell, string>>("Duration: ", (m, s) => m.Duration = s),
|
||||||
new Tuple<string, Action<Spell, string>>("LevelType: ", (m, s) => m.LevelType = s),
|
new Tuple<string, Action<TSpell, string>>("LevelType: ", (m, s) => m.LevelType = s),
|
||||||
new Tuple<string, Action<Spell, string>>("Range: ", (m, s) => m.Range = s),
|
new Tuple<string, Action<TSpell, string>>("Range: ", (m, s) => m.Range = s),
|
||||||
new Tuple<string, Action<Spell, string>>("Source: ", (m, s) => m.Source = s),
|
new Tuple<string, Action<TSpell, string>>("Source: ", (m, s) => m.Source = s),
|
||||||
new Tuple<string, Action<Spell, string>>("Classes: ", (m, s) => m.Source += s),
|
new Tuple<string, Action<TSpell, string>>("Classes: ", (m, s) => m.Source += s),
|
||||||
new Tuple<string, Action<Spell, string>>("", (m,s) =>
|
new Tuple<string, Action<TSpell, string>>("", (m,s) =>
|
||||||
{
|
{
|
||||||
//if (m.Alignment != null)
|
//if (m.Alignment != null)
|
||||||
//{
|
//{
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace AideDeJeu.ViewModels
|
||||||
{
|
{
|
||||||
resourceName = "AideDeJeu.Data.spells_vo.md";
|
resourceName = "AideDeJeu.Data.spells_vo.md";
|
||||||
var md = await Tools.Helpers.GetResourceStringAsync(resourceName);
|
var md = await Tools.Helpers.GetResourceStringAsync(resourceName);
|
||||||
_AllItems = Tools.MarkdownExtensions.MarkdownToSpells(md);
|
_AllItems = Tools.MarkdownExtensions.MarkdownToSpells<SpellVO>(md);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ItemSourceType.SpellHD:
|
case ItemSourceType.SpellHD:
|
||||||
|
|
@ -62,7 +62,7 @@ namespace AideDeJeu.ViewModels
|
||||||
resourceName = "AideDeJeu.Data.spells_hd.md";
|
resourceName = "AideDeJeu.Data.spells_hd.md";
|
||||||
//var md = await Tools.Helpers.GetStringFromUrl("https://raw.githubusercontent.com/Nioux/AideDeJeu/master/Data/spells_hd.md");
|
//var md = await Tools.Helpers.GetStringFromUrl("https://raw.githubusercontent.com/Nioux/AideDeJeu/master/Data/spells_hd.md");
|
||||||
var md = await Tools.Helpers.GetResourceStringAsync(resourceName);
|
var md = await Tools.Helpers.GetResourceStringAsync(resourceName);
|
||||||
_AllItems = Tools.MarkdownExtensions.MarkdownToSpells(md);
|
_AllItems = Tools.MarkdownExtensions.MarkdownToSpells<SpellHD>(md);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
</ContentPage.Resources>
|
</ContentPage.Resources>
|
||||||
<ScrollView VerticalScrollBarVisibility="Default" HorizontalScrollBarVisibility="Default">
|
<ScrollView VerticalScrollBarVisibility="Default" HorizontalScrollBarVisibility="Default">
|
||||||
<StackLayout Orientation="Vertical" Padding="15">
|
<StackLayout Orientation="Vertical" Padding="15">
|
||||||
<Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsection}" />
|
<!--<Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsection}" />
|
||||||
<mdview:MarkdownView x:Name="mdNameVO" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.NameVO}" />
|
<mdview:MarkdownView x:Name="mdNameVO" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.NameVO}" />
|
||||||
|
|
||||||
<Label Text=" " />
|
<Label Text=" " />
|
||||||
|
|
@ -29,11 +29,11 @@
|
||||||
|
|
||||||
<Label FormattedText="{Binding Duration}" />
|
<Label FormattedText="{Binding Duration}" />
|
||||||
|
|
||||||
<Label Text=" " />
|
<Label Text=" " />-->
|
||||||
|
|
||||||
<mdview:MarkdownView x:Name="mdDescription" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.DescriptionHtml}" IsVisible="{Binding Item.DescriptionHtml, Converter={StaticResource NullToFalseConverter}}" />
|
<mdview:MarkdownView x:Name="mdDescription" Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Item.Markdown}" />
|
||||||
|
|
||||||
<Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
|
<!--<Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />-->
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
|
|
@ -17,7 +17,7 @@ namespace AideDeJeu.Views
|
||||||
|
|
||||||
BindingContext = this.viewModel = viewModel;
|
BindingContext = this.viewModel = viewModel;
|
||||||
|
|
||||||
mdNameVO.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s);
|
//mdNameVO.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s);
|
||||||
mdDescription.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s);
|
mdDescription.NavigateToLink = async (s) => await viewModel.Main.NavigateToLink(s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace AideDeJeuCmd
|
||||||
var document = Markdig.Parsers.MarkdownParser.Parse(md);
|
var document = Markdig.Parsers.MarkdownParser.Parse(md);
|
||||||
//DumpMarkdownDocument(document);
|
//DumpMarkdownDocument(document);
|
||||||
|
|
||||||
var spellss = document.ToSpells();
|
var spellss = document.ToSpells<SpellHD>();
|
||||||
Console.WriteLine("ok");
|
Console.WriteLine("ok");
|
||||||
var md2 = spellss.ToMarkdownString();
|
var md2 = spellss.ToMarkdownString();
|
||||||
if (md.CompareTo(md2) != 0)
|
if (md.CompareTo(md2) != 0)
|
||||||
|
|
@ -66,7 +66,7 @@ namespace AideDeJeuCmd
|
||||||
|
|
||||||
var result = string.Empty;
|
var result = string.Empty;
|
||||||
var md = await LoadStringAsync(dataDir + "spells_hd.md");
|
var md = await LoadStringAsync(dataDir + "spells_hd.md");
|
||||||
var items = AideDeJeu.Tools.MarkdownExtensions.MarkdownToSpells(md);
|
var items = AideDeJeu.Tools.MarkdownExtensions.MarkdownToSpells<SpellHD>(md);
|
||||||
|
|
||||||
var classes = new string[]
|
var classes = new string[]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue