Exemple #1
0
        /// <summary>
        /// 要牌
        /// </summary>
        /// <param name="client"></param>
        public void getCard(ClientPeer client)
        {
            SingleExecute.Instance.Execute(
                delegate()
            {
                if (userCache.IsOnline(client) == false)
                {
                    return;
                }
                //必须确保在线
                int userId = userCache.GetId(client);

                SingleRoom room = singleCache.GetRoomByUId(userId);
                if (room.isPlayer21())
                {
                    client.Send(OpCode._21Single, _21SingleCode.GET_SRES, null);    //已经21点不能要牌,最好客户端设置一下
                    return;
                }
                CardDto dto = room.GetOnePlayerCard();
                client.Send(OpCode._21Single, _21SingleCode.GET_SRES, dto);
                if (room.GetPlayerWeight() > 21)                                           //闲家爆牌 这局结束
                {
                    if (room.player.SplitNum > 1)                                          //是分牌的情况
                    {
                        client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, 2); //闲家爆牌
                        //room.player.winOrLose.Add(-1);
                        //room.player.SpliteCardListList.Add(room.player.CardList);
                        room.SaveList(1, false);
                        if (room.player.SpliteCardListQueue.Count() > 0)
                        {
                            client.Send(OpCode._21Single, _21SingleCode.SPLIT_CAN_NEXT_SRES, null);
                        }
                        else
                        {
                            gameOver(userId, room, 7);
                        }
                    }
                    else
                    {
                        client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null);
                        gameOver(userId, room, 2);
                    }
                }
                else if (room.GetPlayerWeight() != 21)
                {
                    BasicStrategyDto basicStrategyDto = new BasicStrategyDto();
                    basicStrategyDto.dealerCardType   = room.getDealerCardType();
                    basicStrategyDto.playerCardType   = room.getPlayerCardType();
                    basicStrategyDto.realAns          = basicStrategy.trueStrategy(basicStrategyDto.dealerCardType, basicStrategyDto.playerCardType);
                    client.Send(OpCode._21Single, _21SingleCode.BASIC_STRATEGY_SRES, basicStrategyDto);
                }
                else
                {
                    client.Send(OpCode._21Single, _21SingleCode.BASIC_STRATEGY_SRES, null);
                }
            });
        }
Exemple #2
0
        /// <summary>
        /// 加倍
        /// </summary>
        /// <param name="client"></param>
        public void doubleCard(ClientPeer client)
        {
            SingleExecute.Instance.Execute(
                delegate()
            {
                if (userCache.IsOnline(client) == false)
                {
                    return;
                }
                //必须确保在线
                int userId = userCache.GetId(client);

                SingleRoom room = singleCache.GetRoomByUId(userId);

                CardDto dto = room.GetOnePlayerCard();
                client.Send(OpCode._21Single, _21SingleCode.GET_SRES, dto);
                //说明是分牌的
                if (room.player.SplitNum > 1)
                {
                    if (room.GetPlayerWeight() > 21)    //闲家爆牌 这局结束
                    {
                        room.SaveList(2, true);
                        client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, 2);    //闲家爆牌
                        //room.player.SpliteCardListList.Add(room.player.CardList);
                        if (room.player.SpliteCardListQueue.Count() > 0)
                        {
                            //room.player.winOrLose.Add(-2);//加倍的时候爆牌了,所以是-2
                            client.Send(OpCode._21Single, _21SingleCode.SPLIT_CAN_NEXT_SRES, null);
                        }
                        else
                        {
                            gameOver(userId, room, 7);
                        }
                    }
                    else
                    {
                        //room.addWeightAndMulti(2);
                        room.SaveList(3, true);
                        //client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, whichwin);
                        //先不能判断输赢
                        if (room.player.SpliteCardListQueue.Count() > 0)
                        {
                            client.Send(OpCode._21Single, _21SingleCode.SPLIT_PROMST_SRES, 0);    //随便提示一下

                            client.Send(OpCode._21Single, _21SingleCode.SPLIT_CAN_NEXT_SRES, null);
                        }
                        else
                        {
                            gameOver(userId, room, 7);
                        }
                    }
                }
                else
                {
                    //设置倍数
                    room.Multiple = 2;
                    if (room.GetPlayerWeight() > 21)    //闲家爆牌 这局结束
                    {
                        //client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, 2);
                        client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null);
                        gameOver(userId, room, 2);
                    }
                    else
                    {
                        client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null);
                        while (room.GetDealerWeight() < 17)
                        {
                            CardDto dto2 = room.GetOneDealerCard();
                            client.Send(OpCode._21Single, _21SingleCode.ADD_DCARD_SRES, dto2);
                        }

                        int whichwin = room.whichWin();
                        //client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, whichwin);
                        gameOver(userId, room, whichwin);
                    }
                }
            });
        }