Пример #1
0
        public void OnGamePlaying()
        {
            _gameLog.GameStart(Guid.NewGuid().ToString(), Blind, RoomId, RoomType);
            Clean();
            //定庄
            EnsurDealer();

            //发牌
            CardDealer.DealCard(GetPlayerCount(), out var allUserCards, out _bottomCards);

            //从庄家开始发牌,下注
            int          index       = _dealerSeatIndex;
            List <int>   dealerOrder = new List <int>();
            List <long>  carrys      = new List <long>();
            GameStartAct act         = new GameStartAct();

            do
            {
                dealerOrder.Add(index);
                _seats[index].DealCard(allUserCards.Last(), Blind);
                _coinsPool.PlayerBetCoins(_seats[index].SeatNum, Blind);
                var player = _seats[index].InGamePlayerInfo;
                carrys.Add(player.Carry);
                act.AddPlayer(new GameStartAct.PlayerInfo(player.Id, player.Carry,
                                                          index, allUserCards.Last()));
                allUserCards.RemoveAt(allUserCards.Count - 1);
            } while ((index = NextSeatedNum(index)) != _dealerSeatIndex);
            _gameLog.AddGameAction(act);
            _coinsPool.BlindPool(dealerOrder.Count, Blind);

            foreach (var player in _playerInfos)
            {
                DealCardsEvent dealCard = new DealCardsEvent(_dealerSeatIndex, dealerOrder,
                                                             CardDealer.UserCardsCount,
                                                             player.Value.SeatInfo?.HandCards, Blind, carrys);
                BroadCastMessage(dealCard, "DealCardsEvent", player.Value);
            }


            //等待发牌结束
            _statusInfo.WaitForNexStatus(OnDealingCards, GameStatus.playing, GameTimerConfig.DealCard);
        }