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

Remise en place des filtres monstres manquants

This commit is contained in:
Yan Maniez 2018-05-18 22:04:56 +02:00
parent 4796f3b9f2
commit 23163fc8d9
3 changed files with 22 additions and 6 deletions

View file

@ -1,4 +1,5 @@
using AideDeJeuLib.Monsters;
using AideDeJeu.Tools;
using AideDeJeuLib.Monsters;
using AideDeJeuLib.Spells;
using Microsoft.EntityFrameworkCore;
using System;
@ -55,12 +56,15 @@ namespace AideDeJeu.Services
{
using (var context = await CreateContextAsync().ConfigureAwait(false))
{
var powerComparer = new PowerComparer();
return await context.Monsters
.AsNoTracking()
.Where(monster =>
monster.Type.Contains(type) &&
(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)
.ToListAsync().ConfigureAwait(false);

View file

@ -3,6 +3,7 @@ using AideDeJeuLib.Spells;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace AideDeJeu.Tools
{
@ -13,4 +14,15 @@ namespace AideDeJeu.Tools
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;
}
}
}

View file

@ -37,8 +37,8 @@
<ScrollView Orientation="Vertical">
<StackLayout Orientation="Vertical" Padding="15">
<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}" />
<!--<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}" />-->
<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}" />
@ -58,8 +58,8 @@
<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}" />
<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}" />
<!--<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}" />-->
<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"/>