1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 14:35:45 +00:00

Modifs export

This commit is contained in:
Yan Maniez 2020-06-01 18:42:31 +02:00
parent 7b0ce8c54c
commit 9126be1c27
10 changed files with 192 additions and 24 deletions

View file

@ -1,17 +1,18 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using YamlDotNet.Serialization;
namespace AideDeJeuLib namespace AideDeJeuLib
{ {
public class BackgroundSpecialtyItem : Item, TableProperty public class BackgroundSpecialtyItem : Item
{ {
public string Table { get; set; } [YamlIgnore]
public List<string> BindableTable public List<string> BindableTable
{ {
get get
{ {
return ExtractSimpleTable(Table); return Table != null ? ExtractSimpleTable(Table) : new List<string>();
} }
} }
public List<string> ExtractSimpleTable(string table) public List<string> ExtractSimpleTable(string table)

View file

@ -1,7 +1,6 @@
namespace AideDeJeuLib namespace AideDeJeuLib
{ {
public class PersonalityItem : Item, TableProperty public class PersonalityItem : Item
{ {
public string Table { get; set; }
} }
} }

View file

@ -1,11 +1,50 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using YamlDotNet.Serialization;
namespace AideDeJeuLib namespace AideDeJeuLib
{ {
public class ClassEvolutionItem : Item public class ClassEvolutionItem : Item
{ {
public string Table { get; set; } [YamlIgnore]
public override Dictionary<string, Dictionary<string, Dictionary<string, string>>> MapTable
{
get
{
return null;
}
}
[YamlMember(Alias = "evolution_table")]
public Dictionary<string, Dictionary<string, Dictionary<string, string[]>>> MapEvolutionTable
{
get
{
return Table != null ? ExtractMapEvolutionTable(Table) : null;
}
}
public Dictionary<string, Dictionary<string, Dictionary<string, string[]>>> ExtractMapEvolutionTable(string table)
{
var map = new Dictionary<string, Dictionary<string, string[]>>();
var matrix = ExtractMatrixTable(table);
for (int y = 2; y < matrix.GetLength(1); y++)
{
map[matrix[0, y]] = new Dictionary<string, string[]>();
}
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<string, Dictionary<string, Dictionary<string, string[]>>>();
supermap[matrix[0, 0]] = map;
return supermap;
}
[YamlIgnore]
public string[,] BindableTable public string[,] BindableTable
{ {
get get

View file

@ -117,6 +117,7 @@ namespace AideDeJeuLib
// throw new NotImplementedException(); // throw new NotImplementedException();
//} //}
[YamlIgnore]
[DataMember] [DataMember]
public virtual string ItemType { get; set; } public virtual string ItemType { get; set; }
@ -124,10 +125,12 @@ namespace AideDeJeuLib
[PrimaryKey] [PrimaryKey]
public virtual string Id { get; set; } public virtual string Id { get; set; }
[YamlIgnore]
[DataMember(Name = "Item_RootId", Order = 1)] [DataMember(Name = "Item_RootId", Order = 1)]
[Indexed] [Indexed]
public virtual string RootId { get; set; } public virtual string RootId { get; set; }
[YamlIgnore]
[DataMember(Name = "Item_ParentLink", Order = 2)] [DataMember(Name = "Item_ParentLink", Order = 2)]
[Indexed] [Indexed]
public virtual string ParentLink { get; set; } public virtual string ParentLink { get; set; }
@ -136,6 +139,7 @@ namespace AideDeJeuLib
[Indexed] [Indexed]
public virtual string Name { get; set; } public virtual string Name { get; set; }
[YamlIgnore]
[DataMember] [DataMember]
[Indexed] [Indexed]
public virtual string NormalizedName public virtual string NormalizedName
@ -147,6 +151,7 @@ namespace AideDeJeuLib
private set { } private set { }
} }
[YamlIgnore]
[DataMember(Name = "Item_ParentName", Order = 4)] [DataMember(Name = "Item_ParentName", Order = 4)]
[Indexed] [Indexed]
public virtual string ParentName { get; set; } public virtual string ParentName { get; set; }
@ -176,8 +181,10 @@ namespace AideDeJeuLib
} }
} }
[YamlIgnore]
[DataMember(Name = "Item_NameLevel", Order = 5)] [DataMember(Name = "Item_NameLevel", Order = 5)]
public virtual int NameLevel { get; set; } public virtual int NameLevel { get; set; }
[DataMember(Name = "Item_AltName", Order = 6)] [DataMember(Name = "Item_AltName", Order = 6)]
[Indexed] [Indexed]
public virtual string AltName { get; set; } public virtual string AltName { get; set; }
@ -209,6 +216,7 @@ namespace AideDeJeuLib
private set { } private set { }
} }
[YamlIgnore]
[DataMember] [DataMember]
[Indexed] [Indexed]
public virtual string NormalizedAltName public virtual string NormalizedAltName
@ -227,6 +235,8 @@ namespace AideDeJeuLib
[YamlIgnore] [YamlIgnore]
[DataMember(Name = "Item_Markdown", Order = 8)] [DataMember(Name = "Item_Markdown", Order = 8)]
public virtual string Markdown { get; set; } public virtual string Markdown { get; set; }
[YamlIgnore]
[DataMember(Name = "Item_FullText", Order = 9)] [DataMember(Name = "Item_FullText", Order = 9)]
public virtual string FullText { get; set; } public virtual string FullText { get; set; }
@ -280,13 +290,14 @@ namespace AideDeJeuLib
get get
{ {
var builder = new SerializerBuilder(); var builder = new SerializerBuilder();
foreach(var mapping in ClassMapping) //foreach(var mapping in ClassMapping)
{ //{
builder = builder.WithTagMapping($"!{mapping.Key}", mapping.Value); // builder = builder.WithTagMapping($"!{mapping.Key}", mapping.Value);
} //}
var serializer = builder var serializer = builder
.EnsureRoundtrip() //.EnsureRoundtrip()
.WithNamingConvention(new PascalCaseNamingConvention()) //.WithNamingConvention(new PascalCaseNamingConvention())
.WithNamingConvention(new UnderscoredNamingConvention())
.Build(); .Build();
return serializer.Serialize(this); return serializer.Serialize(this);
} }
@ -298,8 +309,8 @@ namespace AideDeJeuLib
{ {
get get
{ {
//return $"---\n{Yaml}---\n{CleanMarkdown}"; return $"---\n{Yaml}---\n{CleanMarkdown}";
return CleanMarkdown; //return CleanMarkdown;
} }
} }
@ -353,7 +364,8 @@ namespace AideDeJeuLib
{ {
get get
{ {
var md = Markdown ?? string.Empty; //var md = Markdown ?? string.Empty;
var md = Description ?? string.Empty;
var rx = new Regex("<!--.*?-->"); var rx = new Regex("<!--.*?-->");
md = rx.Replace(md, ""); md = rx.Replace(md, "");
return md; return md;
@ -397,6 +409,7 @@ namespace AideDeJeuLib
static IDeserializer _Deserializer = new DeserializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build(); static IDeserializer _Deserializer = new DeserializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build();
static ISerializer _Serializer = new SerializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build(); static ISerializer _Serializer = new SerializerBuilder().WithNamingConvention(new PascalCaseNamingConvention()).Build();
[YamlIgnore]
protected OrderedDictionary Attributes { get; private set; } = new OrderedDictionary(); protected OrderedDictionary Attributes { get; private set; } = new OrderedDictionary();
//[NotMapped] //[NotMapped]
//[IgnoreDataMember] //[IgnoreDataMember]
@ -459,6 +472,7 @@ namespace AideDeJeuLib
} }
} }
[YamlIgnore]
[DataMember] [DataMember]
public virtual string AttributesDictionary { get; set; } public virtual string AttributesDictionary { get; set; }
// { // {
@ -527,7 +541,85 @@ namespace AideDeJeuLib
} }
[YamlIgnore]
[DataMember] [DataMember]
public virtual string Description { get; set; } public virtual string Description { get; set; }
[YamlIgnore]
[DataMember]
public virtual string Table { get; set; }
[YamlMember(Alias = "table")]
public virtual Dictionary<string, Dictionary<string, Dictionary<string, string>>> MapTable
{
get
{
return Table != null ? ExtractMapTable(Table) : null;
}
}
public Dictionary<string, Dictionary<string, Dictionary<string, string>>> ExtractMapTable(string table)
{
var map = new Dictionary<string, Dictionary<string, string>>();
var matrix = ExtractMatrixTable(table);
for (int y = 2; y < matrix.GetLength(1); y++)
{
map[matrix[0, y]] = new Dictionary<string, string>();
}
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<string, Dictionary<string, Dictionary<string, string>>>();
supermap[matrix[0, 0]] = map;
return supermap;
}
public Dictionary<string, List<string>> ExtractSimpleMapTable(string table)
{
var map = new Dictionary<string, List<string>>();
var matrix = ExtractMatrixTable(table);
for (int x = 0; x < matrix.GetLength(0); x++)
{
map[matrix[x, 0]] = new List<string>();
}
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("<!--br-->", " ").Replace(" ", " ");
matrix[x, y] = text;
x++;
}
}
y++;
}
return matrix;
}
} }
} }

View file

@ -1,7 +1,3 @@
namespace AideDeJeuLib namespace AideDeJeuLib
{ {
interface TableProperty
{
string Table { get; set; }
}
} }

View file

@ -1,14 +1,55 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using YamlDotNet.Serialization;
namespace AideDeJeuLib namespace AideDeJeuLib
{ {
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]
public string RegionsOfOrigin { get; set; } public string RegionsOfOrigin { get; set; }
[YamlMember(Alias = "regions_of_origin")]
public IEnumerable<string> RegionsOfOriginExpanded
{
get
{
return Expand(RegionsOfOrigin);
}
}
[YamlIgnore]
public string MainLanguages { get; set; } public string MainLanguages { get; set; }
[YamlMember(Alias = "main_languages")]
public IEnumerable<string> MainLanguagesExpanded
{
get
{
return Expand(MainLanguages);
}
}
[YamlIgnore]
public string Aspirations { get; set; } public string Aspirations { get; set; }
[YamlMember(Alias = "aspirations")]
public IEnumerable<string> AspirationsExpanded
{
get
{
return Expand(Aspirations);
}
}
[YamlIgnore]
public string AvailableSkills { get; set; } public string AvailableSkills { get; set; }
[YamlMember(Alias = "available_skills")]
public IEnumerable<string> AvailableSkillsExpanded
{
get
{
return Expand(AvailableSkills);
}
}
} }
} }

View file

@ -348,7 +348,7 @@ namespace AideDeJeuCmd
} }
return dico; return dico;
} }
static string outDir = $@"..\..\..\..\..\{AideDeJeu.Config.Domain}\HD\"; static string outDir = $@"..\..\..\..\..\{AideDeJeu.Config.Domain}\export\";
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
@ -1111,7 +1111,7 @@ namespace AideDeJeuCmd
{ {
Console.WriteLine(filename); Console.WriteLine(filename);
} }
//await SaveStringAsync(filename, yaml); await SaveStringAsync(filename, yaml);
var filtervm = item.GetNewFilterViewModel(); var filtervm = item.GetNewFilterViewModel();
if (filtervm != null) if (filtervm != null)

Binary file not shown.

2
JoA

@ -1 +1 @@
Subproject commit 670c2340c7711b3bd3720d438022640b1777aac7 Subproject commit a969e609cd91f2c7ba69feb9f698bf3fde2c6422

View file

@ -274,7 +274,7 @@ packages:
name: provider name: provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.1" version: "4.1.2"
pub_semver: pub_semver:
dependency: transitive dependency: transitive
description: description:
@ -295,7 +295,7 @@ packages:
name: sembast name: sembast
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.4" version: "2.4.4+1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter