using System.Collections.ObjectModel;
using System.Data;
using System.Numerics;
using Models.Game;

namespace Stub
{
    public class Stub
    {
        public ReadOnlyObservableCollection<Player> ListPlayer { get; private set; }
        private readonly ObservableCollection<Player> listplayer = new ObservableCollection<Player>();
        public ReadOnlyObservableCollection<Map> ListMap { get; private set; }
        private readonly ObservableCollection<Map> listmap = new ObservableCollection<Map>();

        public Game ThePartie { get; private set; }

        public Stub()
        {
            ListPlayer = new ReadOnlyObservableCollection<Player>(listplayer);
            ListMap = new ReadOnlyObservableCollection<Map>(listmap);
            ThePartie = new Game();
            LoadPlayer();
            LoadMap();
        }

        public void LoadPlayer()
        {

            listplayer.Add(new Player());
            listplayer.Add(new Player("Lucas", "profile.jpg"));
            listplayer.Add(new Player("relavergne", "profile.jpg"));
            listplayer.Add(new Player("reneveu", "profile.jpg"));
        }
        
        public void LoadMap()
        {

            listmap.Add(new Map("profile.jpg"));
            listmap.Add(new Map("montagne1.png"));
            listmap.Add(new Map("tmp1.jpeg"));
        }

        public void Add(string pseudo, string profilePicture)
        {
            listplayer.Add(new Player(pseudo, profilePicture));
        }
        
        public void Pop(string pseudo, string profilePicture)
        {
            listplayer.Remove(new Player(pseudo, profilePicture));
        }

        public bool Modify(string pseudo, string newpseudo)
        {
            foreach (var index in listplayer)
            {
                if (index.Pseudo == pseudo)
                {
                    index.Pseudo = newpseudo;
                    return true;
                }
            }

            return false;
        }
    }
}
