Beispiel #1
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 #2
0
        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);
                    //send message to all client who was landlord
                    GrabDto dto = new GrabDto(userId, fightRoom.TableCardList, fightRoom.getUserCards(userId));
                    Broadcast(fightRoom, OpCode.FIGHT, FightCode.GRAB_LANDLORD_BROADCAST, dto);

                    //enter deal phase
                    Broadcast(fightRoom, OpCode.FIGHT, FightCode.TURN_DEAL_BROADCAST, userId);
                }
                else
                {
                    //don't grab
                    int nextUserId = fightRoom.GetNextUserId(userId);
                    Broadcast(fightRoom, OpCode.FIGHT, FightCode.TURN_GRAB_BROADCAST, nextUserId);
                }
            });
        }
Beispiel #3
0
        private DealDto BiggestTimeOutDeal(int userId)
        {
            FightRoom fightRoom = fightCache.GetRoomByUId(userId);
            //检查一下剩余手牌数
            List <CardDto> selectCard = fightRoom.getUserFirstCard(userId);

            fightRoom.RemoveCards(userId, selectCard);
            //广播给所有客户端
            DealDto dealDto = new DealDto(selectCard, userId);

            dealDto.RemainCardList = fightRoom.getUserCards(userId);
            return(dealDto);
        }
Beispiel #4
0
        /// <summary>
        /// 开始战斗
        /// </summary>
        public void startFight(List <int> uidList)
        {
            SingleExecute.Instance.Execute(() =>
            {
                //创建战斗房间
                FightRoom room = fightCache.Create(uidList);
                room.InitPlayerCards();
                room.Sort();
                //发送给每个客户端 他自身有什么牌
                foreach (int uid in uidList)
                {
                    ClientPeer client       = userCache.GetClientPeer(uid);
                    List <CardDto> cardList = room.getUserCards(uid);
                    client.Send(OpCode.FIGHT, FightCode.GET_CARD_SRES, cardList);
                }

                //开始抢地主
                int firstUserId = room.GetFirstUId();
                Brocast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BRO, firstUserId, null);
            });
        }
Beispiel #5
0
        /// <summary>
        /// start play cards
        /// </summary>
        /// <param name="userIdList"></param>
        public void startFight(List <int> userIdList)
        {
            SingleExecute.Instance.Execute(() =>
            {
                //create fight room
                FightRoom room = fightCache.Create(userIdList);
                room.InitPlayerCards();
                room.Sort();
                //send all client ,what cards he have;
                foreach (int uid in userIdList)
                {
                    ClientPeer client       = userCache.GetClientPeer(uid);
                    List <CardDto> cardList = room.getUserCards(uid);
                    client.Send(OpCode.FIGHT, FightCode.GET_CARD_SRES, cardList);
                }

                //start grab landlord
                int firstUserId = room.GetFirstUserId();
                //tell all client firstUserId user to grab landlord
                Broadcast(room, OpCode.FIGHT, FightCode.TURN_GRAB_BROADCAST, firstUserId, null);
            });
        }