using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace GameAtlas.Models
{
    [DataContract]
    public class Jeu
    {
        [DataMember]
        public string Nom { get; private set; }
        [DataMember]
        public string Resume { get; private set; }
        [DataMember]
        public string Sortie { get; private set; }
        [DataMember]
        public string Plateformes { get; private set; }
        [DataMember]
        public string Developpeur { get; private set; }
        [DataMember]
        public string Editeur { get; private set; }
        [DataMember]
        public double Note { get; private set; }
        [DataMember]
        public int NbTelechargement { get; private set; }
        //[DataMember]
        //public List<(string,string)> Revendeurs { get; private set; }
        [DataMember]
        public string Genres { get; private set; }
        [DataMember]
        public string Image { get; private set; }
        [DataMember]
        public ObservableCollection<(string,double,string)> ListeAvis { get; private set; }
        [DataMember]
        public int NbFavoris { get; private set; }
        [DataMember]
        public int NbPossedes { get; private set; }

        public Jeu(string nom, string resume, string sortie, string plateformes, string developpeur, string editeur, double note, int nbTelechargement, string genres, string image)
        {
            Nom = nom;
            Resume = resume;
            Sortie = sortie;
            Plateformes = plateformes;
            Developpeur = developpeur;
            Editeur = editeur;
            Note = note;
            NbTelechargement = nbTelechargement;
            //Revendeurs = revendeurs;
            Genres = genres;
            Image = image;
            ListeAvis = new ObservableCollection<(string, double, string)>();
            NbFavoris = 0;
            NbPossedes = 0;
        }

        public void AjouterAvis(string pseudo, double note, string commentaire)
        {
            this.ListeAvis.Add((pseudo, note, commentaire));
        }

        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
                return false;

            Jeu otherJeu = (Jeu)obj;
            return Nom == otherJeu.Nom && Sortie == otherJeu.Sortie;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(Nom, Sortie);
        }
    }
}
