Beispiel #1
0
        /// <summary>
        /// 出牌的处理
        /// </summary>
        private void deal(ClientPeer client, DealDto dto)
        {
            SingleExecute.Instance.Execute(
                delegate()
            {
                if (userCache.IsOnline(client) == false)
                {
                    return;
                }
                //必须确保在线

                int userId = userCache.GetId(client);

                if (userId != dto.UserId)
                {
                    return;
                }
                FightRoom room = fightCache.GetRoomByUId(userId);
                //玩家出牌
                //玩家已经中途退出 掉线
                if (room.LeaveUIdList.Contains(userId))
                {
                    //直接转换出牌
                    turn(room);
                }
                //玩家还在
                bool canDeal = room.DealCard(dto.Type, dto.Weight, dto.Length, userId, dto.SelectCardList);
                if (canDeal == false && room.roundModel.BiggestUId != userId)
                {
                    //玩家出的牌管不上上一个玩家出的牌
                    client.Send(OpCode.FIGHT, FightCode.DEAL_SRES, -1);
                    return;
                }
                else
                {
                    //出牌成功
                    //广播 给所有的客户端
                    List <CardDto> remainCardList = room.GetPlayerModel(userId).CardList;
                    dto.RemainCardList            = remainCardList;
                    brocast(room, OpCode.FIGHT, FightCode.DEAL_BRO, dto);
                    //检测一下剩余手牌,如果手牌数为0,那就游戏结束了
                    if (remainCardList.Count == 0)
                    {
                        //游戏结束
                        gameOver(userId, room);
                    }
                    else
                    {
                        //转换出牌
                        turn(room);
                    }
                }
            }
                );
        }
Beispiel #2
0
        /// <summary>
        /// 出牌的处理
        /// </summary>
        private void deal(ClientPeer client, DealDto dto)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (!userCache.IsOnline(client))
                {
                    return;
                }
                int userId = userCache.GetId(client);
                if (userId != dto.UserId)
                {
                    return;
                }
                FightRoom fightRoom = fightCache.GetRoomByUId(userId);

                //玩家如果掉线退出
                if (fightRoom.LeaveUIdList.Contains(userId))
                {
                    //直接跳过
                    Turn(fightRoom);
                }
                bool canDel = fightRoom.DeadCard(dto.Type, dto.Weight, dto.Length, dto.UserId, dto.selectCardList);
                if (canDel == false)
                {
                    //玩家出的牌管不上
                    client.Send(OpCode.FIGHT, FightCode.DEAL_SERS, -1);
                    return;
                }
                else
                {
                    //给自身客户端发送出牌成功的消息
                    client.Send(OpCode.FIGHT, FightCode.DEAL_SERS, 0);
                    Brocast(fightRoom, OpCode.FIGHT, FightCode.END_TIMEING_BRO, userId);
                    //检查一下剩余手牌数
                    List <CardDto> remainCard = fightRoom.GetPlayerModel(userId).CardList;
                    //广播给所有客户端
                    dto.RemainCardList = remainCard;
                    Brocast(fightRoom, OpCode.FIGHT, FightCode.DEAL_BRO, dto);
                    TimeOutManager.Instance.RemoveEvent(userId);
                    if (remainCard.Count == 0)
                    {
                        //游戏结束
                        gameOver(userId, fightRoom);
                    }
                    else
                    {
                        //转换出牌
                        Turn(fightRoom);
                    }
                }
            });
        }
Beispiel #3
0
        private void deal(ClientPeer client, DealDto dto)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (!userCache.IsOnline(client))
                {
                    return;
                }
                int userId = userCache.GetId(client);
                if (userId != dto.UserId)
                {
                    return;
                }
                FightRoom fightRoom = fightCache.GetRoomByUId(userId);

                bool canDeal = fightRoom.DeadCard(dto.Type, dto.Weight, dto.Length, dto.UserId, dto.selectCardList);
                if (canDeal == false)
                {
                    client.Send(OpCode.FIGHT, FightCode.DEAL_SRES, -1);
                    return;
                }
                else
                {
                    //send deal successful message
                    client.Send(OpCode.FIGHT, FightCode.DEAL_SRES, 0);

                    //check reamin hands
                    List <CardDto> remainCard = fightRoom.GetPlayerModel(userId).CardList;

                    dto.RemainCardList = remainCard;
                    Broadcast(fightRoom, OpCode.FIGHT, FightCode.DEAL_BROADCAST, dto);
                    if (remainCard.Count == 0)
                    {
                        Console.WriteLine("Game Over");
                        gameOver(userId, fightRoom);
                    }
                    else
                    {
                        Turn(fightRoom);
                    }
                }
            });
        }