Пример #1
0
        /// <summary>
        ///  不同游戏类型结算方法不一样
        /// </summary>
        /// <returns></returns>
        public List <ShowDownSDBFC> GetShowDownList()
        {
            Dictionary <int, ShowDownSDBFC> _tempdicpos2SD = new Dictionary <int, ShowDownSDBFC>();
            int _bankerPos = _myTable._bankpos;

            _myTable.ForeashAllDo((i) =>
            {
                _tempdicpos2SD.Add(i, new ShowDownSDBFC()
                {
                    bulltype  = (int)_myTable._DicPos2User[i]._bulltype,
                    gamble    = _myTable._DicPos2User[i]._gambleTotal,
                    money     = 0,
                    pos       = i,
                    _cardlist = _myTable._DicPos2User[i]._shouPaiArr
                });
            });

            BullColorUser _tempBankerUser = _myTable._DicPos2User[_bankerPos];

            _myTable.ForeashAllDo((i) =>
            {
                if (_myTable._DicPos2User[i]._isBanker)
                {
                    return;
                }

                bool _tempBankerWin = BullFight.ComparePoker(_tempBankerUser._shouPaiArr, _tempBankerUser._bulltype, _myTable._DicPos2User[i]._shouPaiArr, _myTable._DicPos2User[i]._bulltype);
                if (_tempBankerWin)
                {
                    int _tempvar = _myTable._baseMoney * _myTable._DicPos2User[i]._gambleTotal * BullFight._dicbullfightRate[_tempBankerUser._bulltype];
                    _tempdicpos2SD[_bankerPos].money += _tempvar;
                    _tempdicpos2SD[i].money          -= _tempvar;
                }
                else
                {
                    int _tempvar = _myTable._baseMoney * _myTable._DicPos2User[i]._gambleTotal * BullFight._dicbullfightRate[_myTable._DicPos2User[i]._bulltype];
                    _tempdicpos2SD[_bankerPos].money -= _tempvar;
                    _tempdicpos2SD[i].money          += _tempvar;
                }
            });

            //算完后,统一数据持久化
            foreach (int key in _tempdicpos2SD.Keys)
            {
                if (_tempdicpos2SD[key].money > 0)//扣出5%费用 只要是赢了的人
                {
                    _tempdicpos2SD[key].money = (int)(_tempdicpos2SD[key].money * 0.95f);
                }
                _myTable._DicPos2User[key]._CurrentGold += _tempdicpos2SD[key].money;
            }
            return(_tempdicpos2SD.Values.ToList <ShowDownSDBFC>());
        }
Пример #2
0
        /// <summary>
        /// 给机器配置胜率后,机器人拿大牌,有多个机器时,以早大POS的机器人为准
        /// 如果有多个设置胜率帐号在同一桌,则会只有一个机率有效。
        /// </summary>
        /// <param name="pos2RobotAI"></param>
        /// <param name="_pos2Poker"></param>
        /// <returns></returns>
        public Dictionary <int, List <int> > ChangePokerByRobotAI(Dictionary <int, int> pos2RobotAI, Dictionary <int, List <int> > _pos2Poker)
        {
            Dictionary <int, PokerBullFightType> _pbftype = new Dictionary <int, PokerBullFightType>();

            _myTable.ForeashAllDo((i) =>
            {
                _pbftype.Add(i, BullFight.GetBullType(_pos2Poker[i]));
            });
            int _maxpos = _myTable._masterPos;
            PokerBullFightType maxvalue = PokerBullFightType.Bull_No;

            _myTable.ForeashAllDo((i) =>
            {
                if (maxvalue < _pbftype[i])
                {
                    maxvalue = _pbftype[i];
                    _maxpos  = i;
                }
            });
            int _RobotRatePos = _maxpos;

            _myTable.ForeashAllDo((i) =>
            {
                int _AIRate = pos2RobotAI[i];
                if (_AIRate == 0)
                {
                    return;
                }
                int _tempRate = ToolsEx.GetRandomSys(0, 100);
                if (_tempRate <= _AIRate)
                {
                    _RobotRatePos = i;
                }
            });
            List <int> _tempChange = new List <int>();//把最大的牌换给机器人最高胜率的人

            _tempChange = _pos2Poker[_RobotRatePos];
            _pos2Poker[_RobotRatePos] = _pos2Poker[_maxpos];
            _pos2Poker[_maxpos]       = _tempChange;

            return(_pos2Poker);
        }
Пример #3
0
        /// <summary>
        /// 初始化大厅
        /// </summary>
        public void Initi()
        {
            Gameid = 42;
            var roomInfo = new ShareCacheStruct <tb_GameInfo>();

            //DOTO 取了一个房间配置 后面在根据情况在来处理
            //====================begin============================================
            BullFight100Room._instance.Awake();
            tb_gamelevelinfoEx.TryRecoverFromDb();//先从数据库恢复一次
            var roomList = new ShareCacheStruct <tb_gamelevelinfo>().FindAll((g) => { return(g.gameid == Gameid); });

            foreach (var _roomInfo in roomList)
            {
                var roomData = new BullFight100Room(_roomInfo);
                BullFight100Room.roomCache.TryAdd(roomData.mRoomID + "", roomData);
                roomData.CreateTableByRobot();
            }
            //===================end
            BullFight.InitRate();
            _dicUserStatus = new ConcurrentDictionary <int, UserStatus>();
        }
Пример #4
0
        /// <summary>
        /// 至少两人到位了进行 开局 ,开局就会扣掉配置钱===============================================
        /// </summary>
        private void Start( )
        {
            lock (objLock)
            {
                if (_numpertable < _num_min)
                {
                    return;
                }

                base.StartBase(60 * 4);
                _pos2UserID   = new Dictionary <int, int>();
                _pos2IPPort   = new Dictionary <int, string>();
                _pos2Money    = new Dictionary <int, decimal>();
                _pos2Win      = new Dictionary <int, bool>();
                _pos2CardList = new Dictionary <int, List <int> >();
                _pos2BullRate = new Dictionary <int, int>();
                _pos2Watch    = new Dictionary <int, int>();

                Queue <int> _tcardLeft = new Queue <int>();
                Dictionary <int, List <int> > _pokerList = new Dictionary <int, List <int> >();

                _pokerList[0] = BullFight.GetPokerbyBullFightType(PokerBullFightType.Bull_Bull);

                Dictionary <int, int> _pos2RobotAI = new Dictionary <int, int>();
                ForeashAllDo((i) =>
                {
                    _pos2RobotAI.Add(i, _DicPos2User[i]._tbUser.winpercent);
                });
                //  _judge.ChangePokerByRobotAI(_pos2RobotAI, _pokerList);

                List <int> _temppoker0 = new List <int>()
                {
                    0, 0, 0, 0, 0
                };
                List <UserIDMSG>      imList  = new List <UserIDMSG>();
                List <CommonPosValSD> _uplist = new List <CommonPosValSD>();
                ForeashAllDo((i) =>
                {
                    _uplist.Add(new CommonPosValSD()
                    {
                        pos = i, val = _DicPos2User[i]._userid
                    });
                });

                _DicPos2User[0]._isBanker = true;
                //同时把每位玩家的数据确认修改了 //发送消息到所有玩家
                ForeashAllDo((i) =>
                {
                    BullColorUser tempUser = _DicPos2User[i];

                    tempUser._isPlaying  = true;
                    tempUser._shouPaiArr = _pokerList[i];
                    _DicPos2User[i]      = tempUser;//必须要赋值回去 要求有3个返馈才处理

                    _tablRecord.MatchCode = _tableMathCode;
                    _tablRecord._guid     = _guid;
                    _tablRecord.StartTime = DateTime.Now;
                    _pos2UserID.Add(i, tempUser._userid);
                    _pos2IPPort.Add(i, tempUser._IPandPort);
                    //发送通知消息
                    sc_tablestart_bfc_n _start = new sc_tablestart_bfc_n()
                    {
                        result = 1, fn = "sc_tablestart_bfc_n", _msgid = _TurnWaitTime
                    };
                    _start.tableid = _tableid;
                    _start.pos     = i;

                    _start._canGetBanker   = false;
                    _start._pos2userid     = _uplist;//所有玩家及对应 的位置信息
                    _start._curTableCount  = _judge._curTableOverCount;
                    _start._curBankerCount = 1;
                    _start.ShowCardList    = _temppoker0;
                    _start.closefun        = false;//需要报价抢庄,不关闭自动显示功能
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_start), tempUser._isRobot, tempUser._isDisconnet));
                });

                BFColorSendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);

                _DicPos2User[_bankpos].SetTimeOutAction(1, "sc_gambleover_bfc_n", 4 * 60);//1分钟等待时间
                _strStatus = "Start...3  ";
            }
        }
Пример #5
0
        /// <summary>
        ///  不同游戏类型结算方法不一样
        /// </summary>
        /// <returns></returns>
        public ShowDownSD100 GetShowDownList(int _pos)
        {
            int _bankerPos = _myTable._bankpos;
            List <CommonPosValListSD> _pos2CardList = new List <CommonPosValListSD>();

            foreach (var pokerlist in _myTable._dicPokerList)
            {
                _pos2CardList.Add(new CommonPosValListSD()
                {
                    pos = pokerlist.Key, vallist = pokerlist.Value
                });
            }

            ShowDownSD100 _tempdicpos2SD = new ShowDownSD100()
            {
                bulltype      = (int)_myTable._DicPos2User[_pos]._bulltype,
                gamble        = _myTable._DicPos2User[_pos]._gambleTotal,
                money         = 0,
                pos           = _pos,
                _pos2CardList = _pos2CardList
            };

            BullFight100User   _tempBankerUser = _myTable._DicPos2User[_bankerPos];
            List <int>         _bankerCardList = _myTable._dicPokerList[1];
            PokerBullFightType _bankderType    = _myTable._dicPokerBFType[1];

            foreach (int key in _myTable._dicPokerList.Keys)
            {
                if (key == 1)
                {
                    continue;          //固定1号位为庄
                }
                bool _tempBankerWin = BullFight.ComparePoker(_bankerCardList, _bankderType, _myTable._dicPokerList[key], _myTable._dicPokerBFType[key]);
                int  _gambleRate    = 1;
                if (_tempBankerWin)
                {
                    _gambleRate = BullFight._dicbullfightRate[_bankderType];
                }
                else
                {
                    _gambleRate = BullFight._dicbullfightRate[_myTable._dicPokerBFType[key]];
                }

                _myTable.ForeashAllDo((i) =>
                {
                    if (_myTable._masterPos == i)
                    {
                        return;                          //房主不计算
                    }
                    if (_myTable._bankpos == i)
                    {
                        return;                        //庄家不计算
                    }
                    if (_tempBankerWin)
                    {
                        int _tempvar = _myTable._baseMoney * _myTable._DicPos2User[i].GetGambleByPos(key) * _gambleRate;
                        _myTable._DicPos2User[_bankerPos]._CurrentGold += _tempvar;       //扣出5%费用 只要是赢了的人
                        _myTable._DicPos2User[i]._CurrentGold          -= _tempvar;
                    }
                    else
                    {
                        int _tempvar = _myTable._baseMoney * _myTable._DicPos2User[i].GetGambleByPos(key) * _gambleRate;
                        _myTable._DicPos2User[_bankerPos]._CurrentGold -= _tempvar;
                        _myTable._DicPos2User[i]._CurrentGold          += _tempvar;//扣出5%费用 只要是赢了的人
                    }
                });
            }

            return(_tempdicpos2SD);
        }
        /// <summary>
        /// 至少两人到位了进行 开局 ,开局就会扣掉配置钱===============================================
        /// </summary>
        private void Start(int userid)
        {
            lock (objLock)
            {
                BullFight100User myu = GetUserByID(userid);
                if (myu == null)
                {
                    return;
                }
                if (myu.CheckisWatch())
                {
                    return;
                }
                if (!myu.CheckFirstDeal())
                {
                    return;
                }
                //if (HaveSomeBodyUnDeal()) return;
                if (_numpertable < _num_min)
                {
                    return;
                }

                base.StartBase(60 * 4);
                _pos2UserID   = new Dictionary <int, int>();
                _pos2IPPort   = new Dictionary <int, string>();
                _pos2Money    = new Dictionary <int, decimal>();
                _pos2Win      = new Dictionary <int, bool>();
                _pos2CardList = new Dictionary <int, List <int> >();
                _pos2BullRate = new Dictionary <int, int>();
                _pos2Watch    = new Dictionary <int, int>();

                Queue <int> _tcardLeft = new Queue <int>();
                var         type       = _judge._gametype;
                _dicPokerList        = new Dictionary <int, List <int> >();
                _dicPokerBFType      = new Dictionary <int, PokerBullFightType>();
                _dicPokerGambleTotal = new Dictionary <int, int>();
                _pos2GambleTable     = new Dictionary <int, int>();

                _allGambleTotal = 0;
                _dicPokerList   = BullFight.DistributePoker(out _tcardLeft, 4);
                foreach (int key in _dicPokerList.Keys)
                {
                    _dicPokerBFType.Add(key, BullFight.GetBullType(_dicPokerList[key]));
                    _dicPokerGambleTotal.Add(key, 0);
                }

                ////Dictionary<int, int> _pos2RobotAI = new Dictionary<int, int>();
                ////ForeashAllDo((i) =>
                ////{
                ////    _pos2RobotAI.Add(i, _DicPos2User[i]._tbUser.winpercent); //_pos2RobotAI.Add(i, i == 1 ? 101 : 0);
                ////});
                ////_judge.ChangePokerByRobotAI(_pos2RobotAI, _dicPokerList);

                List <int> _temppoker0 = new List <int>()
                {
                    0, 0, 0, 0, 0
                };
                List <UserIDMSG>      imList  = new List <UserIDMSG>();
                List <CommonPosValSD> _uplist = new List <CommonPosValSD>();

                _judge.DealReduceDiamond();//执行扣房卡 已处理只扣一次
                _judge.SetCurTableorBankerCount();

                //同时把每位玩家的数据确认修改了 //发送消息到所有玩家
                ForeashAllDo((i) =>
                {
                    BullFight100User tempUser = _DicPos2User[i];

                    tempUser._isPlaying = true;
                    //tempUser._shouPaiArr = _pokerList[i];
                    tempUser._pos2Gameble  = new Dictionary <int, int>();
                    tempUser._showCardList = new List <int>()
                    {
                        0, 0, 0, 0, 0
                    };
                    _DicPos2User[i] = tempUser;//必须要赋值回去 要求有3个返馈才处理

                    _tablRecord.MatchCode = _tableMathCode;
                    _tablRecord._guid     = _guid;
                    _tablRecord.StartTime = DateTime.Now;
                    _pos2UserID.Add(i, tempUser._userid);
                    _pos2IPPort.Add(i, tempUser._IPandPort);
                    //发送通知消息
                    sc_tablestart_bf100_n _start = new sc_tablestart_bf100_n()
                    {
                        result = 1, fn = "sc_tablestart_bf100_n", _msgid = _TurnWaitTime
                    };
                    _start.tableid = _tableid;
                    _start.pos     = i;

                    _start._canGetBanker   = false;
                    _start._pos2userid     = _uplist;//所有玩家及对应 的位置信息
                    _start._curTableCount  = _judge._curTableOverCount;
                    _start._curBankerCount = 1;
                    _start.ShowCardList    = _temppoker0;
                    _start.closefun        = true;//需要抢庄,不关闭自动显示功能
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_start), tempUser._isRobot, tempUser._isDisconnet));
                });

                BF100SendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);
                _strStatus = "Start...3  ";

                DoExecuteSetBanker();
            }
        }