ToModel(this BlackJackGame game, string playerId)
        {
            _ = game ?? throw new ArgumentNullException(nameof(game));
            var dto = new BlackJackGameModel
            {
                Status          = game.Status,
                CurrentPlayerId = game.CurrentPlayer.Identifier,
                Id      = game.Id,
                Players = new List <BlackJackPlayerModel>()
            };

            foreach (var player in game.Players)
            {
                BlackJackPlayerModel playerDto;
                if (game.Status != Enums.GameStatus.Complete)
                {
                    var isCurrentPlayer = player.Identifier.Equals(playerId) ||
                                          player.Status == PlayerStatusTypes.Complete;
                    playerDto = MapPlayer(player, isCurrentPlayer);
                }
                else
                {
                    playerDto = MapPlayer(player, true);
                }
                dto.Players.Add(playerDto);
            }
            return(dto);
        }
Пример #2
0
        private BlackJackGameModel ToModel(BlackJackGame game)
        {
            var result = new BlackJackGameModel();

            result.Id     = game.Id;
            result.Dealer = ToModel(game.Dealer);
            result.Player = ToModel(game.Player);
            result.Winner = game.GetWinnerName();
            return(result);
        }
Пример #3
0
        private BlackJackGameModel ToModel(BlackJackGame game)
        {
            var result = new BlackJackGameModel
            {
                Id     = game.Id,
                Dealer = ToModel(game.Dealer),
                Player = ToModel(game.Player),
                Winner = game.GetWinnerName()
            };

            return(result);
        }
        private void StartGame()
        {
            NumberOfPlayersClass arg = NumberOfPlayersCollection.First <NumberOfPlayersClass>(t => t.IsChecked == true);

            if (arg == null)
            {
                // BIG problem.  Log and find out why
                throw new Exception("Could not resolve number of players in StartGame");
            }
            _game = new BlackJackGameModel(Convert.ToUInt16(arg.Player));
            _game.StartGame();
            OnPropertyChanged("DealerInfo");
            OnPropertyChanged("PlayersInfo");
            OnPropertyChanged("CanShowDealerScore");
        }