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

                SingleRoom room = singleCache.GetRoomByUId(userId);

                //client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, whichwin);
                //说明是分牌的
                if (room.player.SplitNum > 1)
                {
                    //room.addWeightAndMulti(1);
                    room.SaveList(3, false);
                    //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
                {
                    client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null);
                    while (room.GetDealerWeight() < 17)
                    {
                        CardDto dto = room.GetOneDealerCard();
                        client.Send(OpCode._21Single, _21SingleCode.ADD_DCARD_SRES, dto);
                    }

                    int whichwin = room.whichWin();
                    gameOver(userId, room, whichwin);
                }
            });
        }
예제 #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);
                    }
                }
            });
        }
예제 #3
0
        public void gameOver(int userId, SingleRoom room, int whichwin)
        {
            UserModel     um     = userCache.GetModelById(userId);
            ClientPeer    client = userCache.GetClientPeer(userId);
            int           wager  = room.Wager;
            SingleOverDto odto   = new SingleOverDto();



            switch (whichwin)
            {
            case 1:
            {
                int dealerWeight = room.GetDealerWeight();
                odto.dealerWeight = dealerWeight;
                //21点,和庄家比 获胜或平局
                if (dealerWeight != 21)        //获胜
                {
                    um.Been         += (int)(1.5 * wager);
                    um.Exp          += 150;
                    odto.dealerState = 3;
                    odto.playerStateList.Add(1);
                    odto.playerWeightList.Add(room.GetPlayerWeight());
                    odto.playerWinBeenList.Add((int)(1.5 * wager));
                }
                else
                {
                    um.Exp          += 75;
                    odto.dealerState = 1;
                    odto.playerStateList.Add(0);
                    odto.playerWeightList.Add(room.GetPlayerWeight());
                    odto.playerWinBeenList.Add((int)(0));
                }
                break;
            }



            case 2:    //闲家爆牌
            case 4:    //庄家获胜
            {
                int dealerWeight = room.GetDealerWeight();
                odto.dealerWeight = dealerWeight;
                odto.dealerState  = 3;
                um.Been          -= wager * room.Multiple;
                um.Exp           += 50;
                odto.playerWeightList.Add(room.GetPlayerWeight());
                odto.playerWinBeenList.Add(-(wager * room.Multiple));

                if (room.Multiple == 2)
                {
                    if (room.GetPlayerWeight() > 21)     //加倍爆牌
                    {
                        odto.playerStateList.Add(3);
                    }
                    else
                    {
                        odto.playerStateList.Add(5);        //加倍输
                    }
                }
                else
                {
                    if (room.GetPlayerWeight() > 21)        //加倍爆牌
                    {
                        odto.playerStateList.Add(2);
                    }
                    else
                    {
                        odto.playerStateList.Add(7);        //加倍输
                    }
                }

                break;
            }

            case 3:    //庄家爆牌,闲家获胜
            case 5:
            {
                int dealerWeight = room.GetDealerWeight();
                odto.dealerWeight = dealerWeight;
                if (room.GetDealerWeight() > 21)     //爆牌
                {
                    odto.dealerState = 2;
                }
                else
                {
                    odto.dealerState = 3;
                }


                um.Been += wager * room.Multiple;
                odto.playerWinBeenList.Add(wager * room.Multiple);
                odto.playerWeightList.Add(room.GetPlayerWeight());
                if (room.Multiple == 2)      //加倍赢
                {
                    odto.playerStateList.Add(4);
                }
                else
                {
                    odto.playerStateList.Add(6);        //赢
                }
                um.Exp += 100;
                break;
            }

            case 6:
            {
                int dealerWeight = room.GetDealerWeight();
                odto.dealerWeight = dealerWeight;
                odto.dealerState  = 3;
                odto.playerWinBeenList.Add(0);
                odto.playerWeightList.Add(room.GetPlayerWeight());
                odto.playerStateList.Add(8);        //平
                um.Exp += 75;
                break;
            }

            case 7:
            {
                //看看是不是全爆牌了
                bool isallboom = room.isAllBoom();

                //这个是让客户端翻面
                client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null);
                if (!isallboom)
                {
                    while (room.GetDealerWeight() < 17)
                    {
                        CardDto carddto = room.GetOneDealerCard();
                        client.Send(OpCode._21Single, _21SingleCode.ADD_DCARD_SRES, carddto);
                    }
                }
                int dealerWeight = room.GetDealerWeight();
                odto.dealerWeight = dealerWeight;

                if (room.DealerCardList.Count == 2 && room.GetDealerWeight() == 21)        //庄家是21点
                {
                    odto.dealerState = 1;
                }
                else if (room.GetDealerWeight() > 21)
                {
                    odto.dealerState = 2;
                }
                else
                {
                    odto.dealerState = 3;
                }

                for (int j = 0; j < room.player.SpliteCardListList.Count; j++)
                {
                    int multi = 1;

                    PlayerCardDto tempPlayerCardDto = room.player.SpliteCardListList[j];
                    int           tempWeight        = tempPlayerCardDto.Weight;
                    odto.playerWeightList.Add(tempWeight);

                    int  tempState    = tempPlayerCardDto.CardState;
                    bool tempIsDouble = tempPlayerCardDto.isDouble;
                    if (tempIsDouble)
                    {
                        multi = 2;
                    }


                    //21点
                    if (tempState == 1)
                    {
                        if (dealerWeight == 1)     //平局
                        {
                            odto.playerWinBeenList.Add(0);
                            odto.playerStateList.Add(0);
                            um.Exp += 75;
                        }
                        else
                        {
                            um.Been += (int)(wager * 1.5);
                            odto.playerWinBeenList.Add((int)(wager * 1.5));
                            odto.playerStateList.Add(1);

                            um.Exp += 150;
                        }
                    }
                    //闲家爆牌
                    else if (tempState == 2)
                    {
                        um.Been -= wager * multi;
                        odto.playerWinBeenList.Add(-wager * multi);
                        if (multi == 1)
                        {
                            odto.playerStateList.Add(2);
                        }
                        else
                        {
                            odto.playerStateList.Add(3);
                        }
                        um.Exp += 50;
                    }
                    //不要 权值小于
                    else if (tempState == 3)
                    {
                        //庄家爆牌
                        if (dealerWeight > 21)
                        {
                            um.Been += wager * multi;
                            odto.playerWinBeenList.Add(wager * multi);
                            if (multi == 1)
                            {
                                odto.playerStateList.Add(6);
                            }
                            else
                            {
                                odto.playerStateList.Add(4);
                            }

                            um.Exp += 100;
                        }
                        //闲家点大
                        else if (dealerWeight < tempWeight)
                        {
                            um.Been += wager * multi;
                            odto.playerWinBeenList.Add(wager * multi);
                            if (multi == 1)
                            {
                                odto.playerStateList.Add(6);
                            }
                            else
                            {
                                odto.playerStateList.Add(4);
                            }
                            um.Exp += 100;
                        }
                        //庄家点大
                        else if (dealerWeight > tempWeight)
                        {
                            um.Been -= wager * multi;
                            odto.playerWinBeenList.Add(-wager * multi);
                            if (multi == 1)
                            {
                                odto.playerStateList.Add(7);
                            }
                            else
                            {
                                odto.playerStateList.Add(5);
                            }
                            um.Exp += 50;
                        }
                        //平局
                        else
                        {
                            odto.playerWinBeenList.Add(0);
                            odto.playerStateList.Add(8);

                            um.Exp += 75;
                        }
                    }
                }

                //double sum = room.computeWinOrLoss();
                //um.Been += (int)(sum * wager);


                //um.Exp += 50 * room.player.SplitNum;
                //清理工作
                room.player.SplitNum = 1;
                room.splitClear();

                break;
            }


            default:
                break;
            }
            int maxExp = um.Lv * 100;

            while (maxExp <= um.Exp)
            {
                um.Lv++;
                um.Exp -= maxExp;
                maxExp  = um.Lv * 100;
            }
            userCache.Update(um);
            UserDto dto = new UserDto(um.Id, um.Name, um.Been, um.WinCount, um.LoseCount, um.RunCount, um.Lv, um.Exp);

            //SingleOverDto odto = new SingleOverDto(dto, whichwin);
            odto.userDto = dto;
            client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, odto);
            room.player.CardList.Clear();
            room.DealerCardList.Clear();
            Thread.Sleep(100);
            CountStrategyDto countStrategyDto = room.libraryModel.GetCountStrategyDto();

            client.Send(OpCode._21Single, _21SingleCode.COUNT_STRATEGY_SRES, countStrategyDto);
        }