Exemple #1
0
 /// <summary>
 /// 分牌后要下一组牌
 /// </summary>
 /// <param name="client"></param>
 private void splitNext(ClientPeer client)
 {
     SingleExecute.Instance.Execute(
         () =>
     {
         if (userCache.IsOnline(client) == false)
         {
             return;
         }
         int userId = userCache.GetId(client);
         if (fightCache.IsInRoom(userId) == false)
         {
             return;
         }
         //一定要注意安全的验证
         _21MutiFightRoom room = fightCache.GetRoom(userId);
         //发下一组牌
         room.NextHandCardByUId(userId);
         //获取分牌后的下一组手牌
         List <CardDto> cardList = room.GetUserCardsByUserId(userId);
         //广播发送一下手牌
         SplitBroDto sbdto = new SplitBroDto();
         sbdto.userId      = userId;
         sbdto.position    = room.getPosition(userId);
         sbdto.cardList    = cardList;
         //分牌和 下一手用的一个code
         brocast(room, OpCode._21Multi, _21MultiCode.SPLIT_BRO, sbdto, null);
         //和开始游戏后进行一样的判断
         //21点 直接赢了
         if (room.is21ByUserId(userId))
         {
             //记录一下这组牌
             room.SaveListByUserId(userId, 1, false);
             int position      = room.getPosition(userId);
             OverHandDto ohdto = new OverHandDto(userId, position, 1);
             brocast(room, OpCode._21Multi, _21MultiCode.OVER_HAND_BRO, ohdto, null);
             //该下一个玩家了
             turnPlayer(userId, position, room);
         }
         //能够分牌
         if (room.isCanSplitByUserId(userId))
         {
             TurnHandDto thdto = new TurnHandDto(true, userId);
             client.Send(OpCode._21Multi, _21MultiCode.TURN_HS_BRO, thdto);
             //brocast(room, OpCode._21Multi, _21MultiCode.TURN_HS_BRO, thdto, null);
         }
         else
         {
             TurnHandDto thdto = new TurnHandDto(false, userId);
             client.Send(OpCode._21Multi, _21MultiCode.TURN_HS_BRO, thdto);
             //brocast(room, OpCode._21Multi, _21MultiCode.TURN_HS_BRO, thdto, null);
         }
     }
         );
 }