using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.@event;

namespace TheGameExtreme.model
{
    public class Player
    {

        public string Pseudo { get; set; }
        private List<Card> cardList = new List<Card>();
        public event EventHandler<HandCardChangedEventArgs> HandCardChanged;


        public Player(string pseudo)
        {
            Pseudo = pseudo;
        }

        public void pioche(Card card)
        {
            cardList.Add(card);
            int position = cardList.IndexOf(card);
            OnCardDrawable(new HandCardChangedEventArgs(card, position));
        }

        public void joue(Card card)
        {
            int position = cardList.IndexOf(card);
            cardList.Remove(card);
            OnCardDrawable(new HandCardChangedEventArgs(null, position));
        }

        //public IReadOnlyList<Card> getCardList()
        //{
        //     return cardList.AsReadOnly();
        //}

        public List<Card> getCardList()
        {
            return cardList;
        }

        protected internal void OnCardDrawable(HandCardChangedEventArgs args)
        {
            HandCardChanged?.Invoke(this, args);
        }

    }
}
