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.Text.RegularExpressions;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
|
||||
public class BackgroundItem : Items
|
||||
public static class MarkdownExtensions
|
||||
{
|
||||
public string SkillProficiencies { get; set; }
|
||||
public string MasteredTools { get; set; }
|
||||
public string MasteredLanguages { get; set; }
|
||||
public string Equipment { get; set; }
|
||||
public static string StripMarkdownLink(this string md)
|
||||
{
|
||||
var regex = new Regex("\\[(?<text>.*?)\\]");
|
||||
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
|
||||
{
|
||||
get
|
||||
|
|
@ -21,7 +102,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 15)]
|
||||
public BackgroundSpecialtyItem Specialty
|
||||
{
|
||||
get
|
||||
|
|
@ -30,7 +111,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 16)]
|
||||
public PersonalityTraitItem PersonalityTraits
|
||||
{
|
||||
get
|
||||
|
|
@ -39,7 +120,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 17)]
|
||||
public PersonalityIdealItem Ideal
|
||||
{
|
||||
get
|
||||
|
|
@ -48,7 +129,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 17)]
|
||||
public PersonalityLinkItem Bond
|
||||
{
|
||||
get
|
||||
|
|
@ -57,7 +138,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 18)]
|
||||
public PersonalityDefectItem Flaw
|
||||
{
|
||||
get
|
||||
|
|
@ -66,7 +147,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 19)]
|
||||
public IEnumerable<SubBackgroundItem> SubBackgrounds
|
||||
{
|
||||
get
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace AideDeJeuLib
|
|||
{
|
||||
public class ClassItem : Item
|
||||
{
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 10)]
|
||||
public ClassHitPointsItem HitPoints
|
||||
{
|
||||
get
|
||||
|
|
@ -14,7 +14,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 11)]
|
||||
public ClassProficienciesItem Proficiencies
|
||||
{
|
||||
get
|
||||
|
|
@ -23,7 +23,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 12)]
|
||||
public ClassEquipmentItem Equipment
|
||||
{
|
||||
get
|
||||
|
|
@ -32,7 +32,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 13)]
|
||||
public ClassEvolutionItem Evolution
|
||||
{
|
||||
get
|
||||
|
|
@ -41,7 +41,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 14)]
|
||||
public IEnumerable<ClassFeatureItem> Features
|
||||
{
|
||||
get
|
||||
|
|
@ -50,7 +50,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 15)]
|
||||
public IEnumerable<SubClassItem> SubClasses
|
||||
{
|
||||
get
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
using System.Runtime.Serialization;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class SubClassItem : ClassItem
|
||||
{
|
||||
[YamlIgnore]
|
||||
[DataMember]
|
||||
public string ParentClassId { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ namespace AideDeJeuLib
|
|||
[DataMember]
|
||||
public virtual string ItemType { get; set; }
|
||||
|
||||
[YamlMember(Order = 0)]
|
||||
[DataMember(Name = "Item_Id", Order = 0)]
|
||||
[PrimaryKey]
|
||||
public virtual string Id { get; set; }
|
||||
|
|
@ -148,7 +149,7 @@ namespace AideDeJeuLib
|
|||
|
||||
[DataMember(Name = "Item_Name", Order = 3)]
|
||||
[Indexed]
|
||||
[YamlMember(Alias = "title")]
|
||||
[YamlMember(Alias = "title", Order = 1)]
|
||||
public virtual string Name { get; set; }
|
||||
|
||||
[YamlIgnore]
|
||||
|
|
@ -199,11 +200,23 @@ namespace AideDeJeuLib
|
|||
|
||||
[DataMember(Name = "Item_AltName", Order = 6)]
|
||||
[Indexed]
|
||||
[YamlIgnore]
|
||||
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]
|
||||
//[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
[YamlIgnore]
|
||||
//[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public virtual string AltNameText
|
||||
{
|
||||
get
|
||||
|
|
@ -240,6 +253,7 @@ namespace AideDeJeuLib
|
|||
private set { }
|
||||
}
|
||||
|
||||
[YamlMember(Order = 3)]
|
||||
[DataMember(Name = "Item_Source", Order = 7)]
|
||||
[Indexed]
|
||||
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();
|
||||
foreach (var mapping in ClassMapping)
|
||||
|
|
@ -562,7 +576,7 @@ namespace AideDeJeuLib
|
|||
public virtual string Table { get; set; }
|
||||
|
||||
|
||||
[YamlMember(Alias = "table")]
|
||||
[YamlMember(Alias = "table", Order = 4)]
|
||||
public virtual Dictionary<string, Dictionary<string, Dictionary<string, string>>> MapTable
|
||||
{
|
||||
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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using YamlDotNet.Serialization;
|
||||
|
||||
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
|
||||
{
|
||||
IEnumerable<string> Expand(string input)
|
||||
{
|
||||
return input != null ? input.Trim('.').Split(new String[] { ", ", " et " }, StringSplitOptions.None) : new string[] { };
|
||||
}
|
||||
[YamlIgnore]
|
||||
public string RegionsOfOrigin { get; set; }
|
||||
[YamlMember(Alias = "regions_of_origin")]
|
||||
[YamlMember(Alias = "regions_of_origin", Order = 10)]
|
||||
public IEnumerable<string> RegionsOfOriginExpanded
|
||||
{
|
||||
get
|
||||
|
|
@ -21,9 +33,10 @@ namespace AideDeJeuLib
|
|||
return Expand(RegionsOfOrigin);
|
||||
}
|
||||
}
|
||||
|
||||
[YamlIgnore]
|
||||
public string MainLanguages { get; set; }
|
||||
[YamlMember(Alias = "main_languages")]
|
||||
[YamlMember(Alias = "main_languages", Order = 11)]
|
||||
public IEnumerable<string> MainLanguagesExpanded
|
||||
{
|
||||
get
|
||||
|
|
@ -31,19 +44,36 @@ namespace AideDeJeuLib
|
|||
return Expand(MainLanguages);
|
||||
}
|
||||
}
|
||||
|
||||
[YamlIgnore]
|
||||
public string Aspirations { get; set; }
|
||||
[YamlMember(Alias = "aspirations")]
|
||||
public IEnumerable<string> AspirationsExpanded
|
||||
[YamlMember(Alias = "aspirations", Order = 12)]
|
||||
public IEnumerable<object> AspirationsExpanded
|
||||
{
|
||||
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]
|
||||
public string AvailableSkills { get; set; }
|
||||
[YamlMember(Alias = "available_skills")]
|
||||
[YamlMember(Alias = "available_skills", Order = 13)]
|
||||
public IEnumerable<string> AvailableSkillsExpanded
|
||||
{
|
||||
get
|
||||
|
|
@ -52,7 +82,7 @@ namespace AideDeJeuLib
|
|||
}
|
||||
}
|
||||
|
||||
[YamlMember]
|
||||
[YamlMember(Order = 14)]
|
||||
public OriginFeatureItem Feature
|
||||
{
|
||||
get
|
||||
|
|
|
|||
2
JoA
2
JoA
|
|
@ -1 +1 @@
|
|||
Subproject commit c626772a0de392952e44ed86ef394e52cf1a2d1a
|
||||
Subproject commit f4fd23d54f3e7670c69cd64d68a2efec72d1fb09
|
||||
Loading…
Add table
Add a link
Reference in a new issue