Exemplo n.º 1
0
        public SeatInfo SitIn(PlayerInfo p, int preferedSeat = -1)
        {
            if (!Seats.RemainingSeatIds().Any())
            {
                Logger.LogError("Not enough seats to join!");
                return(null);
            }

            //if (!Params.IsValidBuyIn(p.MoneyAmnt))
            //{
            //    Logger.LogError("Player Money ({0}) is not between Minimum ({1}) and Maximum ({2})", p.MoneyAmnt, Params.Lobby.MinimumBuyInAmount(Params.GameSize), Params.Lobby.MaximumBuyInAmount(Params.GameSize));
            //    return null;
            //}

            if (Seats.Players().ContainsPlayerWithSameName(p))
            {
                Logger.LogError("Already someone seated with the same name! Is this you ?");
                return(null);
            }

            var seat = preferedSeat;

            if (preferedSeat < 0 || preferedSeat >= Seats.Length || !Seats[preferedSeat].IsEmpty)
            {
                seat = Seats.RemainingSeatIds().First();
            }

            HadPlayers = true;

            p.ChangeState(PlayerStateEnum.SitIn);
            p.NoSeat           = seat;
            Seats[seat].Player = p;
            return(Seats[seat]);
        }