mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-23 10:33:50 +00:00
Sorts HD presque finaux
This commit is contained in:
parent
60c8301532
commit
9aa9002884
15 changed files with 9048 additions and 17 deletions
|
|
@ -17,6 +17,10 @@
|
|||
<None Remove="OGL.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\..\Data\spells_hd.json" Link="Data\spells_hd.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\..\Data\monsters_vf.json" Link="Data\monsters_vf.json" />
|
||||
<EmbeddedResource Include="..\..\Data\monsters_vo.json" Link="Data\monsters_vo.json" />
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ namespace AideDeJeu.ViewModels
|
|||
var serializer = new DataContractJsonSerializer(typeof(IEnumerable<Spell>));
|
||||
var assembly = typeof(AboutViewModel).GetTypeInfo().Assembly;
|
||||
//var names = assembly.GetManifestResourceNames();
|
||||
using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_vf.json"))
|
||||
using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.spells_hd.json"))
|
||||
{
|
||||
_AllSpells = serializer.ReadObject(stream) as IEnumerable<Spell>;
|
||||
}
|
||||
|
|
@ -200,14 +200,15 @@ namespace AideDeJeu.ViewModels
|
|||
|
||||
public IEnumerable<Spell> GetSpells(string classe, string niveauMin, string niveauMax, string ecole, string rituel, string source)
|
||||
{
|
||||
return AllSpells.Where(spell =>
|
||||
(int.Parse(spell.Level) >= int.Parse(niveauMin)) &&
|
||||
(int.Parse(spell.Level) <= int.Parse(niveauMax)) &&
|
||||
spell.Type.Contains(ecole) &&
|
||||
spell.Source.Contains(source) &&
|
||||
spell.Source.Contains(classe) &&
|
||||
spell.Type.Contains(rituel)
|
||||
)
|
||||
return AllSpells
|
||||
.Where(spell =>
|
||||
(int.Parse(spell.Level) >= int.Parse(niveauMin)) &&
|
||||
(int.Parse(spell.Level) <= int.Parse(niveauMax)) &&
|
||||
spell.Type.ToLower().Contains(ecole.ToLower()) &&
|
||||
spell.Source.Contains(source) &&
|
||||
spell.Source.Contains(classe) &&
|
||||
spell.Type.Contains(rituel)
|
||||
)
|
||||
.OrderBy(spell => spell.NamePHB)
|
||||
.ToList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,13 @@ using AideDeJeuLib.Spells;
|
|||
using HtmlAgilityPack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AideDeJeuCmd
|
||||
|
|
@ -60,6 +64,22 @@ namespace AideDeJeuCmd
|
|||
SaveJSon<IEnumerable<Monster>>(dataDir + "monsters_vf.json", monsters);
|
||||
SaveJSon<IEnumerable<Monster>>(dataDir + "monsters_vo.json", monstersVO);
|
||||
*/
|
||||
var spellsVF = LoadJSon<IEnumerable<Spell>>(dataDir + "spells_vf.json");
|
||||
var spellsVO = LoadJSon<IEnumerable<Spell>>(dataDir + "spells_vo.json");
|
||||
|
||||
var spellLists = new Dictionary<string, IEnumerable<string>>()
|
||||
{
|
||||
{ "Barde", await LoadList(dataDir + "spell_barde.txt") },
|
||||
{ "Clerc", await LoadList(dataDir + "spell_clerc.txt") },
|
||||
{ "Druide", await LoadList(dataDir + "spell_druide.txt") },
|
||||
{ "Ensorceleur", await LoadList(dataDir + "spell_ensorceleur.txt") },
|
||||
{ "Magicien", await LoadList(dataDir + "spell_magicien.txt") },
|
||||
{ "Ombrelame", await LoadList(dataDir + "spell_ombrelame.txt") },
|
||||
{ "Paladin", await LoadList(dataDir + "spell_paladin.txt") },
|
||||
{ "Rôdeur", await LoadList(dataDir + "spell_rodeur.txt") },
|
||||
{ "Sorcier", await LoadList(dataDir + "spell_sorcier.txt") },
|
||||
};
|
||||
|
||||
var spellsHD = new List<Spell>();
|
||||
var spell = new Spell();
|
||||
using (var reader = new StreamReader(dataDir + "spells_hd.txt"))
|
||||
|
|
@ -72,6 +92,25 @@ namespace AideDeJeuCmd
|
|||
Console.WriteLine(spell.NamePHB);
|
||||
|
||||
spell.DescriptionHtml = await FormatDescriptionAsync(spell.DescriptionHtml);
|
||||
spell.Source = "(HD)";
|
||||
spell.Id = spell.IdVF = IdFromName(spell.NamePHB);
|
||||
var spVF = spellsVF.SingleOrDefault(sp => IdFromName(sp.NamePHB) == spell.Id);
|
||||
if(spVF != null)
|
||||
{
|
||||
if(spVF.Source.Contains("(SRD)"))
|
||||
{
|
||||
spell.Source += "(SRD)";
|
||||
}
|
||||
}
|
||||
foreach (var spellList in spellLists)
|
||||
{
|
||||
if(spellList.Value.Contains(spell.NamePHB.ToLower()))
|
||||
{
|
||||
spell.Source += " " + spellList.Key + " ;";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
spellsHD.Add(spell);
|
||||
spell = new Spell();
|
||||
}
|
||||
|
|
@ -84,14 +123,27 @@ namespace AideDeJeuCmd
|
|||
else if (spell.LevelType == null)
|
||||
{
|
||||
spell.LevelType = line;
|
||||
var re = new Regex("(?<type>.*) de niveau (?<level>\\d*).?(?<rituel>\\(rituel\\))?");
|
||||
var match = re.Match(line);
|
||||
spell.Type = match.Groups["type"].Value;
|
||||
spell.Level = match.Groups["level"].Value;
|
||||
spell.Rituel = match.Groups["rituel"].Value;
|
||||
if (string.IsNullOrEmpty(spell.Type))
|
||||
{
|
||||
re = new Regex("(?<type>.*), (?<level>tour de magie)");
|
||||
match = re.Match(line);
|
||||
spell.Type = match.Groups["type"].Value;
|
||||
spell.Level = "0"; // match.Groups["level"].Value;
|
||||
spell.Rituel = match.Groups["rituel"].Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(line.StartsWith("Temps d’incantation : "))
|
||||
{
|
||||
if (line.StartsWith("Temps d’incantation : "))
|
||||
{
|
||||
spell.CastingTime = line.Substring(22);
|
||||
}
|
||||
else if(line.StartsWith("Portée : "))
|
||||
else if (line.StartsWith("Portée : "))
|
||||
{
|
||||
spell.Range = line.Substring(9);
|
||||
}
|
||||
|
|
@ -129,6 +181,21 @@ namespace AideDeJeuCmd
|
|||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
|
||||
public static string RemoveDiacritics(string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return text;
|
||||
|
||||
text = text.Normalize(NormalizationForm.FormD);
|
||||
var chars = text.Where(c => CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark).ToArray();
|
||||
return new string(chars).Normalize(NormalizationForm.FormC);
|
||||
}
|
||||
|
||||
static string IdFromName(string name)
|
||||
{
|
||||
return RemoveDiacritics(name.ToLower().Replace(" ", "-"));
|
||||
}
|
||||
|
||||
static async Task<string> FormatDescriptionAsync(string description)
|
||||
{
|
||||
string formattedDescription = "";
|
||||
|
|
@ -143,6 +210,125 @@ namespace AideDeJeuCmd
|
|||
li = true;
|
||||
formattedDescription += "<li>" + line.Substring(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
var titles = new List<string>()
|
||||
{
|
||||
"À plus haut niveau.",
|
||||
"Agrandir.",
|
||||
"Rétrécir.",
|
||||
"Endurance de l’ours.",
|
||||
"Force du taureau.",
|
||||
"Grâce du chat.",
|
||||
"Splendeur de l’aigle.",
|
||||
"Ruse du renard.",
|
||||
"Sagesse du hibou.",
|
||||
"Aura factice.",
|
||||
"Masque.",
|
||||
"Effets visant une cible.",
|
||||
"Zones de magie.",
|
||||
"Sorts.",
|
||||
"Objets magiques.",
|
||||
"Déplacement magique.",
|
||||
"Créatures et objets.",
|
||||
"Dissipation de la magie.",
|
||||
"Bouille-crâne.",
|
||||
"Convulsions.",
|
||||
"Fièvre répugnante.",
|
||||
"Mal aveuglant.",
|
||||
"Mort poisseuse.",
|
||||
"Pourriture.",
|
||||
"Écarter les eaux.",
|
||||
"Inondation.",
|
||||
"Modifier le cours de l’eau.",
|
||||
"Tourbillon.",
|
||||
"Création d’eau.",
|
||||
"Destruction d’eau.",
|
||||
"Si vous lancez ce sort en une action, choisissez un point à portée.",
|
||||
"Si vous lancez le sort sur une période de huit heures, vous enrichissez la terre.",
|
||||
"Annulation d’enchantement.",
|
||||
"Renvoi.",
|
||||
"Confinement minimal.",
|
||||
"Enchaîné.",
|
||||
"Enseveli.",
|
||||
"Prison isolée.",
|
||||
"Sommeil.",
|
||||
"Mettre fin au sort.",
|
||||
"Glyphe à sort.",
|
||||
"Runes explosives.",
|
||||
"Approche.",
|
||||
"Arrête.",
|
||||
"Fuis.",
|
||||
"Lâche.",
|
||||
"Rampe.",
|
||||
"Main agrippeuse.",
|
||||
"Main interposée.",
|
||||
"Main percutante.",
|
||||
"Poing serré.",
|
||||
"Nauséeux.",
|
||||
"Endormi.",
|
||||
"Paniqué.",
|
||||
"Créature en créature.",
|
||||
"Objet en créature.",
|
||||
"Créature en objet.",
|
||||
"Adaptation aquatique.",
|
||||
"Armes naturelles.",
|
||||
"Changer d’apparence.",
|
||||
"1. Rouge.",
|
||||
"2. Orange.",
|
||||
"3. Jaune.",
|
||||
"4. Vert.",
|
||||
"5. Bleu.",
|
||||
"6. Indigo.",
|
||||
"7. Violet.",
|
||||
"Couloirs.",
|
||||
"Escaliers.",
|
||||
"Portes.",
|
||||
"Autres effets de sort.",
|
||||
"Attirance.",
|
||||
"Répulsion.",
|
||||
"Mettre un terme à l’effet.",
|
||||
"Courage.",
|
||||
"Interférence extradimensionnelle.",
|
||||
"Langues.",
|
||||
"Lumière du jour.",
|
||||
"Protection contres les énergies.",
|
||||
"Repos éternel.",
|
||||
"Ténèbres.",
|
||||
"Vulnérabilité à l’énergie.",
|
||||
"Silence.",
|
||||
"Terreur.",
|
||||
"Démence.",
|
||||
"Désespoir.",
|
||||
"Discorde.",
|
||||
"Douleur.",
|
||||
"Étourdissement.",
|
||||
"Frayeur.",
|
||||
"Mort.",
|
||||
"Sommeil.",
|
||||
"Créatures.",
|
||||
"Objets.",
|
||||
"Familiarité.",
|
||||
"Sur place.",
|
||||
"À proximité.",
|
||||
"Zone similaire.",
|
||||
"Incident.",
|
||||
"Round 2.",
|
||||
"Round 3.",
|
||||
"Round 4.",
|
||||
"Rounds 5 à 10.",
|
||||
"Fissures.",
|
||||
"Structures.",
|
||||
};
|
||||
foreach (var title in titles)
|
||||
{
|
||||
if (line.StartsWith(title))
|
||||
{
|
||||
line = "<strong><em>" + title + "</em></strong>" + line.Substring(title.Length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line.EndsWith("."))
|
||||
{
|
||||
|
|
@ -186,5 +372,23 @@ namespace AideDeJeuCmd
|
|||
serializer.WriteObject(stream, objT);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<IEnumerable<string>> LoadList(string filename)
|
||||
{
|
||||
using (var stream = new StreamReader(filename))
|
||||
{
|
||||
var lines = new List<string>();
|
||||
var line = await stream.ReadLineAsync();
|
||||
while (line != null)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(line))
|
||||
{
|
||||
lines.Add(line);
|
||||
}
|
||||
line = await stream.ReadLineAsync();
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue