mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-11-02 00:16:07 +00:00
Remise en place des filtres monstres manquants
This commit is contained in:
parent
4796f3b9f2
commit
23163fc8d9
3 changed files with 22 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
using AideDeJeuLib.Monsters;
|
using AideDeJeu.Tools;
|
||||||
|
using AideDeJeuLib.Monsters;
|
||||||
using AideDeJeuLib.Spells;
|
using AideDeJeuLib.Spells;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -55,12 +56,15 @@ namespace AideDeJeu.Services
|
||||||
{
|
{
|
||||||
using (var context = await CreateContextAsync().ConfigureAwait(false))
|
using (var context = await CreateContextAsync().ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
|
var powerComparer = new PowerComparer();
|
||||||
return await context.Monsters
|
return await context.Monsters
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(monster =>
|
.Where(monster =>
|
||||||
monster.Type.Contains(type) &&
|
monster.Type.Contains(type) &&
|
||||||
(string.IsNullOrEmpty(size) || monster.Size.Equals(size)) &&
|
(string.IsNullOrEmpty(size) || monster.Size.Equals(size)) &&
|
||||||
monster.Source.Contains(source)
|
monster.Source.Contains(source) &&
|
||||||
|
powerComparer.Compare(monster.Challenge, minPower) >= 0 &&
|
||||||
|
powerComparer.Compare(monster.Challenge, maxPower) <= 0
|
||||||
)
|
)
|
||||||
//.OrderByDescending(monster => monster.Id)
|
//.OrderByDescending(monster => monster.Id)
|
||||||
.ToListAsync().ConfigureAwait(false);
|
.ToListAsync().ConfigureAwait(false);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using AideDeJeuLib.Spells;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace AideDeJeu.Tools
|
namespace AideDeJeu.Tools
|
||||||
{
|
{
|
||||||
|
|
@ -13,4 +14,15 @@ namespace AideDeJeu.Tools
|
||||||
return x.NamePHB.CompareTo(y.NamePHB);
|
return x.NamePHB.CompareTo(y.NamePHB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PowerComparer : Comparer<string>
|
||||||
|
{
|
||||||
|
public override int Compare(string x, string y)
|
||||||
|
{
|
||||||
|
var regex = new Regex(@"\((?<xp>\d*?) PX\)");
|
||||||
|
int xpx = int.Parse(regex.Match(x).Groups["xp"].Value);
|
||||||
|
int xpy = int.Parse(regex.Match(y).Groups["xp"].Value);
|
||||||
|
return xpx - xpy;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@
|
||||||
<ScrollView Orientation="Vertical">
|
<ScrollView Orientation="Vertical">
|
||||||
<StackLayout Orientation="Vertical" Padding="15">
|
<StackLayout Orientation="Vertical" Padding="15">
|
||||||
|
|
||||||
<Label Text="Catégorie" Style="{StaticResource Key=subsubsection}" />
|
<!--<Label Text="Catégorie" Style="{StaticResource Key=subsubsection}" />
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Categories, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Category}" />
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Categories, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Category}" />-->
|
||||||
|
|
||||||
<Label Text="Type" Style="{StaticResource Key=subsubsection}" />
|
<Label Text="Type" Style="{StaticResource Key=subsubsection}" />
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Types, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Type}" />
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Types, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Type}" />
|
||||||
|
|
@ -58,8 +58,8 @@
|
||||||
<Label Text="Taille" Style="{StaticResource Key=subsubsection}" />
|
<Label Text="Taille" Style="{StaticResource Key=subsubsection}" />
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sizes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Size}" />
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sizes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Size}" />
|
||||||
|
|
||||||
<Label Text="Légendaire" Style="{StaticResource Key=subsubsection}" />
|
<!--<Label Text="Légendaire" Style="{StaticResource Key=subsubsection}" />
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Legendaries, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Legendary}" />
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Legendaries, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Legendary}" />-->
|
||||||
|
|
||||||
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
|
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
|
||||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Source}" IsEnabled="False"/>
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Source}" IsEnabled="False"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue