/// <summary>
        /// 抢地主的处理
        /// </summary>
        private void grabLandlord(ClientPeer client, bool result)
        {
            SingleExecute.Instance.Execute(
                delegate()
            {
                if (userCache.IsOnline(client) == false)
                {
                    return;
                }
                //必须确保在线
                int userId = userCache.GetId(client);
                //if()
                FightRoom room = fightCache.GetRoomByUId(userId);

                if (result == true)
                {
                    //抢
                    room.SetLandlord(userId);
                    //给每一个客户端发一个消息  谁当了地主
                    //   第一个:地主id  第二个:三张底牌
                    GrabDto dto = new GrabDto(userId, room.TableCardList, room.GetUserCards(userId));
                    brocast(room, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BRO, dto);
                    //发送一个出牌命令
                    brocast(room, OpCode.FIGHT, FightCode.TURN_DEAL_BRO, userId);
                }
                else
                {
                    //不抢
                    int nextUId = room.GetNextUId(userId);
                    brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, nextUId);
                }
            });
        }
Beispiel #2
0
        /// <summary>
        /// 抢地主
        /// </summary>
        /// <param name="client"></param>
        /// <param name="result"></param>
        private void grabLandlord(ClientPeer client, bool result)
        {
            SingleExecute.Instance.Execute(() =>
            {
                if (!userCache.IsOnline(client))
                {
                    return;
                }
                int userId          = userCache.GetId(client);
                FightRoom fightRoom = fightCache.GetRoomByUId(userId);

                if (result == true)
                {
                    //抢
                    fightRoom.SetLandlord(userId);
                    //给每个客户端发送消息谁当了地主
                    GrabDto dto = new GrabDto(userId, fightRoom.TableCardList, fightRoom.getUserCards(userId));
                    Brocast(fightRoom, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BRQ, dto);

                    Brocast(fightRoom, OpCode.FIGHT, FightCode.TURN_DEAL_BRO, userId);
                }
                else
                {
                    //不抢
                    int nextUId = fightRoom.GetNextUId(userId);
                    Brocast(fightRoom, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, nextUId);
                }
            });
        }
Beispiel #3
0
 /// <summary>
 /// 抢地主的处理
 /// </summary>
 private void grabLandlord(ClientPeer client, bool result)
 {
     SingleExecute.Instance.Execute(
         delegate()
     {
         if (userCache.IsOnline(client) == false)
         {
             return;
         }
         //必须确保在线
         int userId     = userCache.GetId(client);
         FightRoom room = fightCache.GetRoomByUId(userId);
         if (result == true)
         {
             room.isMulti = true;
             //抢
             room.SetLandlord(userId);
             //给每一个客户发一个消息 谁当了地主
             GrabDto dto = new GrabDto(userId, room.TableCardList, room.GetUserCards(userId));
             brocast(room, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BRO, dto);
             foreach (var player in room.PlayerList)
             {
                 if (player.Identity == Identity.FARMER)
                 {
                     //发送给平民翻倍命令
                     singleBrocast(room, OpCode.FIGHT, FightCode.MULTIPLE_BRO, 1, player.UserId);
                 }
                 else
                 {
                     singleBrocast(room, OpCode.FIGHT, FightCode.MULTIPLE_BRO, 2, player.UserId);
                 }
             }
         }
         else
         {
             //不抢
             int nextUId = room.GetNextUId(userId);
             brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, nextUId);
         }
     }
         );
 }