diff --git a/AideDeJeu/AideDeJeu/Models/Backgrounds/BackgroundSpecialtyItem.cs b/AideDeJeu/AideDeJeu/Models/Backgrounds/BackgroundSpecialtyItem.cs index 67979c4b..b0fe9b39 100644 --- a/AideDeJeu/AideDeJeu/Models/Backgrounds/BackgroundSpecialtyItem.cs +++ b/AideDeJeu/AideDeJeu/Models/Backgrounds/BackgroundSpecialtyItem.cs @@ -1,17 +1,18 @@ using System.Collections.Generic; using System.Linq; +using YamlDotNet.Serialization; namespace AideDeJeuLib { - public class BackgroundSpecialtyItem : Item, TableProperty + public class BackgroundSpecialtyItem : Item { - public string Table { get; set; } + [YamlIgnore] public List BindableTable { get { - return ExtractSimpleTable(Table); + return Table != null ? ExtractSimpleTable(Table) : new List(); } } public List ExtractSimpleTable(string table) diff --git a/AideDeJeu/AideDeJeu/Models/Backgrounds/PersonalityItem.cs b/AideDeJeu/AideDeJeu/Models/Backgrounds/PersonalityItem.cs index 495187e1..31d6ae23 100644 --- a/AideDeJeu/AideDeJeu/Models/Backgrounds/PersonalityItem.cs +++ b/AideDeJeu/AideDeJeu/Models/Backgrounds/PersonalityItem.cs @@ -1,7 +1,6 @@ namespace AideDeJeuLib { - public class PersonalityItem : Item, TableProperty + public class PersonalityItem : Item { - public string Table { get; set; } } } diff --git a/AideDeJeu/AideDeJeu/Models/Classes/ClassEvolutionItem.cs b/AideDeJeu/AideDeJeu/Models/Classes/ClassEvolutionItem.cs index 528927b4..ddec4d6c 100644 --- a/AideDeJeu/AideDeJeu/Models/Classes/ClassEvolutionItem.cs +++ b/AideDeJeu/AideDeJeu/Models/Classes/ClassEvolutionItem.cs @@ -1,11 +1,50 @@ using System.Collections.Generic; using System.Linq; +using YamlDotNet.Serialization; namespace AideDeJeuLib { public class ClassEvolutionItem : Item { - public string Table { get; set; } + [YamlIgnore] + public override Dictionary>> MapTable + { + get + { + return null; + } + } + [YamlMember(Alias = "evolution_table")] + public Dictionary>> MapEvolutionTable + { + get + { + return Table != null ? ExtractMapEvolutionTable(Table) : null; + } + } + + public Dictionary>> ExtractMapEvolutionTable(string table) + { + var map = new Dictionary>(); + var matrix = ExtractMatrixTable(table); + for (int y = 2; y < matrix.GetLength(1); y++) + { + map[matrix[0, y]] = new Dictionary(); + } + for (int x = 1; x < matrix.GetLength(0); x++) + { + for (int y = 2; y < matrix.GetLength(1); y++) + { + map[matrix[0, y]][matrix[x, 0]] = matrix[x, y].Split(new string[] { ", " }, System.StringSplitOptions.None); + } + } + var supermap = new Dictionary>>(); + supermap[matrix[0, 0]] = map; + return supermap; + } + + + [YamlIgnore] public string[,] BindableTable { get diff --git a/AideDeJeu/AideDeJeu/Models/Items/Item.cs b/AideDeJeu/AideDeJeu/Models/Items/Item.cs index dbec9a65..f4c10c02 100644 --- a/AideDeJeu/AideDeJeu/Models/Items/Item.cs +++ b/AideDeJeu/AideDeJeu/Models/Items/Item.cs @@ -117,6 +117,7 @@ namespace AideDeJeuLib // throw new NotImplementedException(); //} + [YamlIgnore] [DataMember] public virtual string ItemType { get; set; } @@ -124,10 +125,12 @@ namespace AideDeJeuLib [PrimaryKey] public virtual string Id { get; set; } + [YamlIgnore] [DataMember(Name = "Item_RootId", Order = 1)] [Indexed] public virtual string RootId { get; set; } + [YamlIgnore] [DataMember(Name = "Item_ParentLink", Order = 2)] [Indexed] public virtual string ParentLink { get; set; } @@ -136,6 +139,7 @@ namespace AideDeJeuLib [Indexed] public virtual string Name { get; set; } + [YamlIgnore] [DataMember] [Indexed] public virtual string NormalizedName @@ -147,6 +151,7 @@ namespace AideDeJeuLib private set { } } + [YamlIgnore] [DataMember(Name = "Item_ParentName", Order = 4)] [Indexed] public virtual string ParentName { get; set; } @@ -176,8 +181,10 @@ namespace AideDeJeuLib } } + [YamlIgnore] [DataMember(Name = "Item_NameLevel", Order = 5)] public virtual int NameLevel { get; set; } + [DataMember(Name = "Item_AltName", Order = 6)] [Indexed] public virtual string AltName { get; set; } @@ -209,6 +216,7 @@ namespace AideDeJeuLib private set { } } + [YamlIgnore] [DataMember] [Indexed] public virtual string NormalizedAltName @@ -227,6 +235,8 @@ namespace AideDeJeuLib [YamlIgnore] [DataMember(Name = "Item_Markdown", Order = 8)] public virtual string Markdown { get; set; } + + [YamlIgnore] [DataMember(Name = "Item_FullText", Order = 9)] public virtual string FullText { get; set; } @@ -280,13 +290,14 @@ namespace AideDeJeuLib get { var builder = new SerializerBuilder(); - foreach(var mapping in ClassMapping) - { - builder = builder.WithTagMapping($"!{mapping.Key}", mapping.Value); - } + //foreach(var mapping in ClassMapping) + //{ + // builder = builder.WithTagMapping($"!{mapping.Key}", mapping.Value); + //} var serializer = builder - .EnsureRoundtrip() - .WithNamingConvention(new PascalCaseNamingConvention()) + //.EnsureRoundtrip() + //.WithNamingConvention(new PascalCaseNamingConvention()) + .WithNamingConvention(new UnderscoredNamingConvention()) .Build(); return serializer.Serialize(this); } @@ -298,8 +309,8 @@ namespace AideDeJeuLib { get { - //return $"---\n{Yaml}---\n{CleanMarkdown}"; - return CleanMarkdown; + return $"---\n{Yaml}---\n{CleanMarkdown}"; + //return CleanMarkdown; } } @@ -353,7 +364,8 @@ namespace AideDeJeuLib { get { - var md = Markdown ?? string.Empty; + //var md = Markdown ?? string.Empty; + var md = Description ?? string.Empty; var rx = new Regex(""); md = rx.Replace(md, ""); return md; @@ -397,6 +409,7 @@ namespace AideDeJeuLib static IDeserializer _Deserializer = new DeserializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build(); static ISerializer _Serializer = new SerializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build(); + [YamlIgnore] protected OrderedDictionary Attributes { get; private set; } = new OrderedDictionary(); //[NotMapped] //[IgnoreDataMember] @@ -459,6 +472,7 @@ namespace AideDeJeuLib } } + [YamlIgnore] [DataMember] public virtual string AttributesDictionary { get; set; } // { @@ -527,7 +541,85 @@ namespace AideDeJeuLib } + [YamlIgnore] [DataMember] public virtual string Description { get; set; } + + [YamlIgnore] + [DataMember] + public virtual string Table { get; set; } + + + [YamlMember(Alias = "table")] + public virtual Dictionary>> MapTable + { + get + { + return Table != null ? ExtractMapTable(Table) : null; + } + } + + public Dictionary>> ExtractMapTable(string table) + { + var map = new Dictionary>(); + var matrix = ExtractMatrixTable(table); + for (int y = 2; y < matrix.GetLength(1); y++) + { + map[matrix[0, y]] = new Dictionary(); + } + for (int x = 1; x < matrix.GetLength(0); x++) + { + for (int y = 2; y < matrix.GetLength(1); y++) + { + map[matrix[0, y]][matrix[x,0]] = matrix[x, y]; + } + } + var supermap = new Dictionary>>(); + supermap[matrix[0, 0]] = map; + return supermap; + } + public Dictionary> ExtractSimpleMapTable(string table) + { + var map = new Dictionary>(); + var matrix = ExtractMatrixTable(table); + for (int x = 0; x < matrix.GetLength(0); x++) + { + map[matrix[x, 0]] = new List(); + } + for (int x = 0; x < matrix.GetLength(0); x++) + { + for (int y = 2; y < matrix.GetLength(1); y++) + { + map[matrix[x, 0]].Add(matrix[x, y]); + } + } + return map; + } + public string[,] ExtractMatrixTable(string table) + { + var rows = table.Split('\n'); + var countRows = rows.Count(r => r.StartsWith("|")); + var countCols = rows.FirstOrDefault().Count(c => c == '|') - 1; + var matrix = new string[countCols, countRows]; + var y = 0; + foreach (var row in rows) + { + var x = 0; + if (row.StartsWith("|")) + { + var allcols = row.Split('|'); + var cols = allcols.Skip(1).Take(allcols.Length - 2); + foreach (var col in cols) + { + var text = col.Replace("", " ").Replace(" ", " "); + matrix[x, y] = text; + x++; + } + } + y++; + } + return matrix; + } + } } diff --git a/AideDeJeu/AideDeJeu/Models/Items/Properties.cs b/AideDeJeu/AideDeJeu/Models/Items/Properties.cs index a9b514ba..2c953980 100644 --- a/AideDeJeu/AideDeJeu/Models/Items/Properties.cs +++ b/AideDeJeu/AideDeJeu/Models/Items/Properties.cs @@ -1,7 +1,3 @@ namespace AideDeJeuLib { - interface TableProperty - { - string Table { get; set; } - } } diff --git a/AideDeJeu/AideDeJeu/Models/Origins/OriginItem.cs b/AideDeJeu/AideDeJeu/Models/Origins/OriginItem.cs index 392f7bd7..2d717bc9 100644 --- a/AideDeJeu/AideDeJeu/Models/Origins/OriginItem.cs +++ b/AideDeJeu/AideDeJeu/Models/Origins/OriginItem.cs @@ -1,14 +1,55 @@ using System; using System.Collections.Generic; using System.Text; +using YamlDotNet.Serialization; namespace AideDeJeuLib { public class OriginItem : Item { + IEnumerable 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")] + public IEnumerable RegionsOfOriginExpanded + { + get + { + return Expand(RegionsOfOrigin); + } + } + [YamlIgnore] public string MainLanguages { get; set; } + [YamlMember(Alias = "main_languages")] + public IEnumerable MainLanguagesExpanded + { + get + { + return Expand(MainLanguages); + } + } + [YamlIgnore] public string Aspirations { get; set; } + [YamlMember(Alias = "aspirations")] + public IEnumerable AspirationsExpanded + { + get + { + return Expand(Aspirations); + } + } + [YamlIgnore] public string AvailableSkills { get; set; } + [YamlMember(Alias = "available_skills")] + public IEnumerable AvailableSkillsExpanded + { + get + { + return Expand(AvailableSkills); + } + } } } diff --git a/AideDeJeu/AideDeJeuCmd/Program.cs b/AideDeJeu/AideDeJeuCmd/Program.cs index dec31bd7..a82c1f8d 100644 --- a/AideDeJeu/AideDeJeuCmd/Program.cs +++ b/AideDeJeu/AideDeJeuCmd/Program.cs @@ -348,7 +348,7 @@ namespace AideDeJeuCmd } return dico; } - static string outDir = $@"..\..\..\..\..\{AideDeJeu.Config.Domain}\HD\"; + static string outDir = $@"..\..\..\..\..\{AideDeJeu.Config.Domain}\export\"; static async Task Main(string[] args) { @@ -1111,7 +1111,7 @@ namespace AideDeJeuCmd { Console.WriteLine(filename); } - //await SaveStringAsync(filename, yaml); + await SaveStringAsync(filename, yaml); var filtervm = item.GetNewFilterViewModel(); if (filtervm != null) diff --git a/Data/library_JoA.db b/Data/library_JoA.db index 2794ebf0..764b98da 100644 Binary files a/Data/library_JoA.db and b/Data/library_JoA.db differ diff --git a/JoA b/JoA index 670c2340..a969e609 160000 --- a/JoA +++ b/JoA @@ -1 +1 @@ -Subproject commit 670c2340c7711b3bd3720d438022640b1777aac7 +Subproject commit a969e609cd91f2c7ba69feb9f698bf3fde2c6422 diff --git a/aidedejeu_flutter/pubspec.lock b/aidedejeu_flutter/pubspec.lock index 864501f6..efc60d66 100644 --- a/aidedejeu_flutter/pubspec.lock +++ b/aidedejeu_flutter/pubspec.lock @@ -274,7 +274,7 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "4.1.1" + version: "4.1.2" pub_semver: dependency: transitive description: @@ -295,7 +295,7 @@ packages: name: sembast url: "https://pub.dartlang.org" source: hosted - version: "2.4.4" + version: "2.4.4+1" sky_engine: dependency: transitive description: flutter