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.
201 lines
5.6 KiB
201 lines
5.6 KiB
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.Serialization;
|
|
|
|
namespace Model.Classes
|
|
{
|
|
[DataContract(Name = "personnage")]
|
|
|
|
public class Personnage : ObjetOhara
|
|
{
|
|
[DataMember(Name = "prime")]
|
|
private double prime;
|
|
public double Prime {
|
|
get=>prime;
|
|
set
|
|
{
|
|
if (prime == value)
|
|
{
|
|
return;
|
|
}
|
|
prime = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
[DataMember(Name = "epithete")]
|
|
private string? epithete;
|
|
public string? Epithete {
|
|
get=>epithete;
|
|
set
|
|
{
|
|
if (epithete == value)
|
|
{
|
|
return;
|
|
}
|
|
epithete = value;
|
|
}
|
|
}
|
|
[DataMember(Name = "age")]
|
|
private int age;
|
|
public int Age {
|
|
get=>age;
|
|
set
|
|
{
|
|
if (age == value)
|
|
{
|
|
return;
|
|
}
|
|
age = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
[DataMember(Name = "taille")]
|
|
private double taille;
|
|
public double Taille {
|
|
get=>taille;
|
|
set
|
|
{
|
|
if (taille == value)
|
|
{
|
|
return;
|
|
}
|
|
taille = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
[DataMember(Name = "origine")]
|
|
private string? origine;
|
|
public string? Origine {
|
|
get=>origine;
|
|
set
|
|
{
|
|
if (origine == value)
|
|
{
|
|
return;
|
|
}
|
|
origine = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
[DataMember(Name = "biographie")]
|
|
private string? biographie;
|
|
public string? Biographie {
|
|
get=>biographie;
|
|
set
|
|
{
|
|
if (biographie == value)
|
|
{
|
|
return;
|
|
}
|
|
biographie = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
[DataMember(Name = "citation")]
|
|
private string? citation;
|
|
public string? Citation {
|
|
get=>citation;
|
|
set
|
|
{
|
|
if (citation == value)
|
|
{
|
|
return;
|
|
}
|
|
citation = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
[DataMember(Name = "equipage", EmitDefaultValue = false)]
|
|
private Equipage? equipage;
|
|
public Equipage? Equipage {
|
|
get => equipage;
|
|
set
|
|
{
|
|
if (equipage == value)
|
|
{
|
|
return;
|
|
}
|
|
equipage = value;
|
|
OnPropertyChanged();
|
|
}
|
|
}
|
|
[DataMember(Name = "fruit", EmitDefaultValue = false)]
|
|
private ObservableCollection<FruitDuDemon> fruit = new ObservableCollection<FruitDuDemon>();
|
|
public IReadOnlyCollection<FruitDuDemon> Fruit {
|
|
get=>fruit;
|
|
}
|
|
public void AjouterFruit(FruitDuDemon? f)
|
|
{
|
|
if (f == null) return;
|
|
fruit.Add(f);
|
|
}
|
|
public void RetierFruit(FruitDuDemon? f)
|
|
{
|
|
if (f == null) return;
|
|
fruit.Remove(f);
|
|
}
|
|
public void ViderFruit() => fruit.Clear();
|
|
|
|
|
|
|
|
public Personnage(string nom, double prime, string epithete, int age, double taille, string origine, string biographie, string citation) : base(nom)
|
|
{
|
|
if (prime < 0)
|
|
{
|
|
Prime = 0;
|
|
}
|
|
else
|
|
{
|
|
Prime = prime;
|
|
}
|
|
Epithete = epithete;
|
|
Age = age;
|
|
if (taille < 0)
|
|
{
|
|
Taille = 0;
|
|
}
|
|
else
|
|
{
|
|
Taille = taille;
|
|
}
|
|
|
|
Origine = origine;
|
|
Biographie = biographie;
|
|
Citation = citation;
|
|
|
|
|
|
}
|
|
|
|
public Personnage(string nom, double prime, string epithete, int age, double taille, string origine, string biographie, string citation, string image) : this(nom, prime, epithete, age, taille, origine, biographie, citation)
|
|
{
|
|
if (String.IsNullOrWhiteSpace(image))
|
|
image = "baseimage.png";
|
|
Image = image;
|
|
}
|
|
public override bool Equals(object? obj)
|
|
{
|
|
if (obj == null) return false;
|
|
if (this.GetType() != obj.GetType())
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
Personnage o = (Personnage)obj;
|
|
return o.Nom == Nom;
|
|
}
|
|
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(Prime, Epithete, Age, Origine,Biographie, Citation,Equipage,Fruit);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return "Personnage :" + Nom + " " + EstFavori + " " + Prime + " " + Epithete + " " + Age + " " + Origine + " " + Biographie + " "+ Citation+" " +Equipage+" " + Fruit+" "+ Image;
|
|
}
|
|
}
|
|
} |