using System.Threading.Tasks;
using ActorCore;
using NetWorkMessage;

namespace Server
{
    public class GameBaseMainActor: MainActor
    {
        public GameBaseMainActor(byte moduleId, byte nodeNum) : base(moduleId, nodeNum)
        {
            RegisterRPCHandle(typeof(GameClubKickOutPlayerRPCRequest), OnGameClubKickOutPlayerRPCRequest);   
            RegisterRPCHandle(typeof(GameClubDismissDeskRPCRequest), OnGameClubDismissDeskRPCRequest);   
        }

        private Task OnGameClubKickOutPlayerRPCRequest(ActorId fromActorId, IRequest request, IResponse response)
        {
            if (request is GameClubKickOutPlayerRPCRequest rpcReq && response is GameClubKickOutPlayerRPCResponse rpcResp)
            {
                rpcResp.Error = FriendRoomManager.instance.DoClubOutPlayer(rpcReq.Weiyima, rpcReq.UserId);
            }
            return Task.CompletedTask;
        }
        
        private Task OnGameClubDismissDeskRPCRequest(ActorId fromActorId, IRequest request, IResponse response)
        {
            if (request is GameClubDismissDeskRPCRequest rpcReq && response is GameClubDismissDeskRPCResponse rpcResp)
            {
                rpcResp.Error = FriendRoomManager.instance.ClubDisBankCmd(rpcReq.Weiyima);
            }
            return Task.CompletedTask;
        }
    }
}