mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Test yaml
This commit is contained in:
parent
b6f6461007
commit
1f5daec15b
6 changed files with 166 additions and 35 deletions
|
|
@ -1,18 +1,99 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
namespace AideDeJeuLib
|
namespace AideDeJeuLib
|
||||||
{
|
{
|
||||||
|
|
||||||
public class BackgroundItem : Items
|
public static class MarkdownExtensions
|
||||||
{
|
{
|
||||||
public string SkillProficiencies { get; set; }
|
public static string StripMarkdownLink(this string md)
|
||||||
public string MasteredTools { get; set; }
|
{
|
||||||
public string MasteredLanguages { get; set; }
|
var regex = new Regex("\\[(?<text>.*?)\\]");
|
||||||
public string Equipment { get; set; }
|
var match = regex.Match(md ?? string.Empty);
|
||||||
|
if (!string.IsNullOrEmpty(match.Groups["text"].Value))
|
||||||
|
{
|
||||||
|
return match.Groups["text"].Value;
|
||||||
|
}
|
||||||
|
return md;
|
||||||
|
}
|
||||||
|
|
||||||
[YamlMember]
|
}
|
||||||
|
public class AndNode
|
||||||
|
{
|
||||||
|
[YamlMember(Alias = "and")]
|
||||||
|
public IEnumerable<object> Children { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OrNode
|
||||||
|
{
|
||||||
|
[YamlMember(Alias = "or")]
|
||||||
|
public IEnumerable<object> Children { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BackgroundItem : Item
|
||||||
|
{
|
||||||
|
protected IEnumerable<string> ExpandAnd(string input)
|
||||||
|
{
|
||||||
|
return input != null ? input.Trim('.').Split(new String[] { ", ", " et " }, StringSplitOptions.None) : new string[] { };
|
||||||
|
}
|
||||||
|
protected object ExpandOr(string orstring)
|
||||||
|
{
|
||||||
|
var split = orstring.Split(new string[] { " ou " }, System.StringSplitOptions.None);
|
||||||
|
if(split.Length > 1)
|
||||||
|
{
|
||||||
|
return new OrNode() { Children = split.Select(str => str.StripMarkdownLink()) };
|
||||||
|
}
|
||||||
|
return split[0].StripMarkdownLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
[YamlIgnore]
|
||||||
|
public string SkillProficiencies { get; set; }
|
||||||
|
[YamlMember(Alias = "skill_proficiencies", Order = 10)]
|
||||||
|
public object SkillProficienciesExpanded
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var splitand = ExpandAnd(SkillProficiencies).ToList();
|
||||||
|
if (splitand.Count > 1)
|
||||||
|
{
|
||||||
|
var ret = new List<object>();
|
||||||
|
foreach (var orstring in splitand)
|
||||||
|
{
|
||||||
|
ret.Add(ExpandOr(orstring));
|
||||||
|
}
|
||||||
|
return new AndNode() { Children = ret };
|
||||||
|
}
|
||||||
|
else if(splitand.Count == 1)
|
||||||
|
{
|
||||||
|
return ExpandOr(splitand[0]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[YamlMember(Order = 11)]
|
||||||
|
public string MasteredTools { get; set; }
|
||||||
|
|
||||||
|
[YamlMember(Order = 12)]
|
||||||
|
public string MasteredLanguages { get; set; }
|
||||||
|
|
||||||
|
[YamlIgnore]
|
||||||
|
public string Equipment { get; set; }
|
||||||
|
[YamlMember(Alias = "equipment", Order = 13)]
|
||||||
|
public IEnumerable<string> EquipmentExpanded
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Expand(Equipment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[YamlMember(Order = 14)]
|
||||||
public FeatureItem Feature
|
public FeatureItem Feature
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -21,7 +102,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 15)]
|
||||||
public BackgroundSpecialtyItem Specialty
|
public BackgroundSpecialtyItem Specialty
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -30,7 +111,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 16)]
|
||||||
public PersonalityTraitItem PersonalityTraits
|
public PersonalityTraitItem PersonalityTraits
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -39,7 +120,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 17)]
|
||||||
public PersonalityIdealItem Ideal
|
public PersonalityIdealItem Ideal
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -48,7 +129,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 17)]
|
||||||
public PersonalityLinkItem Bond
|
public PersonalityLinkItem Bond
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -57,7 +138,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 18)]
|
||||||
public PersonalityDefectItem Flaw
|
public PersonalityDefectItem Flaw
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -66,7 +147,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 19)]
|
||||||
public IEnumerable<SubBackgroundItem> SubBackgrounds
|
public IEnumerable<SubBackgroundItem> SubBackgrounds
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace AideDeJeuLib
|
||||||
{
|
{
|
||||||
public class ClassItem : Item
|
public class ClassItem : Item
|
||||||
{
|
{
|
||||||
[YamlMember]
|
[YamlMember(Order = 10)]
|
||||||
public ClassHitPointsItem HitPoints
|
public ClassHitPointsItem HitPoints
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -14,7 +14,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 11)]
|
||||||
public ClassProficienciesItem Proficiencies
|
public ClassProficienciesItem Proficiencies
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -23,7 +23,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 12)]
|
||||||
public ClassEquipmentItem Equipment
|
public ClassEquipmentItem Equipment
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -32,7 +32,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 13)]
|
||||||
public ClassEvolutionItem Evolution
|
public ClassEvolutionItem Evolution
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -41,7 +41,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 14)]
|
||||||
public IEnumerable<ClassFeatureItem> Features
|
public IEnumerable<ClassFeatureItem> Features
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -50,7 +50,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 15)]
|
||||||
public IEnumerable<SubClassItem> SubClasses
|
public IEnumerable<SubClassItem> SubClasses
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
namespace AideDeJeuLib
|
namespace AideDeJeuLib
|
||||||
{
|
{
|
||||||
public class SubClassItem : ClassItem
|
public class SubClassItem : ClassItem
|
||||||
{
|
{
|
||||||
|
[YamlIgnore]
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public string ParentClassId { get; set; }
|
public string ParentClassId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ namespace AideDeJeuLib
|
||||||
[DataMember]
|
[DataMember]
|
||||||
public virtual string ItemType { get; set; }
|
public virtual string ItemType { get; set; }
|
||||||
|
|
||||||
|
[YamlMember(Order = 0)]
|
||||||
[DataMember(Name = "Item_Id", Order = 0)]
|
[DataMember(Name = "Item_Id", Order = 0)]
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
public virtual string Id { get; set; }
|
public virtual string Id { get; set; }
|
||||||
|
|
@ -148,7 +149,7 @@ namespace AideDeJeuLib
|
||||||
|
|
||||||
[DataMember(Name = "Item_Name", Order = 3)]
|
[DataMember(Name = "Item_Name", Order = 3)]
|
||||||
[Indexed]
|
[Indexed]
|
||||||
[YamlMember(Alias = "title")]
|
[YamlMember(Alias = "title", Order = 1)]
|
||||||
public virtual string Name { get; set; }
|
public virtual string Name { get; set; }
|
||||||
|
|
||||||
[YamlIgnore]
|
[YamlIgnore]
|
||||||
|
|
@ -199,11 +200,23 @@ namespace AideDeJeuLib
|
||||||
|
|
||||||
[DataMember(Name = "Item_AltName", Order = 6)]
|
[DataMember(Name = "Item_AltName", Order = 6)]
|
||||||
[Indexed]
|
[Indexed]
|
||||||
|
[YamlIgnore]
|
||||||
public virtual string AltName { get; set; }
|
public virtual string AltName { get; set; }
|
||||||
|
|
||||||
|
[YamlMember(Alias = "alias", Order = 2)]
|
||||||
|
public string Alias
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var altname = AltNameText;
|
||||||
|
if (altname.Length > 0) return altname;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[DataMember]
|
[DataMember]
|
||||||
//[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
|
||||||
[YamlIgnore]
|
[YamlIgnore]
|
||||||
|
//[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||||
public virtual string AltNameText
|
public virtual string AltNameText
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -240,6 +253,7 @@ namespace AideDeJeuLib
|
||||||
private set { }
|
private set { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[YamlMember(Order = 3)]
|
||||||
[DataMember(Name = "Item_Source", Order = 7)]
|
[DataMember(Name = "Item_Source", Order = 7)]
|
||||||
[Indexed]
|
[Indexed]
|
||||||
public virtual string Source { get; set; }
|
public virtual string Source { get; set; }
|
||||||
|
|
@ -349,7 +363,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Item ParseYamlMarkdown(string yamlmd)
|
protected static Item ParseYamlMarkdown(string yamlmd)
|
||||||
{
|
{
|
||||||
var builder = new DeserializerBuilder();
|
var builder = new DeserializerBuilder();
|
||||||
foreach (var mapping in ClassMapping)
|
foreach (var mapping in ClassMapping)
|
||||||
|
|
@ -562,7 +576,7 @@ namespace AideDeJeuLib
|
||||||
public virtual string Table { get; set; }
|
public virtual string Table { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[YamlMember(Alias = "table")]
|
[YamlMember(Alias = "table", Order = 4)]
|
||||||
public virtual Dictionary<string, Dictionary<string, Dictionary<string, string>>> MapTable
|
public virtual Dictionary<string, Dictionary<string, Dictionary<string, string>>> MapTable
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -642,6 +656,10 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected IEnumerable<string> Expand(string input)
|
||||||
|
{
|
||||||
|
return input != null ? input.Trim('.').Split(new String[] { ", ", " et " }, StringSplitOptions.None) : new string[] { };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,31 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
namespace AideDeJeuLib
|
namespace AideDeJeuLib
|
||||||
{
|
{
|
||||||
|
public class NameValueNode
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Value { get; set; }
|
||||||
|
public NameValueNode(string namevalue, string separator)
|
||||||
|
{
|
||||||
|
var split = namevalue.Split(new String[] { " " }, StringSplitOptions.None);
|
||||||
|
if (split.Length == 2)
|
||||||
|
{
|
||||||
|
this.Name = split[0];
|
||||||
|
this.Value = split[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public class OriginItem : Item
|
public class OriginItem : Item
|
||||||
{
|
{
|
||||||
IEnumerable<string> Expand(string input)
|
|
||||||
{
|
|
||||||
return input != null ? input.Trim('.').Split(new String[] { ", ", " et " }, StringSplitOptions.None) : new string[] { };
|
|
||||||
}
|
|
||||||
[YamlIgnore]
|
[YamlIgnore]
|
||||||
public string RegionsOfOrigin { get; set; }
|
public string RegionsOfOrigin { get; set; }
|
||||||
[YamlMember(Alias = "regions_of_origin")]
|
[YamlMember(Alias = "regions_of_origin", Order = 10)]
|
||||||
public IEnumerable<string> RegionsOfOriginExpanded
|
public IEnumerable<string> RegionsOfOriginExpanded
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -21,9 +33,10 @@ namespace AideDeJeuLib
|
||||||
return Expand(RegionsOfOrigin);
|
return Expand(RegionsOfOrigin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlIgnore]
|
[YamlIgnore]
|
||||||
public string MainLanguages { get; set; }
|
public string MainLanguages { get; set; }
|
||||||
[YamlMember(Alias = "main_languages")]
|
[YamlMember(Alias = "main_languages", Order = 11)]
|
||||||
public IEnumerable<string> MainLanguagesExpanded
|
public IEnumerable<string> MainLanguagesExpanded
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -31,19 +44,36 @@ namespace AideDeJeuLib
|
||||||
return Expand(MainLanguages);
|
return Expand(MainLanguages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlIgnore]
|
[YamlIgnore]
|
||||||
public string Aspirations { get; set; }
|
public string Aspirations { get; set; }
|
||||||
[YamlMember(Alias = "aspirations")]
|
[YamlMember(Alias = "aspirations", Order = 12)]
|
||||||
public IEnumerable<string> AspirationsExpanded
|
public IEnumerable<object> AspirationsExpanded
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Expand(Aspirations);
|
return Expand(Aspirations).Select(aspi => new NameValueNode(aspi, " "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[YamlMember(Alias = "aspirations2", Order = 12)]
|
||||||
|
public Dictionary<string, string> AspirationsExpanded2
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var aspis = Expand(Aspirations);
|
||||||
|
var dico = new Dictionary<string, string>();
|
||||||
|
foreach(var aspi in aspis)
|
||||||
|
{
|
||||||
|
var nv = new NameValueNode(aspi, " ");
|
||||||
|
dico[nv.Name] = nv.Value;
|
||||||
|
}
|
||||||
|
return dico;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[YamlIgnore]
|
[YamlIgnore]
|
||||||
public string AvailableSkills { get; set; }
|
public string AvailableSkills { get; set; }
|
||||||
[YamlMember(Alias = "available_skills")]
|
[YamlMember(Alias = "available_skills", Order = 13)]
|
||||||
public IEnumerable<string> AvailableSkillsExpanded
|
public IEnumerable<string> AvailableSkillsExpanded
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -52,7 +82,7 @@ namespace AideDeJeuLib
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[YamlMember]
|
[YamlMember(Order = 14)]
|
||||||
public OriginFeatureItem Feature
|
public OriginFeatureItem Feature
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
||||||
2
JoA
2
JoA
|
|
@ -1 +1 @@
|
||||||
Subproject commit c626772a0de392952e44ed86ef394e52cf1a2d1a
|
Subproject commit f4fd23d54f3e7670c69cd64d68a2efec72d1fb09
|
||||||
Loading…
Add table
Add a link
Reference in a new issue