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.
Ohara_MAUI/Sources/Model/Classes/Personnage.cs

169 lines
4.8 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
{
prime = value;
OnPropertyChanged();
}
}
[DataMember(Name = "epithete")]
private string? epithete;
public string? Epithete {
get=>epithete;
set
{
epithete = value;
}
}
[DataMember(Name = "age")]
private int age;
public int Age {
get=>age;
set
{
age = value;
OnPropertyChanged();
}
}
[DataMember(Name = "taille")]
private double taille;
public double Taille {
get=>taille;
set
{
taille = value;
OnPropertyChanged();
}
}
[DataMember(Name = "origine")]
private string? origine;
public string? Origine {
get=>origine;
set
{
origine = value;
OnPropertyChanged();
}
}
[DataMember(Name = "biographie")]
private string? biographie;
public string? Biographie {
get=>biographie;
set
{
biographie = value;
OnPropertyChanged();
}
}
[DataMember(Name = "citation")]
private string? citation;
public string? Citation {
get=>citation;
set
{
citation = value;
OnPropertyChanged();
}
}
[DataMember(Name = "equipage", EmitDefaultValue = false)]
private Equipage? equipage;
public Equipage? Equipage {
get => equipage;
set
{
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;
}
}
}