public void AddPlayer(PlayerAccount account, string alias) { int position = 1; while (position <= MaxPlayers && !IsPositionOpen(position)) { position++; } AddPlayer(account, alias, position); }
public BlackjackGamePlayer(PlayerAccount account, BlackjackGame game, string alias, int position) { if (account == null) { throw new ArgumentNullException("account", "Account is null"); } if (game == null) { throw new ArgumentNullException("game", "Game is null"); } Game = game; Alias = string.IsNullOrEmpty(alias) ? "ANON" : alias; Account = account; Position = position; Id = Account.Id; }
public void AddPlayer(PlayerAccount account, string alias, int position) { if (account == null) { throw new ArgumentNullException("account", "Account is null"); } if (Players.Count() >= MaxPlayers) { throw new InvalidOperationException("Game is full"); } if (!IsPositionOpen(position)) { throw new InvalidOperationException("Position is not valid"); } if (account.Balance < MinWager) { throw new InvalidOperationException("Insufficient player funds"); } Players.Add(new BlackjackGamePlayer(account, this, alias, position)); }