diff --git a/AideDeJeu/AideDeJeu/ViewModels/Library/FilterViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/Library/FilterViewModel.cs index 89cc3866..f1bb7504 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/Library/FilterViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/Library/FilterViewModel.cs @@ -34,6 +34,15 @@ namespace AideDeJeu.ViewModels.Library Helpers.RemoveDiacritics(item.AltNameText ?? string.Empty).ToLower().Contains(Helpers.RemoveDiacritics(SearchText ?? string.Empty).ToLower()); } + public bool MatchContainsOrNot(string itemValue, string filterValue) + { + if (!string.IsNullOrEmpty(filterValue) && string.IsNullOrWhiteSpace(filterValue)) + { + return string.IsNullOrEmpty(itemValue); + } + return string.IsNullOrEmpty(filterValue) || (itemValue != null && itemValue.ToLower().Contains(filterValue.ToLower())); + } + public bool MatchContains(string itemValue, string filterValue) { return string.IsNullOrEmpty(filterValue) || (itemValue != null && itemValue.ToLower().Contains(filterValue.ToLower())); @@ -265,9 +274,9 @@ namespace AideDeJeu.ViewModels.Library var ritual = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Ritual).SelectedKey ?? ""; var castingTime = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.CastingTime).SelectedKey ?? ""; var range = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Range).SelectedKey ?? ""; - var verbalComponents = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.VerbalComponent).SelectedKey ?? ""; - var somaticComponents = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.SomaticComponent).SelectedKey ?? ""; - var materialComponents = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MaterialComponent).SelectedKey ?? ""; + var verbalComponent = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.VerbalComponent).SelectedKey ?? ""; + var somaticComponent = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.SomaticComponent).SelectedKey ?? ""; + var materialComponent = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.MaterialComponent).SelectedKey ?? ""; var concentration = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Concentration).SelectedKey ?? ""; var duration = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Duration).SelectedKey ?? ""; var source = Filters.SingleOrDefault(filter => filter.Key == FilterKeys.Source).SelectedKey ?? ""; @@ -283,13 +292,13 @@ namespace AideDeJeu.ViewModels.Library spell.Type.ToLower().Contains(school.ToLower()) && (spell.Source != null && spell.Source.Contains(source)) && (spell.Classes != null && spell.Classes.Contains(classe)) && - (string.IsNullOrEmpty(ritual) || (spell.Ritual != null && spell.Ritual.Contains(ritual))) && + MatchContainsOrNot(spell.Ritual, ritual) && (spell.CastingTime != null) && spell.CastingTime.Contains(castingTime) && (spell.Range != null) && spell.Range.Contains(range) && - (string.IsNullOrEmpty(verbalComponents) || (spell.VerbalComponent != null && spell.VerbalComponent.Contains(verbalComponents))) && - (string.IsNullOrEmpty(somaticComponents) || (spell.SomaticComponent != null && spell.SomaticComponent.Contains(somaticComponents))) && - (string.IsNullOrEmpty(materialComponents) || (spell.MaterialComponent != null && spell.MaterialComponent.Contains(materialComponents))) && - (string.IsNullOrEmpty(concentration) || (spell.Concentration != null && spell.Concentration.Contains(concentration))) && + MatchContainsOrNot(spell.VerbalComponent, verbalComponent) && + MatchContainsOrNot(spell.SomaticComponent, somaticComponent) && + MatchContainsOrNot(spell.MaterialComponent, materialComponent) && + MatchContainsOrNot(spell.Concentration, concentration) && (spell.Duration != null) && spell.Duration.Contains(duration) && ( (Helpers.RemoveDiacritics(spell.Name).ToLower().Contains(Helpers.RemoveDiacritics(SearchText ?? string.Empty).ToLower())) || diff --git a/Data/HD/hd_spells.md b/Data/HD/hd_spells.md index 3c412fe2..d4a4261e 100644 --- a/Data/HD/hd_spells.md +++ b/Data/HD/hd_spells.md @@ -3,13 +3,13 @@ Classes: Barde|Clerc|Druide|Ensorceleur|Magicien|Ombrelame|Paladin|Rôdeur|Sorcier Levels: Sorts mineurs|Niveau 1|Niveau 2|Niveau 3|Niveau 4|Niveau 5|Niveau 6|Niveau 7|Niveau 8|Niveau 9 Schools: Abjuration|Divination|Enchantement|Évocation|Illusion|Invocation|Nécromancie|Transmutation -Rituals: Rituel +Rituals: 'Rituel| ' CastingTimes: 1 action|1 action bonus|1 réaction|1 minute|10 minutes|1 heure|8 heures|12 heures|24 heures Ranges: personnel|contact|vision|selon l'arme utilisée|spéciale|1,5 mètre|3 mètres|4,50 mètres|9 mètres|12 mètres|18 mètres|27 mètres|30 mètres|36 mètres|45 mètres|90 mètres|150 mètres|450 mètres|1 kilomètre|1,5 kilomètre|7,5 kilomètres|750 kilomètres|illimitée -VerbalComponents: V -SomaticComponents: S -MaterialComponents: M -Concentrations: concentration +VerbalComponents: 'V| ' +SomaticComponents: 'S| ' +MaterialComponents: 'M| ' +Concentrations: 'concentration| ' Durations: instantané|1 round|1 minute|10 minutes|1 heure|2 heures|8 heures|24 heures|1 jour|7 jours|10 jours|30 jours|dissipation|déclenchement|spéciale Sources: SRD|MDR Family: SpellHD diff --git a/Data/library.db b/Data/library.db index 71911a1c..bb3b9426 100644 Binary files a/Data/library.db and b/Data/library.db differ diff --git a/Data/spells_hd.md b/Data/spells_hd.md index ff7837a1..857b0953 100644 --- a/Data/spells_hd.md +++ b/Data/spells_hd.md @@ -1,5 +1,5 @@  - +[Manuel des règles](index.md)