mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-11-02 00:16:07 +00:00
Début utilisation bdd pour les monstres + optim / correction
This commit is contained in:
parent
2a151915e3
commit
184994c0d8
3 changed files with 118 additions and 53 deletions
|
|
@ -52,13 +52,18 @@ namespace AideDeJeu.Services
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Monster>> GetMonstersAsync()
|
||||
public async Task<IEnumerable<Monster>> GetMonstersAsync(string category, string type, string minPower, string maxPower, string size, string legendary, string source)
|
||||
{
|
||||
using (var context = CreateContext())
|
||||
{
|
||||
//We use OrderByDescending because Posts are generally displayed from most recent to oldest
|
||||
return await context.Monsters
|
||||
.AsNoTracking()
|
||||
.Where(monster =>
|
||||
monster.Type.Contains(type) &&
|
||||
//("[" + monster.Size.Trim().ToUpper() + "]").Contains("[" + size.ToUpper() + "]") &&
|
||||
monster.Source.Contains(source)
|
||||
)
|
||||
.OrderByDescending(monster => monster.Id)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using AideDeJeu.Tools;
|
||||
using AideDeJeu.Services;
|
||||
using AideDeJeu.Tools;
|
||||
using AideDeJeuLib;
|
||||
using AideDeJeuLib.Monsters;
|
||||
using System;
|
||||
|
|
@ -41,19 +42,35 @@ namespace AideDeJeu.ViewModels
|
|||
|
||||
public List<KeyValuePair<string, string>> Powers { get; set; } = new List<KeyValuePair<string, string>>()
|
||||
{
|
||||
new KeyValuePair<string, string>("Z", "0" ),
|
||||
new KeyValuePair<string, string>(".12", "1/8" ),
|
||||
new KeyValuePair<string, string>(".25", "1/4" ),
|
||||
new KeyValuePair<string, string>(".5", "1/2" ),
|
||||
new KeyValuePair<string, string>("1", "1" ),
|
||||
new KeyValuePair<string, string>("2", "2" ),
|
||||
new KeyValuePair<string, string>("4", "4" ),
|
||||
new KeyValuePair<string, string>("6", "6" ),
|
||||
new KeyValuePair<string, string>("8", "8" ),
|
||||
new KeyValuePair<string, string>("10", "10" ),
|
||||
new KeyValuePair<string, string>("15", "15" ),
|
||||
new KeyValuePair<string, string>("20", "20" ),
|
||||
new KeyValuePair<string, string>("30", "30" ),
|
||||
new KeyValuePair<string, string>(" 0 (0 PX)", "0" ),
|
||||
new KeyValuePair<string, string>(" 1/8 (25 PX)", "1/8" ),
|
||||
new KeyValuePair<string, string>(" 1/4 (50 PX)", "1/4" ),
|
||||
new KeyValuePair<string, string>(" 1/2 (100 PX)", "1/2" ),
|
||||
new KeyValuePair<string, string>(" 1 (200 PX)", "1" ),
|
||||
new KeyValuePair<string, string>(" 2 (450 PX)", "2" ),
|
||||
new KeyValuePair<string, string>(" 3 (700 PX)", "3" ),
|
||||
new KeyValuePair<string, string>(" 4 (1100 PX)", "4" ),
|
||||
new KeyValuePair<string, string>(" 5 (1800 PX)", "5" ),
|
||||
new KeyValuePair<string, string>(" 6 (2300 PX)", "6" ),
|
||||
new KeyValuePair<string, string>(" 7 (2900 PX)", "7" ),
|
||||
new KeyValuePair<string, string>(" 8 (3900 PX)", "8" ),
|
||||
new KeyValuePair<string, string>(" 9 (5000 PX)", "9" ),
|
||||
new KeyValuePair<string, string>(" 10 (5900 PX)", "10" ),
|
||||
new KeyValuePair<string, string>(" 11 (7200 PX)", "11" ),
|
||||
new KeyValuePair<string, string>(" 12 (8400 PX)", "12" ),
|
||||
new KeyValuePair<string, string>(" 13 (10000 PX)", "13" ),
|
||||
new KeyValuePair<string, string>(" 14 (11500 PX)", "14" ),
|
||||
new KeyValuePair<string, string>(" 15 (13000 PX)", "15" ),
|
||||
new KeyValuePair<string, string>(" 16 (15000 PX)", "16" ),
|
||||
new KeyValuePair<string, string>(" 17 (18000 PX)", "17" ),
|
||||
new KeyValuePair<string, string>(" 18 (20000 PX)", "18" ),
|
||||
new KeyValuePair<string, string>(" 19 (22000 PX)", "19" ),
|
||||
new KeyValuePair<string, string>(" 20 (25000 PX)", "20" ),
|
||||
new KeyValuePair<string, string>(" 21 (33000 PX)", "21" ),
|
||||
new KeyValuePair<string, string>(" 22 (41000 PX)", "22" ),
|
||||
new KeyValuePair<string, string>(" 23 (50000 PX)", "23" ),
|
||||
new KeyValuePair<string, string>(" 24 (62000 PX)", "24" ),
|
||||
new KeyValuePair<string, string>(" 30 (155000 PX)", "30" ),
|
||||
};
|
||||
|
||||
public List<KeyValuePair<string, string>> Sizes { get; set; } = new List<KeyValuePair<string, string>>()
|
||||
|
|
@ -77,8 +94,8 @@ namespace AideDeJeu.ViewModels
|
|||
public List<KeyValuePair<string, string>> Sources { get; set; } = new List<KeyValuePair<string, string>>()
|
||||
{
|
||||
new KeyValuePair<string, string>("", "Toutes"),
|
||||
new KeyValuePair<string, string>("srd", "SRD"),
|
||||
new KeyValuePair<string, string>("mm", "MM"),
|
||||
new KeyValuePair<string, string>("(SRD)", "SRD"),
|
||||
new KeyValuePair<string, string>("Monster Manual", "MM"),
|
||||
new KeyValuePair<string, string>("sup", "VGtM, MToF"),
|
||||
new KeyValuePair<string, string>("supno", "AL, AideDD"),
|
||||
};
|
||||
|
|
@ -91,11 +108,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Category;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Category != value)
|
||||
{
|
||||
SetProperty(ref _Category, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Type = 0;
|
||||
public int Type
|
||||
{
|
||||
|
|
@ -104,11 +124,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Type;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Type != value)
|
||||
{
|
||||
SetProperty(ref _Type, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _MinPower = 0;
|
||||
public int MinPower
|
||||
{
|
||||
|
|
@ -117,6 +140,8 @@ namespace AideDeJeu.ViewModels
|
|||
return _MinPower;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_MinPower != value)
|
||||
{
|
||||
SetProperty(ref _MinPower, value);
|
||||
if (_MaxPower < _MinPower)
|
||||
|
|
@ -126,7 +151,8 @@ namespace AideDeJeu.ViewModels
|
|||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
private int _MaxPower = 11;
|
||||
}
|
||||
private int _MaxPower = 18;
|
||||
public int MaxPower
|
||||
{
|
||||
get
|
||||
|
|
@ -134,6 +160,8 @@ namespace AideDeJeu.ViewModels
|
|||
return _MaxPower;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_MaxPower != value)
|
||||
{
|
||||
SetProperty(ref _MaxPower, value);
|
||||
if (_MaxPower < _MinPower)
|
||||
|
|
@ -143,6 +171,7 @@ namespace AideDeJeu.ViewModels
|
|||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Size = 0;
|
||||
public int Size
|
||||
{
|
||||
|
|
@ -151,11 +180,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Size;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Size != value)
|
||||
{
|
||||
SetProperty(ref _Size, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Legendary = 0;
|
||||
public int Legendary
|
||||
{
|
||||
|
|
@ -164,11 +196,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Legendary;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Legendary != value)
|
||||
{
|
||||
SetProperty(ref _Legendary, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Source = 1;
|
||||
public int Source
|
||||
{
|
||||
|
|
@ -177,11 +212,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Source;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Source != value)
|
||||
{
|
||||
SetProperty(ref _Source, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public MonstersViewModel(INavigator navigator, ObservableCollection<Item> items)
|
||||
|
|
@ -199,7 +237,11 @@ namespace AideDeJeu.ViewModels
|
|||
try
|
||||
{
|
||||
AllItems.Clear();
|
||||
var items = await new MonstersScrappers().GetMonsters(category: Categories[Category].Key, type: Types[Type].Key, minPower: Powers[MinPower].Key, maxPower: Powers[MaxPower].Key, size: Sizes[Size].Key, legendary:Legendaries[Legendary].Key, source: Sources[Source].Key);
|
||||
//var items = await new MonstersScrappers().GetMonsters(category: Categories[Category].Key, type: Types[Type].Key, minPower: Powers[MinPower].Key, maxPower: Powers[MaxPower].Key, size: Sizes[Size].Key, legendary:Legendaries[Legendary].Key, source: Sources[Source].Key);
|
||||
|
||||
ItemDatabaseHelper<ItemDatabaseContext> helper = new ItemDatabaseHelper<ItemDatabaseContext>();
|
||||
var items = await helper.GetMonstersAsync(category: Categories[Category].Key, type: Types[Type].Key, minPower: Powers[MinPower].Key, maxPower: Powers[MaxPower].Key, size: Sizes[Size].Key, legendary: Legendaries[Legendary].Key, source: Sources[Source].Key);
|
||||
|
||||
var aitems = items.ToArray();
|
||||
Array.Sort(aitems, new ItemComparer());
|
||||
foreach (var item in aitems)
|
||||
|
|
|
|||
|
|
@ -75,11 +75,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Classe;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Classe != value)
|
||||
{
|
||||
SetProperty(ref _Classe, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _NiveauMin = 0;
|
||||
public int NiveauMin
|
||||
{
|
||||
|
|
@ -88,6 +91,8 @@ namespace AideDeJeu.ViewModels
|
|||
return _NiveauMin;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_NiveauMin != value)
|
||||
{
|
||||
SetProperty(ref _NiveauMin, value);
|
||||
if (_NiveauMax < _NiveauMin)
|
||||
|
|
@ -97,6 +102,7 @@ namespace AideDeJeu.ViewModels
|
|||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _NiveauMax = 9;
|
||||
public int NiveauMax
|
||||
{
|
||||
|
|
@ -105,6 +111,8 @@ namespace AideDeJeu.ViewModels
|
|||
return _NiveauMax;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_NiveauMax != value)
|
||||
{
|
||||
SetProperty(ref _NiveauMax, value);
|
||||
if (_NiveauMax < _NiveauMin)
|
||||
|
|
@ -114,6 +122,7 @@ namespace AideDeJeu.ViewModels
|
|||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Ecole = 0;
|
||||
public int Ecole
|
||||
{
|
||||
|
|
@ -122,11 +131,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Ecole;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Ecole != value)
|
||||
{
|
||||
SetProperty(ref _Ecole, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Rituel = 0;
|
||||
public int Rituel
|
||||
{
|
||||
|
|
@ -135,11 +147,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Rituel;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Rituel != value)
|
||||
{
|
||||
SetProperty(ref _Rituel, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _Source = 1;
|
||||
public int Source
|
||||
{
|
||||
|
|
@ -148,11 +163,14 @@ namespace AideDeJeu.ViewModels
|
|||
return _Source;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_Source != value)
|
||||
{
|
||||
SetProperty(ref _Source, value);
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public SpellsViewModel(INavigator navigator, ObservableCollection<Item> items)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue