using OrderCriterias;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManagerInterfaces
{

    /// <summary>
    /// All methods to handle players
    /// /!\ all methods returns a task
    /// </summary>
    /// <typeparam name="T">a DTO, Entity or Model player</typeparam>
    public interface IPlayerManager<T>
    {
        /// <summary>
        /// get the number of T element
        /// </summary>
        /// <returns>the number of T element</returns>
        public int getNbElements();
        /// <summary>
        /// add a player
        /// </summary>
        /// <param name="player">the player to add</param>
        /// <returns>
        /// the T element that corresponde to
        /// the player added or the player equal to this
        /// player if this player was already added
        /// </returns>
        public Task<T> addPlayer(T player);
        /// <summary>
        /// remove a player
        /// </summary>
        /// <param name="player">the player to remove</param>
        /// <returns>
        /// the player removed or null if
        /// the player does not exist
        /// </returns>
        public Task<T?> removePlayer(T player);
        /// <summary>
        /// remove a player
        /// </summary>
        /// <param name="id">the identifier of the player to remove</param>
        /// <returns>
        /// the player removed or null if
        /// the player does not exist
        /// </returns>
        Task<T?> removePlayer(uint id);
        /// <summary>
        /// get a part of all players
        /// </summary>
        /// <param name="nb">the actual page</param>
        /// <param name="count">number of T element in a page</param>
        /// <param name="orderCriteria">the order criteria</param>
        /// <returns>
        /// a set of the number of page and
        /// all T element in the database for
        /// the page nb (or null if the page
        /// does not exist (<=> (nb-1)*count outside
        /// boundaries (0, getNbElement()-1)))
        /// </returns>
        public Task<(int nbPages, IEnumerable<T>? players)> getPlayers(int nb, int count, PlayerOrderCriteria orderCriteria = PlayerOrderCriteria.ById);
        /// <summary>
        /// get a player
        /// </summary>
        /// <param name="id">identifier of the player</param>
        /// <returns>
        /// the player with this id
        /// or null if no player match
        /// with this id
        /// </returns>
        public Task<T?> getPlayer(uint id);
        /// <summary>
        /// get a player
        /// </summary>
        /// <param name="nickname">nickname of the player</param>
        /// <returns>
        /// the player with this nickname
        /// or null if no player match
        /// with this nickname
        /// </returns>
        public Task<T?> getPlayer(string nickname);
        /// <summary>
        /// get players in a lobby
        /// </summary>
        /// <param name="idLobby">the id of the lobby they are inside</param>
        /// <returns>
        /// a set of all players in this lobby
        /// (we know that the lobby is at less
        /// used by the creator) or null (and
        /// delete the lobby) if it is used by
        /// no player
        /// </returns>
        public Task<IEnumerable<T>?> getPlayersInALobby(uint idLobby);
        /// <summary>
        /// get the max score of a player in a chapter
        /// </summary>
        /// <param name="id">identifier of the player</param>
        /// <param name="idChapter">identifier of the chapter</param>
        /// <returns>
        /// the max score of the player
        /// or null if the player or
        /// the chapter does not exist
        /// </returns>
        public Task<uint?> getMaxScorePlayer(uint id, uint idChapter);
        /// <summary>
        /// get the global max score of a player
        /// </summary>
        /// <param name="id">identifier of the player</param>
        /// <returns>
        /// the max score of the player
        /// or null if the player does not exist
        /// </returns>
        public Task<uint?> getMaxScorePlayer(uint id);
    }
}
