public void HandleRequestAsync(RequestModel requestModel, IOutputBoundary <ResponseModel> outputBoundary) { _ = requestModel?.PlayerId ?? throw new ArgumentNullException(nameof(requestModel.PlayerId)); var avitar = AvitarRepository.ReadAsync(requestModel.PlayerId); var currentPlayer = new BlackJackPlayer(avitar, HandIdProvider, requestModel.HandCount); var keyAndGame = GameRepository.FindByStatusFirstOrDefault(GameStatus.Waiting, requestModel.MaxPlayers); string gameIdentifier; BlackJackGame game; if (string.IsNullOrEmpty(keyAndGame.Key)) { gameIdentifier = GameIdProviders.GenerateGameId(); game = new BlackJackGame(CardProvider, DealerProvider.Dealer, requestModel.MaxPlayers); } else { gameIdentifier = keyAndGame.Key; game = keyAndGame.Value; } game.AddPlayer(currentPlayer); GameRepository.UpdateAsync(gameIdentifier, game); outputBoundary.HandleResponse(new ResponseModel() { GameIdentifier = gameIdentifier }); }
public void HandleRequest(RequestModel requestModel, IOutputBoundary <ResponseModel> outputBoundary) { var game = gameRepository.GetGame(requestModel.GameIdentifier); game.HandleLetter(requestModel.Letter); gameRepository.SaveGame(requestModel.GameIdentifier, game); outputBoundary.HandleResponse(new ResponseModel() { Phrase = game.Phrase.Current, CurrentPlayerName = game.CurrentPlayer.Name }); }
public void HandleRequest(RequestModel requestModel, IOutputBoundary <ResponseModel> outputBoundary) { var completePhrase = phraseRepository.GetPhrase(); var game = new Game(requestModel.PlayerNames, completePhrase); var gameIdentifier = gameRepository.CreateNewGame(game); outputBoundary.HandleResponse(new ResponseModel() { GameIdentifier = gameIdentifier, Phrase = game.Phrase.Current, CurrentPlayerName = game.CurrentPlayer.Name }); }
public void HandleRequestAsync(RequestModel requestModel, IOutputBoundary <ResponseModel> outputBoundary) { var game = GameRepository.ReadAsync(requestModel.GameIdentifier); game.PlayerHits(requestModel.PlayerIdentifier, requestModel.HandIdentifier); GameRepository.UpdateAsync(requestModel.GameIdentifier, game); var gameDto = MapperBlackJackGameDto.Map(game, requestModel.PlayerIdentifier); outputBoundary.HandleResponse(new ResponseModel() { Game = gameDto }); }
public void HandleRequest(RequestModel requestModel, IOutputBoundary <ResponseModel> outputBoundary) { var game = gameRepository.GetGame(requestModel.GameIdentifier); game.HandleGuess(requestModel.Guess); gameRepository.SaveGame(requestModel.GameIdentifier, game); var reward = game.IsOver ? game.CurrentPlayer.Money : 0; outputBoundary.HandleResponse(new ResponseModel() { Phrase = game.Phrase.Current, CurrentPlayerName = game.CurrentPlayer.Name, Reward = reward }); }
public void HandleRequestAsync(RequestModel requestModel, IOutputBoundary <ResponseModel> outputBoundary) { _ = requestModel.PlayerName ?? throw new ArgumentNullException(nameof(requestModel.PlayerName)); var identifier = IdentifierProvider.GenerateAvitar(); var player = new AvitarDto() { id = identifier, userName = requestModel.PlayerName }; AvitarRepository.CreateAsync(player); outputBoundary.HandleResponse(new ResponseModel() { AvitarIdentifier = identifier }); }
public void HandleRequest(RequestModel requestModel, IOutputBoundary <ResponseModel> outputBoundary) { var game = gameRepository.GetGame(requestModel.GameIdentifier); var circle = circleRepository.GetCircle(); var space = circle.GetSpace(randomProvider.GetRandom(0, circle.CountSpaces())); game.HandleSpace(space); gameRepository.SaveGame(requestModel.GameIdentifier, game); var resultDescription = game.RequestLetter ? game.LetterDollarAmount.Value.ToString() : space.Type.ToString(); outputBoundary.HandleResponse(new ResponseModel() { ResultDescription = resultDescription, RequestLetter = game.RequestLetter, CurrentPlayerName = game.CurrentPlayer.Name }); }