1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 22:45:44 +00:00

Recablage Monsters

This commit is contained in:
Yan Maniez 2018-05-28 09:18:25 +02:00
parent 37198340ec
commit 2c0d222a03
5 changed files with 491 additions and 270 deletions

View file

@ -19,7 +19,7 @@ namespace AideDeJeu.Tools
{
public override int Compare(string x, string y)
{
var regex = new Regex(@"\((?<xp>\d*?) PX\)");
var regex = new Regex(@"\((?<xp>\d*?) (PX|XP)\)");
int xpx = int.Parse(regex.Match(x).Groups["xp"].Value);
int xpy = int.Parse(regex.Match(y).Groups["xp"].Value);
return xpx - xpy;

View file

@ -1,5 +1,10 @@
using System;
using AideDeJeu.Tools;
using AideDeJeuLib;
using AideDeJeuLib.Monsters;
using AideDeJeuLib.Spells;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
@ -8,11 +13,36 @@ namespace AideDeJeu.ViewModels
public abstract class FilterViewModel : BaseViewModel
{
public ICommand LoadItemsCommand { get; protected set; }
public abstract IEnumerable<Item> FilterItems(IEnumerable<Item> items);
}
#region Spells
public abstract class SpellFilterViewModel : FilterViewModel
{
public override IEnumerable<Item> FilterItems(IEnumerable<Item> items)
{
var classe = Classes[Classe].Key;
var niveauMin = Niveaux[NiveauMin].Key;
var niveauMax = Niveaux[NiveauMax].Key;
var ecole = Ecoles[Ecole].Key;
var rituel = Rituels[Rituel].Key;
var source = Sources[Source].Key;
return items
.Where(item =>
{
var spell = item as Spell;
return (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();
}
public abstract List<KeyValuePair<string, string>> Classes { get; }
public abstract List<KeyValuePair<string, string>> Niveaux { get; }
@ -302,9 +332,434 @@ namespace AideDeJeu.ViewModels
#endregion Spells
#region Monsters
public class MonsterFilterViewModel : FilterViewModel
public abstract class MonsterFilterViewModel : FilterViewModel
{
public override IEnumerable<Item> FilterItems(IEnumerable<Item> items)
{
var powerComparer = new PowerComparer();
var category = Categories[Category].Key;
var type = Types[Type].Key;
var minPower = Powers[MinPower].Key;
var maxPower = Powers[MaxPower].Key;
var size = Sizes[Size].Key;
var legendary = Legendaries[Legendary].Key;
var source = Sources[Source].Key;
return items.Where(item =>
{
var monster = item as Monster;
return monster.Type.Contains(type) &&
(string.IsNullOrEmpty(size) || monster.Size.Equals(size)) &&
monster.Source.Contains(source) &&
powerComparer.Compare(monster.Challenge, minPower) >= 0 &&
powerComparer.Compare(monster.Challenge, maxPower) <= 0;
})
.OrderBy(monster => monster.NamePHB)
.ToList();
}
public abstract List<KeyValuePair<string, string>> Categories { get; }
public abstract List<KeyValuePair<string, string>> Types { get; }
public abstract List<KeyValuePair<string, string>> Powers { get; }
public abstract List<KeyValuePair<string, string>> Sizes { get; }
public abstract List<KeyValuePair<string, string>> Legendaries { get; }
public abstract List<KeyValuePair<string, string>> Sources { get; }
private int _Category = 0;
public int Category
{
get
{
return _Category;
}
set
{
if (_Category != value)
{
SetProperty(ref _Category, value);
LoadItemsCommand.Execute(null);
}
}
}
private int _Type = 0;
public int Type
{
get
{
return _Type;
}
set
{
if (_Type != value)
{
SetProperty(ref _Type, value);
LoadItemsCommand.Execute(null);
}
}
}
private int _MinPower = 0;
public int MinPower
{
get
{
return _MinPower;
}
set
{
if (_MinPower != value)
{
SetProperty(ref _MinPower, value);
if (_MaxPower < _MinPower)
{
SetProperty(ref _MaxPower, value, nameof(MaxPower));
}
LoadItemsCommand.Execute(null);
}
}
}
private int _MaxPower = 28;
public int MaxPower
{
get
{
return _MaxPower;
}
set
{
if (_MaxPower != value)
{
SetProperty(ref _MaxPower, value);
if (_MaxPower < _MinPower)
{
SetProperty(ref _MinPower, value, nameof(MinPower));
}
LoadItemsCommand.Execute(null);
}
}
}
private int _Size = 0;
public int Size
{
get
{
return _Size;
}
set
{
if (_Size != value)
{
SetProperty(ref _Size, value);
LoadItemsCommand.Execute(null);
}
}
}
private int _Legendary = 0;
public int Legendary
{
get
{
return _Legendary;
}
set
{
if (_Legendary != value)
{
SetProperty(ref _Legendary, value);
LoadItemsCommand.Execute(null);
}
}
}
private int _Source = 1;
public int Source
{
get
{
return _Source;
}
set
{
if (_Source != value)
{
SetProperty(ref _Source, value);
LoadItemsCommand.Execute(null);
}
}
}
}
public class VFMonsterFilterViewModel : MonsterFilterViewModel
{
public override List<KeyValuePair<string, string>> Categories { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes" ),
new KeyValuePair<string, string>("M", "Monstres" ),
new KeyValuePair<string, string>("A", "Animaux" ),
new KeyValuePair<string, string>("P", "PNJ" ),
};
public override List<KeyValuePair<string, string>> Types { get; } = new List<KeyValuePair<string, string>>()
{
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 override List<KeyValuePair<string, string>> Powers { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>(" 0 (0 PX)", "0" ),
new KeyValuePair<string, string>(" 1/8 (25 PX)", "1/8" ),
new KeyValuePair<string, string>(" 1/4 (50 PX)", "1/4" ),
new KeyValuePair<string, string>(" 1/2 (100 PX)", "1/2" ),
new KeyValuePair<string, string>(" 1 (200 PX)", "1" ),
new KeyValuePair<string, string>(" 2 (450 PX)", "2" ),
new KeyValuePair<string, string>(" 3 (700 PX)", "3" ),
new KeyValuePair<string, string>(" 4 (1100 PX)", "4" ),
new KeyValuePair<string, string>(" 5 (1800 PX)", "5" ),
new KeyValuePair<string, string>(" 6 (2300 PX)", "6" ),
new KeyValuePair<string, string>(" 7 (2900 PX)", "7" ),
new KeyValuePair<string, string>(" 8 (3900 PX)", "8" ),
new KeyValuePair<string, string>(" 9 (5000 PX)", "9" ),
new KeyValuePair<string, string>(" 10 (5900 PX)", "10" ),
new KeyValuePair<string, string>(" 11 (7200 PX)", "11" ),
new KeyValuePair<string, string>(" 12 (8400 PX)", "12" ),
new KeyValuePair<string, string>(" 13 (10000 PX)", "13" ),
new KeyValuePair<string, string>(" 14 (11500 PX)", "14" ),
new KeyValuePair<string, string>(" 15 (13000 PX)", "15" ),
new KeyValuePair<string, string>(" 16 (15000 PX)", "16" ),
new KeyValuePair<string, string>(" 17 (18000 PX)", "17" ),
new KeyValuePair<string, string>(" 18 (20000 PX)", "18" ),
new KeyValuePair<string, string>(" 19 (22000 PX)", "19" ),
new KeyValuePair<string, string>(" 20 (25000 PX)", "20" ),
new KeyValuePair<string, string>(" 21 (33000 PX)", "21" ),
new KeyValuePair<string, string>(" 22 (41000 PX)", "22" ),
new KeyValuePair<string, string>(" 23 (50000 PX)", "23" ),
new KeyValuePair<string, string>(" 24 (62000 PX)", "24" ),
new KeyValuePair<string, string>(" 30 (155000 PX)", "30" ),
};
public override List<KeyValuePair<string, string>> Sizes { get; } = 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 override List<KeyValuePair<string, string>> Legendaries { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("si", "Si"),
new KeyValuePair<string, string>("no", "Non"),
};
public override List<KeyValuePair<string, string>> Sources { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("(SRD)", "SRD"),
new KeyValuePair<string, string>("Monster Manual", "MM"),
new KeyValuePair<string, string>("sup", "VGtM, MToF"),
new KeyValuePair<string, string>("supno", "AL, AideDD"),
};
}
public class VOMonsterFilterViewModel : MonsterFilterViewModel
{
public override List<KeyValuePair<string, string>> Categories { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes" ),
new KeyValuePair<string, string>("M", "Monstres" ),
new KeyValuePair<string, string>("A", "Animaux" ),
new KeyValuePair<string, string>("P", "PNJ" ),
};
public override List<KeyValuePair<string, string>> Types { get; } = new List<KeyValuePair<string, string>>()
{
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 override List<KeyValuePair<string, string>> Powers { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>(" 0 (0 PX)", "0" ),
new KeyValuePair<string, string>(" 1/8 (25 PX)", "1/8" ),
new KeyValuePair<string, string>(" 1/4 (50 PX)", "1/4" ),
new KeyValuePair<string, string>(" 1/2 (100 PX)", "1/2" ),
new KeyValuePair<string, string>(" 1 (200 PX)", "1" ),
new KeyValuePair<string, string>(" 2 (450 PX)", "2" ),
new KeyValuePair<string, string>(" 3 (700 PX)", "3" ),
new KeyValuePair<string, string>(" 4 (1100 PX)", "4" ),
new KeyValuePair<string, string>(" 5 (1800 PX)", "5" ),
new KeyValuePair<string, string>(" 6 (2300 PX)", "6" ),
new KeyValuePair<string, string>(" 7 (2900 PX)", "7" ),
new KeyValuePair<string, string>(" 8 (3900 PX)", "8" ),
new KeyValuePair<string, string>(" 9 (5000 PX)", "9" ),
new KeyValuePair<string, string>(" 10 (5900 PX)", "10" ),
new KeyValuePair<string, string>(" 11 (7200 PX)", "11" ),
new KeyValuePair<string, string>(" 12 (8400 PX)", "12" ),
new KeyValuePair<string, string>(" 13 (10000 PX)", "13" ),
new KeyValuePair<string, string>(" 14 (11500 PX)", "14" ),
new KeyValuePair<string, string>(" 15 (13000 PX)", "15" ),
new KeyValuePair<string, string>(" 16 (15000 PX)", "16" ),
new KeyValuePair<string, string>(" 17 (18000 PX)", "17" ),
new KeyValuePair<string, string>(" 18 (20000 PX)", "18" ),
new KeyValuePair<string, string>(" 19 (22000 PX)", "19" ),
new KeyValuePair<string, string>(" 20 (25000 PX)", "20" ),
new KeyValuePair<string, string>(" 21 (33000 PX)", "21" ),
new KeyValuePair<string, string>(" 22 (41000 PX)", "22" ),
new KeyValuePair<string, string>(" 23 (50000 PX)", "23" ),
new KeyValuePair<string, string>(" 24 (62000 PX)", "24" ),
new KeyValuePair<string, string>(" 30 (155000 PX)", "30" ),
};
public override List<KeyValuePair<string, string>> Sizes { get; } = 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 override List<KeyValuePair<string, string>> Legendaries { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("si", "Si"),
new KeyValuePair<string, string>("no", "Non"),
};
public override List<KeyValuePair<string, string>> Sources { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("(SRD)", "SRD"),
new KeyValuePair<string, string>("Monster Manual", "MM"),
new KeyValuePair<string, string>("sup", "VGtM, MToF"),
new KeyValuePair<string, string>("supno", "AL, AideDD"),
};
}
public class HDMonsterFilterViewModel : MonsterFilterViewModel
{
public override List<KeyValuePair<string, string>> Categories { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes" ),
new KeyValuePair<string, string>("M", "Monstres" ),
new KeyValuePair<string, string>("A", "Animaux" ),
new KeyValuePair<string, string>("P", "PNJ" ),
};
public override List<KeyValuePair<string, string>> Types { get; } = new List<KeyValuePair<string, string>>()
{
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 override List<KeyValuePair<string, string>> Powers { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>(" 0 (0 PX)", "0" ),
new KeyValuePair<string, string>(" 1/8 (25 PX)", "1/8" ),
new KeyValuePair<string, string>(" 1/4 (50 PX)", "1/4" ),
new KeyValuePair<string, string>(" 1/2 (100 PX)", "1/2" ),
new KeyValuePair<string, string>(" 1 (200 PX)", "1" ),
new KeyValuePair<string, string>(" 2 (450 PX)", "2" ),
new KeyValuePair<string, string>(" 3 (700 PX)", "3" ),
new KeyValuePair<string, string>(" 4 (1100 PX)", "4" ),
new KeyValuePair<string, string>(" 5 (1800 PX)", "5" ),
new KeyValuePair<string, string>(" 6 (2300 PX)", "6" ),
new KeyValuePair<string, string>(" 7 (2900 PX)", "7" ),
new KeyValuePair<string, string>(" 8 (3900 PX)", "8" ),
new KeyValuePair<string, string>(" 9 (5000 PX)", "9" ),
new KeyValuePair<string, string>(" 10 (5900 PX)", "10" ),
new KeyValuePair<string, string>(" 11 (7200 PX)", "11" ),
new KeyValuePair<string, string>(" 12 (8400 PX)", "12" ),
new KeyValuePair<string, string>(" 13 (10000 PX)", "13" ),
new KeyValuePair<string, string>(" 14 (11500 PX)", "14" ),
new KeyValuePair<string, string>(" 15 (13000 PX)", "15" ),
new KeyValuePair<string, string>(" 16 (15000 PX)", "16" ),
new KeyValuePair<string, string>(" 17 (18000 PX)", "17" ),
new KeyValuePair<string, string>(" 18 (20000 PX)", "18" ),
new KeyValuePair<string, string>(" 19 (22000 PX)", "19" ),
new KeyValuePair<string, string>(" 20 (25000 PX)", "20" ),
new KeyValuePair<string, string>(" 21 (33000 PX)", "21" ),
new KeyValuePair<string, string>(" 22 (41000 PX)", "22" ),
new KeyValuePair<string, string>(" 23 (50000 PX)", "23" ),
new KeyValuePair<string, string>(" 24 (62000 PX)", "24" ),
new KeyValuePair<string, string>(" 30 (155000 PX)", "30" ),
};
public override List<KeyValuePair<string, string>> Sizes { get; } = 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 override List<KeyValuePair<string, string>> Legendaries { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("si", "Si"),
new KeyValuePair<string, string>("no", "Non"),
};
public override List<KeyValuePair<string, string>> Sources { get; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("(SRD)", "SRD"),
new KeyValuePair<string, string>("Monster Manual", "MM"),
new KeyValuePair<string, string>("sup", "VGtM, MToF"),
new KeyValuePair<string, string>("supno", "AL, AideDD"),
};
}
#endregion Monsters
}

View file

@ -12,11 +12,9 @@ namespace AideDeJeu.ViewModels
{
LoadItemsCommand = new Command(() => ExecuteLoadItemsCommand(null));
}
protected ObservableCollection<Item> AllItems { get; set; } = new ObservableCollection<Item>();
public ICommand LoadItemsCommand { get; protected set; }
public abstract void ExecuteLoadItemsCommand(FilterViewModel filterViewModel);
public abstract Task ExecuteGotoItemCommandAsync(Item item);
protected INavigator Navigator { get; set; }
//private string _SearchText = "";
//public string SearchText

View file

@ -37,7 +37,7 @@ namespace AideDeJeu.ViewModels
public class MainViewModel : BaseViewModel
{
private ItemSourceType _ItemSourceType = ItemSourceType.SpellHD;
private ItemSourceType _ItemSourceType = ItemSourceType.MonsterVO;
public ItemSourceType ItemSourceType
{
get
@ -54,31 +54,14 @@ namespace AideDeJeu.ViewModels
}
}
//private ItemSource _ItemsSource = ItemSource.VF;
//public ItemSource ItemsSource
//{
// get
// {
// return _ItemsSource;
// }
// set
// {
// //CurrentViewModel.SearchText = "";
// SetProperty(ref _ItemsSource, value);
// //CurrentViewModel.SearchText = "";
// //OnPropertyChanged(nameof(CurrentViewModel));
// LoadItemsCommand.Execute(null);
// }
//}
public Dictionary<ItemSourceType, Lazy<ItemsViewModel>> AllItemsViewModel = new Dictionary<ItemSourceType, Lazy<ItemsViewModel>>()
{
{ ItemSourceType.SpellVF, new Lazy<ItemsViewModel>(() => new SpellsViewModel(ItemSourceType.SpellVF)) },
{ ItemSourceType.SpellVO, new Lazy<ItemsViewModel>(() => new SpellsViewModel(ItemSourceType.SpellVO)) },
{ ItemSourceType.SpellHD, new Lazy<ItemsViewModel>(() => new SpellsViewModel(ItemSourceType.SpellHD)) },
{ ItemSourceType.MonsterVF, new Lazy<ItemsViewModel>(() => new MonstersViewModel()) },
{ ItemSourceType.MonsterVO, new Lazy<ItemsViewModel>(() => new MonstersViewModel()) },
{ ItemSourceType.MonsterHD, new Lazy<ItemsViewModel>(() => new MonstersViewModel()) },
{ ItemSourceType.MonsterVF, new Lazy<ItemsViewModel>(() => new MonstersViewModel(ItemSourceType.MonsterVF)) },
{ ItemSourceType.MonsterVO, new Lazy<ItemsViewModel>(() => new MonstersViewModel(ItemSourceType.MonsterVO)) },
{ ItemSourceType.MonsterHD, new Lazy<ItemsViewModel>(() => new MonstersViewModel(ItemSourceType.MonsterHD)) },
};
public ItemsViewModel GetItemsViewModel(ItemSourceType itemSourceType)
@ -91,6 +74,9 @@ namespace AideDeJeu.ViewModels
{ ItemSourceType.SpellVF, new Lazy<FilterViewModel>(() => new VFSpellFilterViewModel()) },
{ ItemSourceType.SpellVO, new Lazy<FilterViewModel>(() => new VOSpellFilterViewModel()) },
{ ItemSourceType.SpellHD, new Lazy<FilterViewModel>(() => new HDSpellFilterViewModel()) },
{ ItemSourceType.MonsterVF, new Lazy<FilterViewModel>(() => new VFMonsterFilterViewModel()) },
{ ItemSourceType.MonsterVO, new Lazy<FilterViewModel>(() => new VOMonsterFilterViewModel()) },
{ ItemSourceType.MonsterHD, new Lazy<FilterViewModel>(() => new HDMonsterFilterViewModel()) },
};
public FilterViewModel GetFilterViewModel(ItemSourceType itemSourceType)
@ -98,28 +84,6 @@ namespace AideDeJeu.ViewModels
return AllFiltersViewModel[itemSourceType].Value;
}
//public ItemsViewModel SpellsVF
//{
// get
// {
// return AllItemsViewModel[ItemSourceType.SpellVF].Value;
// }
//}
//public ItemsViewModel CurrentViewModel
//{
// get
// {
// if (ItemsType == ItemType.Spell)
// {
// return Spells;
// }
// if (ItemsType == ItemType.Monster)
// {
// return Monsters;
// }
// return null;
// }
//}
public ObservableCollection<Item> Items { get; private set; } = new ObservableCollection<Item>();
private Item _SelectedItem;
@ -155,7 +119,10 @@ namespace AideDeJeu.ViewModels
{
//Spells = new SpellsViewModel(navigator, Items);
//Monsters = new MonstersViewModel(navigator, Items);
LoadItemsCommand = new Command(() => GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommand(GetFilterViewModel(ItemSourceType)));
LoadItemsCommand = new Command(() =>
{
GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommand(GetFilterViewModel(ItemSourceType));
});
GotoItemCommand = new Command<Item>(async (item) => await GetItemsViewModel(ItemSourceType).ExecuteGotoItemCommandAsync(item));
SwitchToSpells = new Command(() => ItemSourceType = (ItemSourceType & ~ ItemSourceType.Monster) | ItemSourceType.Spell);
SwitchToMonsters = new Command(() => ItemSourceType = (ItemSourceType & ~ItemSourceType.Spell) | ItemSourceType.Monster);

View file

@ -15,214 +15,11 @@ namespace AideDeJeu.ViewModels
{
public class MonstersViewModel : ItemsViewModel
{
public List<KeyValuePair<string, string>> Categories { get; set; } = new List<KeyValuePair<string, string>>()
ItemSourceType ItemSourceType;
public MonstersViewModel(ItemSourceType itemSourceType)
{
new KeyValuePair<string, string>("", "Toutes" ),
new KeyValuePair<string, string>("M", "Monstres" ),
new KeyValuePair<string, string>("A", "Animaux" ),
new KeyValuePair<string, string>("P", "PNJ" ),
};
public List<KeyValuePair<string, string>> Types { get; set; } = new List<KeyValuePair<string, string>>()
{
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>> Powers { get; set; } = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>(" 0 (0 PX)", "0" ),
new KeyValuePair<string, string>(" 1/8 (25 PX)", "1/8" ),
new KeyValuePair<string, string>(" 1/4 (50 PX)", "1/4" ),
new KeyValuePair<string, string>(" 1/2 (100 PX)", "1/2" ),
new KeyValuePair<string, string>(" 1 (200 PX)", "1" ),
new KeyValuePair<string, string>(" 2 (450 PX)", "2" ),
new KeyValuePair<string, string>(" 3 (700 PX)", "3" ),
new KeyValuePair<string, string>(" 4 (1100 PX)", "4" ),
new KeyValuePair<string, string>(" 5 (1800 PX)", "5" ),
new KeyValuePair<string, string>(" 6 (2300 PX)", "6" ),
new KeyValuePair<string, string>(" 7 (2900 PX)", "7" ),
new KeyValuePair<string, string>(" 8 (3900 PX)", "8" ),
new KeyValuePair<string, string>(" 9 (5000 PX)", "9" ),
new KeyValuePair<string, string>(" 10 (5900 PX)", "10" ),
new KeyValuePair<string, string>(" 11 (7200 PX)", "11" ),
new KeyValuePair<string, string>(" 12 (8400 PX)", "12" ),
new KeyValuePair<string, string>(" 13 (10000 PX)", "13" ),
new KeyValuePair<string, string>(" 14 (11500 PX)", "14" ),
new KeyValuePair<string, string>(" 15 (13000 PX)", "15" ),
new KeyValuePair<string, string>(" 16 (15000 PX)", "16" ),
new KeyValuePair<string, string>(" 17 (18000 PX)", "17" ),
new KeyValuePair<string, string>(" 18 (20000 PX)", "18" ),
new KeyValuePair<string, string>(" 19 (22000 PX)", "19" ),
new KeyValuePair<string, string>(" 20 (25000 PX)", "20" ),
new KeyValuePair<string, string>(" 21 (33000 PX)", "21" ),
new KeyValuePair<string, string>(" 22 (41000 PX)", "22" ),
new KeyValuePair<string, string>(" 23 (50000 PX)", "23" ),
new KeyValuePair<string, string>(" 24 (62000 PX)", "24" ),
new KeyValuePair<string, string>(" 30 (155000 PX)", "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>>()
{
new KeyValuePair<string, string>("", "Toutes"),
new KeyValuePair<string, string>("(SRD)", "SRD"),
new KeyValuePair<string, string>("Monster Manual", "MM"),
new KeyValuePair<string, string>("sup", "VGtM, MToF"),
new KeyValuePair<string, string>("supno", "AL, AideDD"),
};
private int _Category = 0;
public int Category
{
get
{
return _Category;
}
set
{
if (_Category != value)
{
SetProperty(ref _Category, value);
LoadItemsCommand.Execute(null);
}
}
this.ItemSourceType = itemSourceType;
}
private int _Type = 0;
public int Type
{
get
{
return _Type;
}
set
{
if (_Type != value)
{
SetProperty(ref _Type, value);
LoadItemsCommand.Execute(null);
}
}
}
private int _MinPower = 0;
public int MinPower
{
get
{
return _MinPower;
}
set
{
if (_MinPower != value)
{
SetProperty(ref _MinPower, value);
if (_MaxPower < _MinPower)
{
SetProperty(ref _MaxPower, value, nameof(MaxPower));
}
LoadItemsCommand.Execute(null);
}
}
}
private int _MaxPower = 28;
public int MaxPower
{
get
{
return _MaxPower;
}
set
{
if (_MaxPower != value)
{
SetProperty(ref _MaxPower, value);
if (_MaxPower < _MinPower)
{
SetProperty(ref _MinPower, value, nameof(MinPower));
}
LoadItemsCommand.Execute(null);
}
}
}
private int _Size = 0;
public int Size
{
get
{
return _Size;
}
set
{
if (_Size != value)
{
SetProperty(ref _Size, value);
LoadItemsCommand.Execute(null);
}
}
}
private int _Legendary = 0;
public int Legendary
{
get
{
return _Legendary;
}
set
{
if (_Legendary != value)
{
SetProperty(ref _Legendary, value);
LoadItemsCommand.Execute(null);
}
}
}
private int _Source = 1;
public int Source
{
get
{
return _Source;
}
set
{
if (_Source != value)
{
SetProperty(ref _Source, value);
LoadItemsCommand.Execute(null);
}
}
}
private IEnumerable<Monster> _AllMonsters = null;
@ -232,18 +29,26 @@ namespace AideDeJeu.ViewModels
{
if (_AllMonsters == null)
{
var serializer = new DataContractJsonSerializer(typeof(IEnumerable<Monster>));
var assembly = typeof(AboutViewModel).GetTypeInfo().Assembly;
//var names = assembly.GetManifestResourceNames();
using (var stream = assembly.GetManifestResourceStream("AideDeJeu.Data.monsters_vf.json"))
string resourceName = null;
switch (ItemSourceType)
{
_AllMonsters = serializer.ReadObject(stream) as IEnumerable<Monster>;
case ItemSourceType.MonsterVF:
resourceName = "AideDeJeu.Data.monsters_vf.json";
break;
case ItemSourceType.MonsterVO:
resourceName = "AideDeJeu.Data.monsters_vo.json";
break;
case ItemSourceType.MonsterHD:
resourceName = "AideDeJeu.Data.monsters_hd.json";
break;
}
_AllMonsters = Tools.Helpers.GetResourceObject<IEnumerable<Monster>>(resourceName);
}
return _AllMonsters;
}
}
public IEnumerable<Monster> GetMonsters(string category, string type, string minPower, string maxPower, string size, string legendary, string source)
{
var powerComparer = new PowerComparer();
@ -268,18 +73,14 @@ namespace AideDeJeu.ViewModels
try
{
AllItems.Clear();
//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);
Main.Items.Clear();
//var filter = filterViewModel as MonsterFilterViewModel;
//var items = GetMonsters(category: filter.Categories[filter.Category].Key, type: filter.Types[filter.Type].Key, minPower: filter.Powers[filter.MinPower].Key, maxPower: filter.Powers[filter.MaxPower].Key, size: filter.Sizes[filter.Size].Key, legendary: filter.Legendaries[filter.Legendary].Key, source: filter.Sources[filter.Source].Key);
var items = filterViewModel.FilterItems(AllMonsters);
//ItemDatabaseHelper helper = new ItemDatabaseHelper();
//var items = await helper.GetMonstersAsync(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);
var items = 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);
//var aitems = items.ToArray();
//Array.Sort(aitems, new ItemComparer());
foreach (var item in items)
{
AllItems.Add(item);
Main.Items.Add(item);
}
//FilterItems();
}
@ -295,7 +96,7 @@ namespace AideDeJeu.ViewModels
public override async Task ExecuteGotoItemCommandAsync(Item item)
{
await Navigator.GotoMonsterDetailPageAsync(item as Monster);
await Main.Navigator.GotoMonsterDetailPageAsync(item as Monster);
}
}