1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2026-05-15 00:50:36 +00:00
This commit is contained in:
Yan Maniez 2019-04-19 15:24:18 +02:00
parent 9bdd734df3
commit fba536500f
1659 changed files with 7951 additions and 7153 deletions

View file

@ -6,27 +6,37 @@ namespace AideDeJeuLib
public class ClassEvolutionItem : Item
{
public string Table { get; set; }
public List<string> BindableTable
public string[,] BindableTable
{
get
{
return ExtractSimpleTable(Table);
}
}
public List<string> ExtractSimpleTable(string table)
public string[,] ExtractSimpleTable(string table)
{
var lines = table.Split('\n');
var result = new List<string>();
foreach (var line in lines.Skip(2))
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)
{
if (line.StartsWith("|"))
var x = 0;
if (row.StartsWith("|"))
{
var cols = line.Split('|');
var text = cols[2].Replace("<!--br-->", " ").Replace(" ", " ");
result.Add(text);
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 result;
return matrix;
}
}

View file

@ -33,21 +33,46 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
public string Description { get { return Class?.Description; } }
public string Markdown { get { return Class?.Markdown; } }
private List<ClassFeatureItem> _LeveledFeatures = null;
public List<ClassFeatureItem> LeveledFeatures
{
get
{
var table = Evolution.ExtractSimpleTable(Evolution.Table);
var feats = table[1];
var leveledFeats = new List<ClassFeatureItem>();
foreach(var feature in Features)
return _LeveledFeatures;
}
set
{
SetProperty(ref _LeveledFeatures, value);
}
}
public int ColumnIndex(string[,] table, string columnName)
{
for (var c = 0; c < table.GetLength(0); c++)
{
if(table[c, 0] == columnName)
{
if(feats.Contains(feature.Name))
return c;
}
}
return -1;
}
public void InitLeveledFeatures()
{
if (Evolution != null)
{
var table = Evolution.ExtractSimpleTable(Evolution.Table);
var feats = table[ColumnIndex(table, "Aptitudes"), 2];
var leveledFeats = new List<ClassFeatureItem>();
foreach (var feature in Features)
{
if (feats.Contains(feature.Id))
{
leveledFeats.Add(feature);
}
}
return leveledFeats;
LeveledFeatures = leveledFeats;
}
}
@ -60,6 +85,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
Equipment = await context.ClassEquipments.Where(c => c.ParentLink == Class.Id).FirstOrDefaultAsync();
Evolution = await context.ClassEvolutions.Where(c => c.ParentLink == Class.Id).FirstOrDefaultAsync();
Features = await context.ClassFeatures.Where(c => c.ParentLink == Class.Id).ToListAsync();
InitLeveledFeatures();
}
}
}

View file

@ -213,6 +213,49 @@ namespace AideDeJeu.ViewModels
}
}
class Matrix
{
private Dictionary<string, Object> Data = new Dictionary<string, object>();
public object this[int x, int y]
{
get
{
string key = this.GetKey(x, y);
return Data.ContainsKey(key) ? Data[key] : null;
}
set
{
string key = this.GetKey(x, y);
if (value == null)
Data.Remove(key);
else
Data[key] = value;
}
}
private string GetKey(int x, int y)
{
return String.Join(",", new[] { x, y });
}
}
public void ParseItemProperties(string source, Item item, Markdig.Extensions.Tables.Table table)
{
Markdig.Extensions.Tables.TableRow firstRow = table.FirstOrDefault() as Markdig.Extensions.Tables.TableRow;
var matrix = new string[firstRow.Count, table.Count];
int y = 0;
foreach (Markdig.Extensions.Tables.TableRow row in table)
{
int x = 0;
foreach (Markdig.Extensions.Tables.TableCell col in row)
{
ParseItemProperties(source, item, col);
matrix[x, y] = col.ToMarkdownString();
x++;
}
y++;
}
Debug.WriteLine(matrix);
}
public void ParseItemProperties(string source, Item item, ContainerBlock blocks)
{
foreach (var block in blocks)

View file

@ -85,9 +85,22 @@
<views:ItemView BindingContext="{Binding}" Name="#### Jets de sauvegarde" Description="{Binding SelectedPlayerCharacter.Class.Proficiencies.SavingThrows}" />
<views:ItemView BindingContext="{Binding}" Name="#### Compétences" Description="{Binding SelectedPlayerCharacter.Class.Proficiencies.Skills}" />
<views:ItemView BindingContext="{Binding}" Name="#### Équipement" Description="{Binding SelectedPlayerCharacter.Class.Equipment.Description}" />
<StackLayout BindableLayout.ItemsSource="{Binding SelectedPlayerCharacter.Class.LeveledFeatures}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout>
<views:ItemView BindingContext="{Binding}" Name="{Binding Name, StringFormat='#### {0}'}" Description="{Binding Description}" />
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
</Frame>
<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding SelectedPlayerCharacter.Class.Markdown}" />
<!--<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding SelectedPlayerCharacter.Class.Markdown}" />-->
</StackLayout>
</ScrollView>
</ContentPage>