You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
145 lines
4.3 KiB
145 lines
4.3 KiB
using Microsoft.VisualBasic;
|
|
using Model.Stub;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Model
|
|
|
|
{
|
|
public class Manager
|
|
{
|
|
public IDataManager DataManager { get; set; }
|
|
|
|
public ObservableCollection<Bateau> Bateaux { get; private set; }
|
|
|
|
public Manager() {
|
|
Bateaux = new ObservableCollection<Bateau>();
|
|
DataManager = new StubManager();
|
|
}
|
|
|
|
public List<Personnage> GetPersonnages()
|
|
{
|
|
return DataManager.GetPersonnages().ToList();
|
|
}
|
|
public List<FruitDuDemon> GetFruits()
|
|
{
|
|
return DataManager.GetFruits().ToList();
|
|
}
|
|
public List<Equipage> GetEquipages()
|
|
{
|
|
return DataManager.GetEquipages().ToList();
|
|
}
|
|
public List<Bateau> GetBateaux()
|
|
{
|
|
return DataManager.GetBateaux().ToList();
|
|
}
|
|
public List<Bestiaire> GetBestiaires()
|
|
{
|
|
return DataManager.GetBestiaires().ToList();
|
|
}
|
|
public List<Ile> GetIles()
|
|
{
|
|
return DataManager.GetIles().ToList();
|
|
}
|
|
|
|
public List<FruitDuDemon> FiltrerFDD(string type)
|
|
{
|
|
List<FruitDuDemon> fdd = GetFruits();
|
|
foreach(FruitDuDemon f in fdd.ToList())
|
|
{
|
|
if(f.Type != type)
|
|
{
|
|
fdd.Remove(f);
|
|
}
|
|
}
|
|
return fdd;
|
|
}
|
|
|
|
public List<FruitDuDemon> RechercheFDD(string text,List<FruitDuDemon> listeFDD)
|
|
{
|
|
if (text == "") {
|
|
return listeFDD;
|
|
}
|
|
foreach(FruitDuDemon f in listeFDD.ToList())
|
|
{
|
|
bool correspondance = false;
|
|
int textPos = 0;
|
|
for (int i = 0; i < (f.Nom.Length); i++) {
|
|
if (string.Equals(text[textPos].ToString(), f.Nom[i].ToString(), StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
textPos++;
|
|
}
|
|
if(textPos == text.Length)
|
|
{
|
|
correspondance = true;
|
|
break;
|
|
}
|
|
|
|
}
|
|
if (!correspondance)
|
|
{
|
|
listeFDD.Remove(f);
|
|
}
|
|
}
|
|
return listeFDD;
|
|
}
|
|
public List<ObjetOhara> RechercheObjetOhara(string text, List<ObjetOhara> liste)
|
|
{
|
|
if (text == "")
|
|
{
|
|
return liste;
|
|
}
|
|
foreach (ObjetOhara f in liste.ToList())
|
|
{
|
|
bool correspondance = false;
|
|
int textPos = 0;
|
|
for (int i = 0; i < (f.Nom.Length); i++)
|
|
{
|
|
if (string.Equals(text[textPos].ToString(), f.Nom[i].ToString(), StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
textPos++;
|
|
}
|
|
if (textPos == text.Length)
|
|
{
|
|
correspondance = true;
|
|
break;
|
|
}
|
|
|
|
}
|
|
if (!correspondance)
|
|
{
|
|
liste.Remove(f);
|
|
}
|
|
}
|
|
return liste;
|
|
}
|
|
public List<ObjetOhara> GetFavoris()
|
|
{
|
|
List<ObjetOhara> listeFavoris = new List<ObjetOhara>();
|
|
listeFavoris.AddRange(GetBateaux());
|
|
listeFavoris.AddRange(GetIles());
|
|
listeFavoris.AddRange(GetEquipages());
|
|
listeFavoris.AddRange(GetFruits());
|
|
listeFavoris.AddRange(GetBestiaires());
|
|
listeFavoris.AddRange(GetPersonnages());
|
|
foreach(ObjetOhara obj in listeFavoris.ToList())
|
|
{
|
|
if (obj.EstFavori == true)
|
|
{
|
|
listeFavoris.Remove(obj);
|
|
}
|
|
}
|
|
return listeFavoris;
|
|
}
|
|
|
|
public void AddBateauFavoris(Bateau bateau)
|
|
{
|
|
bateau.EstFavori = true;
|
|
}
|
|
}
|
|
}
|