|
@@ -0,0 +1,90 @@
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+
|
|
|
+namespace ET.Server
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 出牌
|
|
|
+ /// </summary>
|
|
|
+ [MessageHandler(SceneType.Game)]
|
|
|
+ public class C2G_DisCardHandler : AMRpcHandler<C2G_DisCard, G2C_DisCard>
|
|
|
+ {
|
|
|
+ protected override async ETTask Run(Session session, C2G_DisCard request, G2C_DisCard response, Action reply)
|
|
|
+ {
|
|
|
+ Player player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
|
|
|
+ if (player == null)
|
|
|
+ {
|
|
|
+ response.Error = ErrorCode.ERR_OperationError;
|
|
|
+ response.Message = "玩家不存在或离线...";
|
|
|
+ reply();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 玩家是否进入房间
|
|
|
+ if (player.RoomId <= 0)
|
|
|
+ {
|
|
|
+ response.Error = ErrorCode.ERR_OperationError;
|
|
|
+ response.Message = "玩家不在房间,不可操作...";
|
|
|
+ reply();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Scene scene = session.DomainScene();
|
|
|
+
|
|
|
+ // 房间是否能找到
|
|
|
+ Room room = scene.GetComponent<GameRoomComponent>().Get(player.RoomId);
|
|
|
+ if (room == null)
|
|
|
+ {
|
|
|
+ response.Error = ErrorCode.ERR_OperationError;
|
|
|
+ response.Message = "请求的房间不存在或已解散...";
|
|
|
+ reply();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // todo 玩家房间是否已开始, 后面这个判断要调整
|
|
|
+ // 房间状态
|
|
|
+ HGHuangHuangComponent hgHuangHuangComponent = room.GetComponent<HGHuangHuangComponent>();
|
|
|
+ if (hgHuangHuangComponent != null && hgHuangHuangComponent.State != 2)
|
|
|
+ {
|
|
|
+ response.Error = ErrorCode.ERR_OperationError;
|
|
|
+ response.Message = "房间不在游戏中,不可出牌...";
|
|
|
+ reply();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 玩家状态
|
|
|
+ if (player.State != 2)
|
|
|
+ {
|
|
|
+ response.Error = ErrorCode.ERR_OperationError;
|
|
|
+ response.Message = "玩家不在游戏中,不可出牌...";
|
|
|
+ reply();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (request.Card <= 0 || !HGHuangHuangConst.Values.Contains(request.Card))
|
|
|
+ {
|
|
|
+ response.Error = ErrorCode.ERR_OperationError;
|
|
|
+ response.Message = "出牌错误...";
|
|
|
+ reply();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断玩家是否可出牌
|
|
|
+ if (hgHuangHuangComponent.CurrentPlayer.Id != player.Id)
|
|
|
+ {
|
|
|
+ response.Error = ErrorCode.ERR_OperationError;
|
|
|
+ response.Message = "不是当前操作玩家,出牌错误...";
|
|
|
+ reply();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 出牌
|
|
|
+ hgHuangHuangComponent.DisCard(room, player, request.Card, false);
|
|
|
+
|
|
|
+ // 返回
|
|
|
+ reply();
|
|
|
+ await ETTask.CompletedTask;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|