mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 07:26:09 +00:00 
			
		
		
		
	Adaptation aux nouvelles pages AideDD
This commit is contained in:
		
							parent
							
								
									28d833c94d
								
							
						
					
					
						commit
						e487488f60
					
				
					 8 changed files with 62 additions and 36 deletions
				
			
		|  | @ -178,15 +178,15 @@ namespace AideDeJeu.ViewModels | |||
| 
 | ||||
|                 //try | ||||
|                 //{ | ||||
|                 ItemDatabaseHelper<ItemDatabaseContext> helper = new ItemDatabaseHelper<ItemDatabaseContext>(); | ||||
|                 await helper.AddOrUpdateSpellsAsync(items); | ||||
|                 var items2 = await helper.GetSpellsAsync(); | ||||
|                 //ItemDatabaseHelper<ItemDatabaseContext> helper = new ItemDatabaseHelper<ItemDatabaseContext>(); | ||||
|                 //await helper.AddOrUpdateSpellsAsync(items); | ||||
|                 //var items2 = await helper.GetSpellsAsync(); | ||||
|                 //} | ||||
|                 //catch(Exception ex) | ||||
|                 //{ | ||||
|                 //    Debug.WriteLine(ex); | ||||
|                 //} | ||||
|                 var aitems = items2.ToArray(); | ||||
|                 var aitems = items.ToArray(); | ||||
|                 Array.Sort(aitems, new ItemComparer()); | ||||
|                 foreach (var item in aitems) | ||||
|                 { | ||||
|  |  | |||
|  | @ -8,6 +8,9 @@ | |||
|     <ContentPage.BindingContext> | ||||
|         <vm:AboutViewModel /> | ||||
|     </ContentPage.BindingContext> | ||||
|     <ContentPage.ToolbarItems> | ||||
|         <ToolbarItem Text="truc" /> | ||||
|     </ContentPage.ToolbarItems> | ||||
|     <Grid> | ||||
|         <Grid.RowDefinitions> | ||||
|             <RowDefinition Height="Auto" /> | ||||
|  |  | |||
|  | @ -99,11 +99,12 @@ | |||
|                     ItemsSource="{Binding Items}" | ||||
|                     VerticalOptions="FillAndExpand" | ||||
|                     HasUnevenRows="true" | ||||
|                     RefreshCommand="{Binding LoadItemsCommand}" | ||||
|                     IsPullToRefreshEnabled="true" | ||||
|                     IsRefreshing="{Binding IsBusy, Mode=OneWay}" | ||||
|                     CachingStrategy="RecycleElement" | ||||
|                     SelectedItem="{Binding SelectedItem}"> | ||||
|                     <!--RefreshCommand="{Binding LoadItemsCommand}" | ||||
|                     IsPullToRefreshEnabled="true"--> | ||||
| 
 | ||||
|                     <ListView.ItemTemplate> | ||||
|                         <DataTemplate> | ||||
|                             <ViewCell> | ||||
|  |  | |||
|  | @ -12,5 +12,6 @@ namespace AideDeJeuLib | |||
|         public string Name { get; set; } | ||||
|         public string NameVO { get; set; } | ||||
|         public string NamePHB { get; set; } | ||||
|         public string Html { get; set; } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -72,13 +72,21 @@ namespace AideDeJeuLib.Monsters | |||
|         public static Monster FromHtml(HtmlNode divBloc) | ||||
|         { | ||||
|             var monster = new Monster(); | ||||
|             monster.Html = divBloc.OuterHtml; | ||||
|             var divMonster = divBloc?.SelectSingleNode("div[contains(@class,'monstre')]"); | ||||
|             monster.Name = divMonster?.SelectSingleNode("h1").InnerText; | ||||
| 
 | ||||
|             var altNames = divMonster.SelectSingleNode("div[@class='trad']").InnerText; | ||||
|             var altNames = divMonster.SelectSingleNode("div[@class='trad']")?.InnerText; | ||||
|             if (altNames != null) | ||||
|             { | ||||
|                 var matchNames = new Regex(@"\[ (?<vo>.*?) \](?: \[ (?<alt>.*?) \])?").Match(altNames); | ||||
|                 monster.NameVO = matchNames.Groups["vo"].Value; | ||||
|                 monster.NamePHB = string.IsNullOrEmpty(matchNames.Groups["alt"].Value) ? monster.Name : matchNames.Groups["alt"].Value; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 monster.NamePHB = monster.Name; | ||||
|             } | ||||
| 
 | ||||
|             var divSansSerif = divMonster?.SelectSingleNode("div[contains(@class,'sansSerif')]"); | ||||
|             var typeSizeAlignment = divSansSerif?.SelectSingleNode("h2/em")?.InnerText; | ||||
|  |  | |||
|  | @ -74,11 +74,14 @@ namespace AideDeJeuLib.Monsters | |||
|             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={category}&t={type}&min={minPower}&max={maxPower}&sz={size}&lg={legendary}&s={source}", category, type, minPower, maxPower, size, legendary, 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 url = string.Format($"https://www.aidedd.org/dnd-filters/monstres.php?c={category}&t={type}&min={minPower}&max={maxPower}&sz={size}&lg={legendary}&s={source}", category, type, minPower, maxPower, size, legendary, source); | ||||
|             html = await client.GetStringAsync(url); | ||||
| 
 | ||||
|             var pack = new HtmlDocument(); | ||||
|             pack.LoadHtml(html); | ||||
|             var trs = pack.GetElementbyId("liste").Element("table").Elements("tr").ToList(); | ||||
|             //var trs = pack.GetElementbyId("liste").Element("table").Elements("tr").ToList(); | ||||
|             var trs = pack.DocumentNode.SelectSingleNode("//table[contains(@class,'liste')]").Elements("tr").ToList(); | ||||
|             var monsters = new List<Monster>(); | ||||
|             foreach (var tr in trs) | ||||
|             { | ||||
|  | @ -86,28 +89,28 @@ namespace AideDeJeuLib.Monsters | |||
|                 if (tds.Length > 0) | ||||
|                 { | ||||
|                     var monster = new Monster(); | ||||
|                     var aname = tds[0].Element("a"); | ||||
|                     var aname = tds[1].Element("a"); | ||||
|                     var spanname = aname.Element("span"); | ||||
|                     if (spanname != null) | ||||
|                     { | ||||
|                         monster.NamePHB = spanname.GetAttributeValue("title", ""); | ||||
|                         monster.Name = spanname.Element("strong").InnerText; | ||||
|                         monster.Name = spanname.InnerText; | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         monster.NamePHB = aname.Element("strong").InnerText; | ||||
|                         monster.Name = aname.Element("strong").InnerText; | ||||
|                         monster.NamePHB = aname.InnerText; | ||||
|                         monster.Name = aname.InnerText; | ||||
|                     } | ||||
| 
 | ||||
|                     //monster.Name = tds[0].InnerText; | ||||
|                     var href = aname.GetAttributeValue("href", ""); | ||||
|                     var regex = new Regex("vf=(?<id>.*)"); | ||||
|                     monster.Id = regex.Match(href).Groups["id"].Value; | ||||
|                     monster.Power = tds[1].InnerText; | ||||
|                     monster.Type = tds[2].InnerText; | ||||
|                     monster.Size = tds[3].InnerText; | ||||
|                     monster.Alignment = tds[4].InnerText; | ||||
|                     monster.Legendary = tds[5].InnerText; | ||||
|                     monster.Power = tds[2].InnerText; | ||||
|                     monster.Type = tds[3].InnerText; | ||||
|                     monster.Size = tds[4].InnerText; | ||||
|                     monster.Alignment = tds[5].InnerText; | ||||
|                     monster.Legendary = tds[6].InnerText; | ||||
|                     monsters.Add(monster); | ||||
|                 } | ||||
|             } | ||||
|  |  | |||
|  | @ -58,11 +58,19 @@ namespace AideDeJeuLib.Spells | |||
|         public static Spell FromHtml(HtmlNode nodeSpell) | ||||
|         { | ||||
|             var spell = new Spell(); | ||||
|             spell.Html = nodeSpell.OuterHtml; | ||||
|             spell.Name = nodeSpell.SelectSingleNode("h1").InnerText; | ||||
|             var altNames = nodeSpell.SelectSingleNode("div[@class='trad']").InnerText; | ||||
|             var altNames = nodeSpell.SelectSingleNode("div[@class='trad']")?.InnerText; | ||||
|             if (altNames != null) | ||||
|             { | ||||
|                 var matchNames = new Regex(@"\[ (?<vo>.*?) \](?: \[ (?<alt>.*?) \])?").Match(altNames); | ||||
|                 spell.NameVO = matchNames.Groups["vo"].Value; | ||||
|                 spell.NamePHB = string.IsNullOrEmpty(matchNames.Groups["alt"].Value) ? spell.Name : matchNames.Groups["alt"].Value; | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 spell.NamePHB = spell.Name; | ||||
|             } | ||||
|             spell.LevelType = nodeSpell.SelectSingleNode("h2/em").InnerText; | ||||
|             spell.Level = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[0].Split(' ')[1]; | ||||
|             spell.Type = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[1]; | ||||
|  |  | |||
|  | @ -72,12 +72,14 @@ namespace AideDeJeuLib.Spells | |||
|             var client = GetHttpClient(); | ||||
|             // https://www.aidedd.org/regles/sorts/ | ||||
| 
 | ||||
|             var url = string.Format("https://www.aidedd.org/regles/sorts/?c={0}&min={1}&max={2}&e={3}&r={4}&s={5}", classe, niveauMin, niveauMax, ecole, rituel, source); | ||||
|             //var url = string.Format("https://www.aidedd.org/regles/sorts/?c={0}&min={1}&max={2}&e={3}&r={4}&s={5}", classe, niveauMin, niveauMax, ecole, rituel, source); | ||||
|             var url = string.Format("https://www.aidedd.org/dnd-filters/sorts.php?c={0}&min={1}&max={2}&e={3}&r={4}&s={5}", classe, niveauMin, niveauMax, ecole, rituel, source); | ||||
|             html = await client.GetStringAsync(url); | ||||
| 
 | ||||
|             var pack = new HtmlDocument(); | ||||
|             pack.LoadHtml(html); | ||||
|             var tdssort = pack.GetElementbyId("liste").Element("table").Elements("tr").ToList(); | ||||
|             //var tdssort = pack.GetElementbyId("liste").Element("table").Elements("tr").ToList(); | ||||
|             var tdssort = pack.DocumentNode.SelectSingleNode("//table[contains(@class,'liste')]").Elements("tr").ToList(); | ||||
|             var spells = new List<Spell>(); | ||||
|             foreach (var tdsort in tdssort) | ||||
|             { | ||||
|  | @ -85,27 +87,27 @@ namespace AideDeJeuLib.Spells | |||
|                 if (thssort.Length > 0) | ||||
|                 { | ||||
|                     Spell spell = new Spell(); | ||||
|                     var aname = thssort[0].Element("a"); | ||||
|                     var aname = thssort[1].Element("a"); | ||||
|                     var spanname = aname.Element("span"); | ||||
|                     if(spanname != null) | ||||
|                     { | ||||
|                         spell.NamePHB = spanname.GetAttributeValue("title", ""); | ||||
|                         spell.Name = spanname.Element("strong").InnerText; | ||||
|                         spell.Name = spanname.InnerText; | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         spell.NamePHB = aname.Element("strong").InnerText; | ||||
|                         spell.Name = aname.Element("strong").InnerText; | ||||
|                         spell.NamePHB = aname.InnerText; | ||||
|                         spell.Name = aname.InnerText; | ||||
|                     } | ||||
|                     var href = aname.GetAttributeValue("href", ""); | ||||
|                     var regex = new Regex("vf=(?<id>.*)"); | ||||
|                     spell.Id = regex.Match(href).Groups["id"].Value; | ||||
| 
 | ||||
|                     spell.Level = thssort[1].InnerText; | ||||
|                     spell.Type = thssort[2].InnerText; | ||||
|                     spell.CastingTime = thssort[3].InnerText; | ||||
|                     spell.Concentration = thssort[4].InnerText; | ||||
|                     spell.Rituel = thssort[5].InnerText; | ||||
|                     spell.Level = thssort[2].InnerText; | ||||
|                     spell.Type = thssort[3].InnerText; | ||||
|                     spell.CastingTime = thssort[4].InnerText; | ||||
|                     spell.Concentration = thssort[5].InnerText; | ||||
|                     spell.Rituel = thssort[6].InnerText; | ||||
|                     spells.Add(spell); | ||||
|                 } | ||||
|             } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez