public BluffParams GetBluffParams(SendBluffViewModel model, string userId, RockPaperScissorsType choice) { var bluffParams = _mapper.Map <SendBluffViewModel, BluffParams>(model); bluffParams.UserId = userId; bluffParams.GameRoundId = model.GameRoundId; return(bluffParams); }
public async Task <IActionResult> SendBluff(SendBluffViewModel model) { var accessToken = HttpContext.Request.Headers["Authorization"].ToString().GetAccessTokenFromHeaderString(); var userId = await _identityService.GetUserId(accessToken); var isSuccess = await _gameManager.SendBluff(userId, model); if (isSuccess) { return(BadRequest(_localizer.GetString("ExpiredBluff"))); } return(Ok(true)); }
public async Task <bool> SendBluff(string userId, SendBluffViewModel model) { var roundAnswers = _roundAnswerService.RoundAnswers(model.GameRoundId); if (roundAnswers.All(x => x.Choice != Enum.RockPaperScissorsType.NotAnswered)) { return(false); } BluffParams bluffParams = _bluffService.GetBluffParams(model, userId, model.Choice); _bluffService.CreateOrUpdate(bluffParams); await _bluffService.TextBluff(model, userId); return(true); }
public async Task TextBluff(SendBluffViewModel model, string userId) { var isHostUser = _gameService.IsHostUser(model.GameId, userId); await _hubContext.Clients.User(userId).SendAsync("TextBluff", JsonConvert.SerializeObject(new { choice = model.Choice })); }