Ejemplo n.º 1
0
    /// <summary>
    /// 游戏结束
    /// </summary>
    /// <param name="value"></param>
    private void overGame(SingleOverDto overDto)
    {
        //switch (overDto.whichwin)
        //{
        //    case 1:
        //        promptMsg.Change("21点,闲家获胜", Color.red);
        //        break;
        //    case 2:
        //        promptMsg.Change("闲家爆牌,庄家获胜", Color.red);
        //        break;
        //    case 3:
        //        promptMsg.Change("庄家爆牌,闲家获胜", Color.red);
        //        break;
        //    case 4:
        //        promptMsg.Change("庄家获胜", Color.red);
        //        break;
        //    case 5:
        //        promptMsg.Change("闲家获胜", Color.red);
        //        break;
        //    case 6:
        //        promptMsg.Change("平局", Color.red);
        //        break;
        //    case 7:
        //        promptMsg.Change("....分牌了我该说啥....", Color.red);
        //        break;
        //    default:
        //        break;
        //}
        //Dispatch(AreaCode.UI, UIEvent.PROMPT_MSG, promptMsg);
        //todo牌面清空 做一些豆子处理

        Dispatch(AreaCode.UI, UIEvent.SINGLE_SHOW_OVER_PANEL, overDto);
        Models.GameModel.UserDto = overDto.userDto;
        //更新豆子
        Dispatch(AreaCode.UI, UIEvent.SINGLE_CHANGE_BEEN, Models.GameModel.UserDto.Been);
        //倍数还原
        //Dispatch(AreaCode.UI, UIEvent.CHANGE_MUTIPLE, 1);
        //显示下一把按钮
        Dispatch(AreaCode.UI, UIEvent.SINGLE_SHOW_GET_BUTTON, false);
        Dispatch(AreaCode.UI, UIEvent.SINGLE_SHOW_START_BUTTON, false);
        Dispatch(AreaCode.UI, UIEvent.SINGLE_SHOW_NEXT_BUTTON, true);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 刷新显示
    /// </summary>
    private void refreshPanel(SingleOverDto singleOverDto)
    {
        //显示面板
        setPanelActive(true);

        txtDealerSettle.text  = "庄家 :点数 ";
        txtDealerSettle.text += singleOverDto.dealerWeight;
        txtDealerSettle.text += "  ";
        if (singleOverDto.dealerState == 1)
        {
            txtDealerSettle.text += "21点";
        }
        else if (singleOverDto.dealerState == 2)
        {
            txtDealerSettle.text += "爆牌";
        }

        txtPlayerSettle.text = "";
        for (int j = 0; j < singleOverDto.playerWeightList.Count; j++)
        {
            txtPlayerSettle.text += "点数 ";
            //1 21点,2 爆牌,3 加倍爆牌 ,4 加倍 赢 ,5 加倍 输,6赢 ,7 输,8 平
            switch (singleOverDto.playerStateList[j])
            {
            case 0:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += " 黑杰克(平)  + ";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }


            case 1:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += " 黑杰克(赢)  + ";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }

            case 2:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += "爆牌  ";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }

            case 3:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += "加倍爆牌  ";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }

            case 4:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += "加倍 赢  + ";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }

            case 5:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += "加倍 输  ";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }

            case 6:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += "赢  +";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }

            case 7:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += "输  ";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }

            case 8:
            {
                txtPlayerSettle.text += singleOverDto.playerWeightList[j];
                txtPlayerSettle.text += "平  + ";
                txtPlayerSettle.text += singleOverDto.playerWinBeenList[j];
                break;
            }
            }

            txtPlayerSettle.text += "\n";
        }
    }
Ejemplo n.º 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);
        }