mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 07:26:09 +00:00 
			
		
		
		
	Critères de sélection monstres
This commit is contained in:
		
							parent
							
								
									1585525519
								
							
						
					
					
						commit
						387ce03d56
					
				
					 4 changed files with 110 additions and 94 deletions
				
			
		|  | @ -14,130 +14,159 @@ namespace AideDeJeu.ViewModels | ||||||
|     { |     { | ||||||
|         public ObservableCollection<Monster> Items { get; set; } |         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>("", "Toutes" ), | ||||||
|             new KeyValuePair<string, string>("b", "Barde" ), |             new KeyValuePair<string, string>("M", "Monstres" ), | ||||||
|             new KeyValuePair<string, string>("c", "Clerc" ), |             new KeyValuePair<string, string>("A", "Animaux" ), | ||||||
|             new KeyValuePair<string, string>("d", "Druide" ), |             new KeyValuePair<string, string>("P", "PNJ" ), | ||||||
|             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" ), |  | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         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"), |  | ||||||
|         }; |  | ||||||
| 
 |  | ||||||
|         public List<KeyValuePair<string, string>> Ecoles { 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"), |  | ||||||
|         }; |  | ||||||
| 
 |  | ||||||
|         public List<KeyValuePair<string, string>> Rituels { get; set; } = new List<KeyValuePair<string, string>>() |  | ||||||
|         { |         { | ||||||
|             new KeyValuePair<string, string>("", "Tous" ), |             new KeyValuePair<string, string>("", "Tous" ), | ||||||
|             new KeyValuePair<string, string>("1", "Rituel"), |             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>> 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>("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>> Legendaries { get; set; } = new List<KeyValuePair<string, string>>() | ||||||
|  |         { | ||||||
|  |             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>>() |         public List<KeyValuePair<string, string>> Sources { get; set; } = new List<KeyValuePair<string, string>>() | ||||||
|         { |         { | ||||||
|             new KeyValuePair<string, string>("", "Toutes"), |             new KeyValuePair<string, string>("", "Toutes"), | ||||||
|             new KeyValuePair<string, string>("srd", "SRD"), |             new KeyValuePair<string, string>("srd", "SRD"), | ||||||
|             new KeyValuePair<string, string>("ph", "PHB"), |             new KeyValuePair<string, string>("mm", "MM"), | ||||||
|             new KeyValuePair<string, string>("sup", "SCAG, XGtE"), |             new KeyValuePair<string, string>("sup", "VGtM, MToF"), | ||||||
|  |             new KeyValuePair<string, string>("supno", "AL, AideDD"), | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         private int _Classe = 0; |         private int _Category = 0; | ||||||
|         public int Classe |         public int Category | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 return _Classe; |                 return _Category; | ||||||
|             } |             } | ||||||
|             set |             set | ||||||
|             { |             { | ||||||
|                 SetProperty(ref _Classe, value); |                 SetProperty(ref _Category, value); | ||||||
|                 LoadItemsCommand.Execute(null); |                 LoadItemsCommand.Execute(null); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         private int _NiveauMin = 0; |         private int _Type = 0; | ||||||
|         public int NiveauMin |         public int Type | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 return _NiveauMin; |                 return _Type; | ||||||
|             } |             } | ||||||
|             set |             set | ||||||
|             { |             { | ||||||
|                 SetProperty(ref _NiveauMin, value); |                 SetProperty(ref _Type, value); | ||||||
|                 if (_NiveauMax < _NiveauMin) |                 LoadItemsCommand.Execute(null); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         private int _MinPower = 0; | ||||||
|  |         public int MinPower | ||||||
|         { |         { | ||||||
|                     SetProperty(ref _NiveauMax, value, nameof(NiveauMax)); |             get | ||||||
|  |             { | ||||||
|  |                 return _MinPower; | ||||||
|  |             } | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 SetProperty(ref _MinPower, value); | ||||||
|  |                 if (_MaxPower < _MinPower) | ||||||
|  |                 { | ||||||
|  |                     SetProperty(ref _MaxPower, value, nameof(MaxPower)); | ||||||
|                 } |                 } | ||||||
|                 LoadItemsCommand.Execute(null); |                 LoadItemsCommand.Execute(null); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         private int _NiveauMax = 9; |         private int _MaxPower = 9; | ||||||
|         public int NiveauMax |         public int MaxPower | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 return _NiveauMax; |                 return _MaxPower; | ||||||
|             } |             } | ||||||
|             set |             set | ||||||
|             { |             { | ||||||
|                 SetProperty(ref _NiveauMax, value); |                 SetProperty(ref _MaxPower, value); | ||||||
|                 if (_NiveauMax < _NiveauMin) |                 if (_MaxPower < _MinPower) | ||||||
|                 { |                 { | ||||||
|                     SetProperty(ref _NiveauMin, value, nameof(NiveauMin)); |                     SetProperty(ref _MinPower, value, nameof(MinPower)); | ||||||
|                 } |                 } | ||||||
|                 LoadItemsCommand.Execute(null); |                 LoadItemsCommand.Execute(null); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         private int _Ecole = 0; |         private int _Size = 0; | ||||||
|         public int Ecole |         public int Size | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 return _Ecole; |                 return _Size; | ||||||
|             } |             } | ||||||
|             set |             set | ||||||
|             { |             { | ||||||
|                 SetProperty(ref _Ecole, value); |                 SetProperty(ref _Size, value); | ||||||
|                 LoadItemsCommand.Execute(null); |                 LoadItemsCommand.Execute(null); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         private int _Rituel = 0; |         private int _Legendary = 0; | ||||||
|         public int Rituel |         public int Legendary | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|                 return _Rituel; |                 return _Legendary; | ||||||
|             } |             } | ||||||
|             set |             set | ||||||
|             { |             { | ||||||
|                 SetProperty(ref _Rituel, value); |                 SetProperty(ref _Legendary, value); | ||||||
|                 LoadItemsCommand.Execute(null); |                 LoadItemsCommand.Execute(null); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | @ -160,16 +189,8 @@ namespace AideDeJeu.ViewModels | ||||||
| 
 | 
 | ||||||
|         public MonstersViewModel() |         public MonstersViewModel() | ||||||
|         { |         { | ||||||
|             //Title = "Browse"; |  | ||||||
|             Items = new ObservableCollection<Monster>(); |             Items = new ObservableCollection<Monster>(); | ||||||
|             LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand()); |             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() |         async Task ExecuteLoadItemsCommand() | ||||||
|  | @ -181,17 +202,8 @@ namespace AideDeJeu.ViewModels | ||||||
| 
 | 
 | ||||||
|             try |             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(); |                 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) |                 foreach (var item in items) | ||||||
|                 { |                 { | ||||||
|                     Items.Add(item); |                     Items.Add(item); | ||||||
|  |  | ||||||
|  | @ -121,13 +121,8 @@ namespace AideDeJeu.ViewModels | ||||||
| 
 | 
 | ||||||
|             try |             try | ||||||
|             { |             { | ||||||
|                 //Items.Clear(); |                 var item = await SpellsScrappers.GetSpell(Item.Id); | ||||||
|                 var item = await new SpellsScrappers().GetSpell(Item.Id); |  | ||||||
|                 Item = item; |                 Item = item; | ||||||
|                 //foreach (var item in items) |  | ||||||
|                 //{ |  | ||||||
|                 //    Items.Add(item); |  | ||||||
|                 //} |  | ||||||
|             } |             } | ||||||
|             catch (Exception ex) |             catch (Exception ex) | ||||||
|             { |             { | ||||||
|  |  | ||||||
|  | @ -27,20 +27,29 @@ | ||||||
|                     </Picker.Items> |                     </Picker.Items> | ||||||
|                 </Picker>--> |                 </Picker>--> | ||||||
| 
 | 
 | ||||||
|                 <Label Text="Classe" Style="{StaticResource Key=subsubsection}" /> |                 <Label Text="Catégorie" Style="{StaticResource Key=subsubsection}" /> | ||||||
|                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Classes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Classe}" /> |                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Categories, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Category}" /> | ||||||
| 
 | 
 | ||||||
|                 <Label Text="Niveau minimum" Style="{StaticResource Key=subsubsection}" /> |                 <Label Text="Type" Style="{StaticResource Key=subsubsection}" /> | ||||||
|                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMin}" /> |                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Types, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Type}" /> | ||||||
| 
 | 
 | ||||||
|                 <Label Text="Niveau maximum" Style="{StaticResource Key=subsubsection}" /> |                 <StackLayout Orientation="Horizontal"> | ||||||
|                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding NiveauMax}" /> |                     <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}" /> |                     <StackLayout Orientation="Vertical"> | ||||||
|                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Ecoles, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Ecole}" /> |                         <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}" /> |                 <Label Text="Taille" Style="{StaticResource Key=subsubsection}" /> | ||||||
|                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Rituels, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Rituel}" /> |                 <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}" /> |                 <Label Text="Source" Style="{StaticResource Key=subsubsection}" /> | ||||||
|                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Source}" /> |                 <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Source}" /> | ||||||
|  |  | ||||||
|  | @ -22,14 +22,14 @@ namespace AideDeJeuLib.Monsters | ||||||
|             return client; |             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; |             string html = null; | ||||||
|             using (var client = GetHttpClient()) |             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 |                 // 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(); |             var pack = new HtmlDocument(); | ||||||
|             pack.LoadHtml(html); |             pack.LoadHtml(html); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez