using System;
using Cysharp.Threading.Tasks;

namespace Com.Project.B.Lobby
{
    /// <summary>
    /// 大厅服务
    /// </summary>
    public interface ILobbyServices
    {
        /// <summary>
        /// 获取玩家所在的大厅
        /// </summary>
        /// <param name="playerId"></param>
        /// <returns></returns>
        UniTask<ILobbyData> GetPlayerLobbyAsync(Guid playerId); 
        /// <summary>
        /// 获取所有大厅
        /// </summary>
        /// <returns></returns>
        UniTask<ILobbyData[]> GetAllLobbyDataAsync();
        /// <summary>
        /// 创建大厅
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        UniTask<ILobbyData> CreateLobbyAsync(ILobbyData data);
        /// <summary>
        /// 加入大厅
        /// </summary>
        /// <param name="playerId"></param>
        /// <param name="lobbyId"></param>
        /// <returns></returns>
        UniTask<ILobbyData> JoinLobbyAsync(Guid playerId,Guid lobbyId);
        /// <summary>
        /// 离开大厅
        /// </summary>
        /// <param name="playerId"></param>
        /// <param name="lobbyId"></param>
        /// <returns></returns>
        UniTask<ILobbyData> LeaveLobbyAsync(Guid playerId,Guid lobbyId);
        /// <summary>
        /// 更新大厅信息
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        UniTask<ILobbyData> UpdateLobbyAsync(ILobbyData data);
        /// <summary>
        /// 正式释放大厅,通常是游戏开始后
        /// </summary>
        /// <param name="lobbyId"></param>
        /// <returns></returns>
        UniTask<ILobbyData> ReleaseLobbyAsync(Guid lobbyId);
        /// <summary>
        /// 释放大厅,通常是主机离线或加入其他人的大厅
        /// </summary>
        /// <param name="lobbyId"></param>
        /// <returns></returns>
        UniTask<ILobbyData> DisposeLobbyAsync(Guid lobbyId);
        /// <summary>
        /// 邀请玩家加入大厅
        /// </summary>
        /// <returns></returns>
        UniTask InviteToLobbyAsync(Guid inviterId,Guid inviteeId,Guid lobbyId);
        /// <summary>
        /// 是否接受邀请
        /// </summary>
        /// <param name="playerId"></param>
        /// <param name="lobbyId"></param>
        /// <param name="accept"></param>
        /// <returns></returns>
        UniTask AccessLobbyInviteAsync(Guid playerId,Guid lobbyId,bool accept);
        /// <summary>
        /// 当大厅创建时
        /// </summary>
        event Action<ILobbyData> OnLobbyCreated;
        /// <summary>
        /// 当大厅更新时
        /// </summary>
        event Action<ILobbyData> OnLobbyUpdated;
        /// <summary>
        /// 当大厅正式释放时
        /// </summary>
        event Action<ILobbyData> OnLobbyReleased;
        /// <summary>
        /// 当大厅释放时
        /// </summary>
        event Action<ILobbyData> OnLobbyDisposed;
        /// <summary>
        /// 当邀请加入大厅时
        /// </summary>
        event Action<Guid,ILobbyData> OnInviteToLobby;
        /// <summary>
        /// 当拒绝或接受邀请时
        /// </summary>
        event Action<Guid,ILobbyData> OnAccessLobbyInvite;
    }
}