mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-23 10:33:50 +00:00
Alignement avec description
This commit is contained in:
parent
39ac4976c3
commit
f01fc2e547
402 changed files with 835 additions and 698 deletions
6
AideDeJeu/AideDeJeu/Models/Alignment/AlignmentItem.cs
Normal file
6
AideDeJeu/AideDeJeu/Models/Alignment/AlignmentItem.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
namespace AideDeJeuLib
|
||||
{
|
||||
public class AlignmentItem : Item
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -194,6 +194,7 @@ namespace AideDeJeuLib
|
|||
public static Dictionary<string, Type> ClassMapping = new Dictionary<string, Type>()
|
||||
{
|
||||
{ "GenericItem", typeof(GenericItem) },
|
||||
{ "AlignmentItem", typeof(AlignmentItem) },
|
||||
{ "MonsterItem", typeof(MonsterItem) },
|
||||
{ "MonsterItems", typeof(MonsterItems) },
|
||||
{ "SpellItem", typeof(SpellItem) },
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
using AideDeJeu.Tools;
|
||||
using AideDeJeuLib;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
|
@ -45,19 +42,19 @@ namespace AideDeJeu.ViewModels
|
|||
#endregion Selected PC
|
||||
|
||||
#region Alignment
|
||||
private List<string> _AllAllignments = new List<string>()
|
||||
/*private List<string> _AllAllignments = new List<string>()
|
||||
{
|
||||
"Loyal Bon",
|
||||
"Loyal Neutre",
|
||||
"Loyal Mauvais",
|
||||
"Neutre Bon",
|
||||
"Neutre",
|
||||
"Neutre Mauvais",
|
||||
"Chaotique Bon",
|
||||
"Chaotique Neutre",
|
||||
"Chaotique Mauvais"
|
||||
"Loyal Bon (LB)",
|
||||
"Neutre Bon (NB)",
|
||||
"Chaotique Bon (CB)",
|
||||
"Loyal Neutre (LN)",
|
||||
"Neutre (N)",
|
||||
"Chaotique Neutre (CN)",
|
||||
"Loyal Mauvais (LM)",
|
||||
"Neutre Mauvais (NM)",
|
||||
"Chaotique Mauvais (CM)"
|
||||
};
|
||||
|
||||
|
||||
private List<string> _Alignments = null;
|
||||
public List<string> Alignments
|
||||
{
|
||||
|
|
@ -69,10 +66,53 @@ namespace AideDeJeu.ViewModels
|
|||
{
|
||||
SetProperty(ref _Alignments, value);
|
||||
}
|
||||
}*/
|
||||
|
||||
private NotifyTaskCompletion<List<AlignmentItem>> _Alignments = null;
|
||||
public NotifyTaskCompletion<List<AlignmentItem>> Alignments
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Alignments;
|
||||
}
|
||||
private set
|
||||
{
|
||||
SetProperty(ref _Alignments, value);
|
||||
}
|
||||
}
|
||||
|
||||
private int _AlignmentSelectedIndex = -1;
|
||||
public int AlignmentSelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _AlignmentSelectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _AlignmentSelectedIndex, value);
|
||||
SelectedPlayerCharacter.Alignment = Alignments.Result[_AlignmentSelectedIndex];
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<AlignmentItem>> LoadAlignmentsAsync(string alignment = null)
|
||||
{
|
||||
using (var context = await StoreViewModel.GetLibraryContextAsync())
|
||||
{
|
||||
if (alignment == null)
|
||||
{
|
||||
return await context.Alignments.OrderBy(r => Tools.Helpers.RemoveDiacritics(r.Name)).ToListAsync().ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await context.Alignments.Where(a => a.Name.ToLower().Contains(alignment.ToLower())).OrderBy(r => Tools.Helpers.RemoveDiacritics(r.Name)).ToListAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetAlignments()
|
||||
{
|
||||
Alignments = new NotifyTaskCompletion<List<AlignmentItem>>(Task.Run(() => LoadAlignmentsAsync()));
|
||||
if (!string.IsNullOrEmpty(SelectedPlayerCharacter.PersonalityIdeal))
|
||||
{
|
||||
var regex = new Regex(".*\\((?<alignment>.*?)\\)$");
|
||||
|
|
@ -80,16 +120,17 @@ namespace AideDeJeu.ViewModels
|
|||
var alignment = match.Groups["alignment"].Value;
|
||||
if (!string.IsNullOrEmpty(alignment))
|
||||
{
|
||||
Alignments = _AllAllignments.Where(a => a.ToLower().Contains(alignment.ToLower())).ToList();
|
||||
Alignments = new NotifyTaskCompletion<List<AlignmentItem>>(Task.Run(() => LoadAlignmentsAsync(alignment)));
|
||||
SelectedPlayerCharacter.Alignment = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Alignments = _AllAllignments;
|
||||
Alignments = new NotifyTaskCompletion<List<AlignmentItem>>(Task.Run(() => LoadAlignmentsAsync()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alignments = _AllAllignments;
|
||||
Alignments = new NotifyTaskCompletion<List<AlignmentItem>>(Task.Run(() => LoadAlignmentsAsync()));
|
||||
}
|
||||
}
|
||||
#endregion Alignment
|
||||
|
|
@ -380,24 +421,7 @@ namespace AideDeJeu.ViewModels
|
|||
return new Command<List<string>>(async (strings) =>
|
||||
{
|
||||
SelectedPlayerCharacter.PersonalityIdeal = await ExecuteStringPickerCommandAsync(strings);
|
||||
if (!string.IsNullOrEmpty(SelectedPlayerCharacter.PersonalityIdeal))
|
||||
{
|
||||
var regex = new Regex(".*\\((?<alignment>.*?)\\)$");
|
||||
var match = regex.Match(SelectedPlayerCharacter.PersonalityIdeal);
|
||||
var alignment = match.Groups["alignment"].Value;
|
||||
if (!string.IsNullOrEmpty(alignment))
|
||||
{
|
||||
Alignments = _AllAllignments.Where(a => a.ToLower().Contains(alignment.ToLower())).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alignments = _AllAllignments;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Alignments = _AllAllignments;
|
||||
}
|
||||
ResetAlignments();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,18 @@ namespace AideDeJeu.ViewModels
|
|||
{
|
||||
public class PlayerCharacterViewModel : BaseViewModel
|
||||
{
|
||||
private AlignmentItem _Alignment = null;
|
||||
public AlignmentItem Alignment
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Alignment;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _Alignment, value);
|
||||
}
|
||||
}
|
||||
private RaceItem _Race = null;
|
||||
public RaceItem Race
|
||||
{
|
||||
|
|
|
|||
|
|
@ -564,6 +564,7 @@ namespace AideDeJeu.ViewModels
|
|||
public DbSet<PersonalityIdealItem> PersonalityIdeals { get; set; }
|
||||
public DbSet<PersonalityLinkItem> PersonalityLinks { get; set; }
|
||||
public DbSet<PersonalityDefectItem> PersonalityDefects { get; set; }
|
||||
public DbSet<AlignmentItem> Alignments { get; set; }
|
||||
|
||||
public AideDeJeuContext(string dbPath)
|
||||
{
|
||||
|
|
@ -588,6 +589,7 @@ namespace AideDeJeu.ViewModels
|
|||
|
||||
|
||||
|
||||
modelBuilder.Entity<AlignmentItem>();
|
||||
modelBuilder.Entity<GenericItem>();
|
||||
modelBuilder.Entity<MonsterItem>();
|
||||
modelBuilder.Entity<MonsterItems>();
|
||||
|
|
|
|||
|
|
@ -19,11 +19,14 @@
|
|||
</ResourceDictionary>
|
||||
</TabbedPage.Resources>
|
||||
<ContentPage Title="Généralités">
|
||||
<StackLayout>
|
||||
<Entry Placeholder="Nom" Text="{Binding Name}" Keyboard="Text" />
|
||||
<Picker Title="Alignement" HorizontalOptions="FillAndExpand" ItemsSource="{Binding Alignments}" ItemDisplayBinding="{Binding StringFormat='Alignement : {0}'}" />
|
||||
<Picker Title="Niveau" HorizontalOptions="FillAndExpand" ItemsSource="{Binding Levels}" ItemDisplayBinding="{Binding StringFormat='Niveau : {0}'}" />
|
||||
</StackLayout>
|
||||
<ScrollView Orientation="Vertical">
|
||||
<StackLayout>
|
||||
<Entry Placeholder="Nom" Text="{Binding Name}" Keyboard="Text" />
|
||||
<Picker Title="Alignement" HorizontalOptions="FillAndExpand" IsEnabled="{Binding Alignments.IsSuccessfullyCompleted}" ItemsSource="{Binding Alignments.Result}" ItemDisplayBinding="{Binding Name}" SelectedIndex="{Binding AlignmentSelectedIndex, Mode=TwoWay}" />
|
||||
<mdview:MarkdownView Markdown="{Binding SelectedPlayerCharacter.Alignment.Description}" />
|
||||
<Picker Title="Niveau" HorizontalOptions="FillAndExpand" ItemsSource="{Binding Levels}" ItemDisplayBinding="{Binding StringFormat='Niveau : {0}'}" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
||||
<ContentPage Title="Race">
|
||||
<StackLayout>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue