Exemplo n.º 1
0
        public void OnPlayerOpt()
        {
            GameSeat seat = _seats[ActiveSeatNum];

            //超时, 默认过牌,否则弃牌,然后激活下一个玩家
            if (seat.BetedCoins < _maxAdd)
            {
                PlayerDrop(seat.PlayerInfo);
            }
            else
            {
                PlayerPass(seat.PlayerInfo);
            }
        }
Exemplo n.º 2
0
        public long FollowCoins(GameSeat seat)
        {
            long followChips = 0;

            if (seat.BetedCoins < _maxAdd)
            {
                if (seat.PlayerInfo.Carry >= _maxAdd)
                {
                    followChips = _maxAdd;
                }
                else
                {
                    followChips = seat.PlayerInfo.Carry;
                }
            }
            return(followChips);
        }
Exemplo n.º 3
0
        public async Task <BodyResponse <JoinGameRoomMqResponse> > JoinRoom(long id)
        {
            var accountInfo = _mqManager.GetAccountInfo(id);
            var moneyInfo   = _mqManager.BuyIn(id, MinCarry, MaxCarry);
            await Task.WhenAll(accountInfo, moneyInfo);

            if (moneyInfo.Result == null)
            {
                return(new BodyResponse <JoinGameRoomMqResponse>(StatusCodeDefines.Error, new List <string>()
                {
                    "make player error "
                }, null));
            }
            _playerInfos.TryGetValue(id, out var player);
            //已经在房间直接返回成功
            if (player != null)
            {
                if (accountInfo.Result == null)
                {
                    player.UpdateInfo(id, "", "", 0, "", moneyInfo.Result.CurCoins,
                                      moneyInfo.Result.CurDiamonds, moneyInfo.Result.Carry);
                }
                else
                {
                    player.UpdateInfo(id, accountInfo.Result.PlatformAccount, accountInfo.Result.UserName,
                                      accountInfo.Result.Sex, accountInfo.Result.HeadUrl, moneyInfo.Result.CurCoins,
                                      moneyInfo.Result.CurDiamonds, moneyInfo.Result.Carry);
                }
            }
            else
            {
                player = MakePlayer(id, accountInfo.Result, moneyInfo.Result);
            }

            if (player == null)
            {
                return(new BodyResponse <JoinGameRoomMqResponse>(StatusCodeDefines.Error, new List <string>()
                {
                    "make player error "
                }, null));
            }

            if (!player.IsSeated())
            {
                GameSeat seat = GetEmptySeat();

                if (seat == null)
                {
                    _playerInfos.Remove(id);
                    return(new BodyResponse <JoinGameRoomMqResponse>(StatusCodeDefines.Error, new List <string>()
                    {
                        "room is full "
                    },
                                                                     new JoinGameRoomMqResponse(id, RoomId, GameRoomManager.gameKey, SeatCount, Blind)));
                }
                player.Seat(seat);
                BroadCastMessage(new PlayerSeatedEvent(player.Id, player.UserName,
                                                       player.Coins, player.Diamonds, player.SeatInfo.SeatNum, player.Carry),
                                 "PlayerSeatedEvent");
                //判断房间人数>2 人, 而且是正在准备状态, 开始牌局, 否者旁观
                if (IsGameCanStart())
                {
                    _statusInfo.WaitForNexStatus(OnGameReady, GameStatus.ready, GameTimerConfig.ReadyWait);
                }
            }

            return(new BodyResponse <JoinGameRoomMqResponse>(StatusCodeDefines.Success, null,
                                                             new JoinGameRoomMqResponse(id, RoomId, GameRoomManager.gameKey, GetPlayerCount(), Blind)));
        }
Exemplo n.º 4
0
 public void Seat(GameSeat seatInfo)
 {
     SeatInfo = seatInfo;
     SeatInfo.PlayerSeat(this);
 }