1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 06:26:02 +00:00

Critères de sélection monstres

This commit is contained in:
Yan Maniez 2018-04-29 15:20:34 +02:00
parent 1585525519
commit 387ce03d56
4 changed files with 110 additions and 94 deletions

View file

@ -14,130 +14,159 @@ namespace AideDeJeu.ViewModels
{
public ObservableCollection<Monster> Items { get; set; }
public List<KeyValuePair<string, string>> Classes { get; set; } = new List<KeyValuePair<string, string>>()
public List<KeyValuePair<string, string>> Categories { get; set; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes" ),
new KeyValuePair<string, string>("b", "Barde" ),
new KeyValuePair<string, string>("c", "Clerc" ),
new KeyValuePair<string, string>("d", "Druide" ),
new KeyValuePair<string, string>("s", "Ensorceleur" ),
new KeyValuePair<string, string>("w", "Magicien" ),
new KeyValuePair<string, string>("p", "Paladin" ),
new KeyValuePair<string, string>("r", "Rôdeur" ),
new KeyValuePair<string, string>("k", "Sorcier" ),
new KeyValuePair<string, string>("M", "Monstres" ),
new KeyValuePair<string, string>("A", "Animaux" ),
new KeyValuePair<string, string>("P", "PNJ" ),
};
public List<KeyValuePair<int, string>> Niveaux { get; set; } = new List<KeyValuePair<int, string>>()
public List<KeyValuePair<string, string>> Types { get; set; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<int, string>(0, "Sorts mineurs"),
new KeyValuePair<int, string>(1, "Niveau 1"),
new KeyValuePair<int, string>(2, "Niveau 2"),
new KeyValuePair<int, string>(3, "Niveau 3"),
new KeyValuePair<int, string>(4, "Niveau 4"),
new KeyValuePair<int, string>(5, "Niveau 5"),
new KeyValuePair<int, string>(6, "Niveau 6"),
new KeyValuePair<int, string>(7, "Niveau 7"),
new KeyValuePair<int, string>(8, "Niveau 8"),
new KeyValuePair<int, string>(9, "Niveau 9"),
new KeyValuePair<string, string>("", "Tous" ),
new KeyValuePair<string, string>("Humanoïde", "Humanoïde"),
new KeyValuePair<string, string>("Aberration", "Aberration"),
new KeyValuePair<string, string>("Bête", "Bête"),
new KeyValuePair<string, string>("Céleste", "Céleste"),
new KeyValuePair<string, string>("Créature artificielle", "Créature artificielle"),
new KeyValuePair<string, string>("Créature monstrueuse", "Créature monstrueuse"),
new KeyValuePair<string, string>("Dragon", "Dragon"),
new KeyValuePair<string, string>("Élémentaire", "Élémentaire"),
new KeyValuePair<string, string>("Fée", "Fée"),
new KeyValuePair<string, string>("Fiélon", "Fiélon"),
new KeyValuePair<string, string>("Géant", "Géant"),
new KeyValuePair<string, string>("Mort-vivant", "Mort-vivant"),
new KeyValuePair<string, string>("Plante", "Plante"),
new KeyValuePair<string, string>("Vase", "Vase"),
};
public List<KeyValuePair<string, string>> Ecoles { get; set; } = new List<KeyValuePair<string, string>>()
public List<KeyValuePair<string, string>> Powers { get; set; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("0", "0" ),
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" ),
};
public List<KeyValuePair<string, string>> Sizes { get; set; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("abjuration", "Abjuration"),
new KeyValuePair<string, string>("divination", "Divination"),
new KeyValuePair<string, string>("enchantement", "Enchantement"),
new KeyValuePair<string, string>("evocation", "Évocation"),
new KeyValuePair<string, string>("illusion", "Illusion"),
new KeyValuePair<string, string>("invocation", "Invocation"),
new KeyValuePair<string, string>("necromancie", "Nécromancie"),
new KeyValuePair<string, string>("transmutation", "Transmutation"),
new KeyValuePair<string, string>("TP", "Très petite"),
new KeyValuePair<string, string>("P", "Petite"),
new KeyValuePair<string, string>("M", "Moyenne"),
new KeyValuePair<string, string>("G", "Grande"),
new KeyValuePair<string, string>("TG", "Très grande"),
new KeyValuePair<string, string>("Gig", "Gigantesque"),
};
public List<KeyValuePair<string, string>> Rituels { get; set; } = new List<KeyValuePair<string, string>>()
public List<KeyValuePair<string, string>> Legendaries { get; set; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Tous"),
new KeyValuePair<string, string>("1", "Rituel"),
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("si", "Si"),
new KeyValuePair<string, string>("no", "Non"),
};
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>("ph", "PHB"),
new KeyValuePair<string, string>("sup", "SCAG, XGtE"),
new KeyValuePair<string, string>("mm", "MM"),
new KeyValuePair<string, string>("sup", "VGtM, MToF"),
new KeyValuePair<string, string>("supno", "AL, AideDD"),
};
private int _Classe = 0;
public int Classe
private int _Category = 0;
public int Category
{
get
{
return _Classe;
return _Category;
}
set
{
SetProperty(ref _Classe, value);
SetProperty(ref _Category, value);
LoadItemsCommand.Execute(null);
}
}
private int _NiveauMin = 0;
public int NiveauMin
private int _Type = 0;
public int Type
{
get
{
return _NiveauMin;
return _Type;
}
set
{
SetProperty(ref _NiveauMin, value);
if (_NiveauMax < _NiveauMin)
SetProperty(ref _Type, value);
LoadItemsCommand.Execute(null);
}
}
private int _MinPower = 0;
public int MinPower
{
get
{
return _MinPower;
}
set
{
SetProperty(ref _MinPower, value);
if (_MaxPower < _MinPower)
{
SetProperty(ref _NiveauMax, value, nameof(NiveauMax));
SetProperty(ref _MaxPower, value, nameof(MaxPower));
}
LoadItemsCommand.Execute(null);
}
}
private int _NiveauMax = 9;
public int NiveauMax
private int _MaxPower = 9;
public int MaxPower
{
get
{
return _NiveauMax;
return _MaxPower;
}
set
{
SetProperty(ref _NiveauMax, value);
if (_NiveauMax < _NiveauMin)
SetProperty(ref _MaxPower, value);
if (_MaxPower < _MinPower)
{
SetProperty(ref _NiveauMin, value, nameof(NiveauMin));
SetProperty(ref _MinPower, value, nameof(MinPower));
}
LoadItemsCommand.Execute(null);
}
}
private int _Ecole = 0;
public int Ecole
private int _Size = 0;
public int Size
{
get
{
return _Ecole;
return _Size;
}
set
{
SetProperty(ref _Ecole, value);
SetProperty(ref _Size, value);
LoadItemsCommand.Execute(null);
}
}
private int _Rituel = 0;
public int Rituel
private int _Legendary = 0;
public int Legendary
{
get
{
return _Rituel;
return _Legendary;
}
set
{
SetProperty(ref _Rituel, value);
SetProperty(ref _Legendary, value);
LoadItemsCommand.Execute(null);
}
}
@ -160,16 +189,8 @@ namespace AideDeJeu.ViewModels
public MonstersViewModel()
{
//Title = "Browse";
Items = new ObservableCollection<Monster>();
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
//MessagingCenter.Subscribe<NewItemPage, Spell>(this, "AddItem", async (obj, item) =>
//{
// var _item = item as Item;
// Items.Add(_item);
// await DataStore.AddItemAsync(_item);
//});
}
async Task ExecuteLoadItemsCommand()
@ -181,17 +202,8 @@ namespace AideDeJeu.ViewModels
try
{
//<option value="b">Barde</option>
//<option value="c">Clerc</option>
//<option value="d">Druide</option>
//<option value="s">Ensorceleur</option>
//<option value="w">Magicien</option>
//<option value="p">Paladin</option>
//<option value="r">Rôdeur</option>
//<option value="k">Sorcier</option>
Items.Clear();
var items = await new MonstersScrappers().GetMonsters();
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);
foreach (var item in items)
{
Items.Add(item);

View file

@ -121,13 +121,8 @@ namespace AideDeJeu.ViewModels
try
{
//Items.Clear();
var item = await new SpellsScrappers().GetSpell(Item.Id);
var item = await SpellsScrappers.GetSpell(Item.Id);
Item = item;
//foreach (var item in items)
//{
// Items.Add(item);
//}
}
catch (Exception ex)
{

View file

@ -27,20 +27,29 @@
</Picker.Items>
</Picker>-->
<Label Text="Classe" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Classes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Classe}" />
<Label Text="Catégorie" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Categories, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Category}" />
<Label Text="Niveau minimum" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMin}" />
<Label Text="Type" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Types, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Type}" />
<Label Text="Niveau maximum" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMax}" />
<StackLayout Orientation="Horizontal">
<StackLayout Orientation="Vertical">
<Label Text="FP minimum" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Powers, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding MinPower}" />
</StackLayout>
<Label Text="École" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Ecoles, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Ecole}" />
<StackLayout Orientation="Vertical">
<Label Text="FP maximum" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Powers, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding MaxPower}" />
</StackLayout>
</StackLayout>
<Label Text="Rituel" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Rituels, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Rituel}" />
<Label Text="Taille" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Sizes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Size}" />
<Label Text="Légendaire" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Legendaries, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Legendary}" />
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Source}" />

View file

@ -22,14 +22,14 @@ namespace AideDeJeuLib.Monsters
return client;
}
public async Task<IEnumerable<Monster>> GetMonsters(string categorie = "", string type = "", string niveauMin = "", string niveauMax = "", string taille = "", string legendaire = "", string source = "srd")
public async Task<IEnumerable<Monster>> GetMonsters(string category = "", string type = "", string minPower = "", string maxPower = "", string size = "", string legendary = "", string source = "srd")
{
string html = null;
using (var client = GetHttpClient())
{
// https://www.aidedd.org/regles/monstres/?min=.25&max=20&c=M&sz=TP&lg=si&t=Humano%C3%AFde&s=srd
html = await client.GetStringAsync(string.Format($"https://www.aidedd.org/regles/monstres/?c={categorie}&t={type}&min={niveauMin}&max={niveauMax}&sz={taille}&lg={legendaire}&s={source}", categorie, type, niveauMin, niveauMax, taille, legendaire, source));
html = await client.GetStringAsync(string.Format($"https://www.aidedd.org/regles/monstres/?c={category}&t={type}&min={minPower}&max={maxPower}&sz={size}&lg={legendary}&s={source}", category, type, minPower, maxPower, size, legendary, source));
}
var pack = new HtmlDocument();
pack.LoadHtml(html);