public async Task <ApplyTurnResponse> AutoPlayTurn(ApplyTurnRequest request) { var response = ServiceMessageFactory <ApplyTurnResponse> .CreateFrom(request); var autoPlayRequest = ServiceMessageFactory <PlayTurnRequest> .CreateFrom(request); autoPlayRequest.IsAutoPlay = true; autoPlayRequest.Address = request.Address; autoPlayRequest.GameSessionId = request.GameSessionId; autoPlayRequest.PlayerId = request.PlayerId; var autoPlayResponse = await gamePlayEngine.PlayTurnAsync(autoPlayRequest); // ToDo: Add logging. return(response); }
public async Task <ApplyTurnResponse> ApplyTurnAsync(ApplyTurnRequest request) { var response = ServiceMessageFactory <ApplyTurnResponse> .CreateFrom(request); var playerRequest = ServiceMessageFactory <GetPlayerRequest> .CreateFrom(request); playerRequest.PlayerId = request.PlayerId; var playerResponse = await playerAccess.GetPlayerAsync(playerRequest); var playTurnRequest = ServiceMessageFactory <PlayTurnRequest> .CreateFrom(request); playTurnRequest.GameSessionId = request.GameSessionId; playTurnRequest.PlayerId = request.PlayerId; playTurnRequest.Address = request.Address; playTurnRequest.IsAutoPlay = playerResponse.Player.IsMachine; var playTurnResponse = await gamePlayEngine.PlayTurnAsync(playTurnRequest); if (playTurnResponse.HasErrors) { logger.LogError($"{InstanceId}: {playTurnResponse.Errors}"); } return(response); }