private async Task ShowAchievementsWithAnimationAsync(MatchResultDto matchResultDto) { try { DisableMenuElements(); ShowWarship(matchResultDto.SkinName); SetBattleRatingDelta(matchResultDto.MatchRatingDelta); canvasCameraSpace.SetActive(true); await ShowAnimationOfAppearanceSmoothly(leftMenu); await ShowAnimationOfAppearanceSmoothly(rightMenu); ShowSpaceshipRatingGo(); await ShowRatingCalculation(matchResultDto.CurrentWarshipRating, matchResultDto.MatchRatingDelta); await ShowRewards(matchResultDto.LootboxPoints); int sum = matchResultDto.LootboxPoints.Values.Sum(); await ShowMoneyAccrual(0, sum); ShowExitButton(); } catch (Exception e) { log.Error("Ui throw an exception ." + e.FullMessage()); } }
private void ShowPlayerAchievements(MatchResultDto matchResultDto) { log.Info(nameof(ShowPlayerAchievements) + " start"); mainCamera.transform.position = Vector3.zero; battleUiController.DisableZoneAndOverlayCanvas(); canvasCameraSpace.SetActive(true); ShowAchievementsWithAnimationAsync(matchResultDto).ConfigureAwait(true); log.Info(nameof(ShowPlayerAchievements) + " end"); }
// 猜比分 // GET: /Casino/MatchResult/id public ActionResult MatchResult(Guid id) { var model = new MatchResultDto { Match = MatchDto.Single(id), MatchGuid = id }; return(View(model)); }
private IEnumerator ShowPlayerAchievementsCoroutine() { //Достать данные из глобальных классов BattleRoyaleClientMatchModel matchModel = MatchModelStorage.Instance.GetMatchModel(); int matchId = matchModel.MatchId; if (PlayerIdStorage.TryGetServiceId(out string playerServiceId)) { if (playerServiceId == null) { throw new Exception($"{nameof(playerServiceId)} is null"); } //Загрузить данные с профиль-сервера Task <MatchResultDto> task = ExperimentalDich.GetMatchReward(matchId, playerServiceId); yield return(new WaitUntil(() => task.IsCompleted)); MatchResultDto matchResultDto = task.Result; //Если не загрузилось, перейти в лобби if (matchResultDto == null || task.IsFaulted || task.IsCanceled) { if (matchResultDto == null) { log.Error($"matchResultDto is null"); } else { PlayerAchievementsUtils.LogPlayerAchievements(matchResultDto); } if (task.IsFaulted) { log.Error($"task.IsFaulted"); } if (task.IsCanceled) { log.Error($"task.IsCanceled"); } log.Error("Не удалось загрузить результат боя игрока."); lobbyLoaderController.LoadLobbyScene(); } PlayerAchievementsUtils.LogPlayerAchievements(matchResultDto); //Показать анимацию ShowPlayerAchievements(matchResultDto); } else { log.Error($"{nameof(ShowPlayerAchievementsCoroutine)} {nameof(playerServiceId)} is null"); } }
public async Task <ActionResult <string> > Get([FromQuery] int?matchId, [FromQuery] string playerServiceId) { if (matchId == null) { Console.WriteLine($"{nameof(matchId)} is null"); return(BadRequest()); } if (playerServiceId == null) { Console.WriteLine($"{nameof(playerServiceId)} is null"); return(BadRequest()); } MatchResultDto matchResultDto = await matchResultDbReaderService .ReadMatchResultAsync(matchId.Value, playerServiceId); if (matchResultDto == null) { throw new NullReferenceException(nameof(matchResultDto)); } if (matchResultDto.CurrentWarshipRating < 0) { throw new ArgumentOutOfRangeException(nameof(matchResultDto.CurrentWarshipRating)); } if (matchResultDto.LootboxPoints.Count == 0) { throw new Exception("список наград пуст"); } foreach (var pair in matchResultDto.LootboxPoints) { Console.WriteLine($"{pair.Key} {pair.Value}"); } //Чек на адекватность ответа if (matchResultDto == null) { return(StatusCode(500)); } if (matchResultDto.CurrentWarshipRating < 0) { Console.WriteLine($"\n\n\n\n{nameof(matchResultDto.CurrentWarshipRating)} {matchResultDto.CurrentWarshipRating }"); return(StatusCode(500)); } return(matchResultDto.SerializeToBase64String()); }
public static void LogPlayerAchievements(MatchResultDto matchResultDto) { if (matchResultDto == null) { log.Info($"{nameof(matchResultDto)} is null"); return; } log.Info($"{nameof(matchResultDto.SkinName)} {matchResultDto.SkinName}"); log.Info($"{nameof(matchResultDto.MatchRatingDelta)} {matchResultDto.MatchRatingDelta}"); log.Info($"{nameof(matchResultDto.CurrentWarshipRating)} {matchResultDto.CurrentWarshipRating}"); if (matchResultDto.LootboxPoints.Count == 0) { log.Info("Список наград пуст"); } foreach (var pair in matchResultDto.LootboxPoints) { log.Info($"{pair.Key} {pair.Value}"); } }
public ActionResult MatchResult(MatchResultDto model) { if (ModelState.IsValid) { try { var id = model.MatchGuid; var bet = new Bet { UserID = AcnID, UserName = User.Identity.Name }; bet.Place(id, model.ResultHome, model.ResultAway); //投注成功 TempData["DataUrl"] = $"data-url=/Casino/GameBet/{id}"; return(RedirectToAction("GameBet", new { id })); } catch (Exception ex) { ModelState.AddModelError("Warn", ex.Message); } } else { ModelState.AddModelError("Warn", "请正确填写比赛结果比分"); } model.Match = MatchDto.Single(model.MatchGuid); //model.MatchGuid = model.MatchGuid; return(View(model)); }
public async Task <MatchResultDto> ReadMatchResultAsync(int matchId, string playerServiceId) { MatchResult matchResult = await dbContext.MatchResults .Include(matchResult1 => matchResult1.Warship) .ThenInclude(warship => warship.WarshipType) .Include(matchResult1 => matchResult1.Transaction) .ThenInclude(resource => resource.Increments) .Include(matchResult1 => matchResult1.Transaction) .ThenInclude(resource => resource.Decrements) .SingleOrDefaultAsync(matchResult1 => matchResult1.MatchId == matchId && matchResult1.Warship.Account.ServiceId == playerServiceId); //Такой матч существует? if (matchResult == null) { throw new NullReferenceException(nameof(matchResult)); return(null); } //Результат игрока записан? if (!matchResult.IsFinished) { throw new Exception("Игрок не закончил этот матч"); return(null); } int currentWarshipRating = await warshipRatingReaderService.ReadWarshipRatingAsync(matchResult.WarshipId); var lootboxPoints = new Dictionary <MatchRewardTypeEnum, int>(); if (matchResult.Transaction.Increments.Count == 0) { throw new Exception("Игрок ничего не заработал за бой"); } foreach (Increment increment in matchResult.Transaction.Increments) { if (increment.IncrementTypeId == IncrementTypeEnum.LootboxPoints) { if (increment.MatchRewardTypeId != null) { lootboxPoints.Add(increment.MatchRewardTypeId.Value, increment.Amount); } } } int warshipRatingIncrement = matchResult.Transaction.Increments .Where(increment => increment.IncrementTypeId == IncrementTypeEnum.WarshipRating) .Sum(increment => increment.Amount); int warshipRatingDecrement = matchResult.Transaction.Decrements .Where(decrement => decrement.DecrementTypeId == DecrementTypeEnum.WarshipRating) .Sum(decrement => decrement.Amount); int matchRatingDelta = warshipRatingIncrement - warshipRatingDecrement; MatchResultDto matchResultDto = new MatchResultDto { CurrentWarshipRating = currentWarshipRating, MatchRatingDelta = matchRatingDelta, LootboxPoints = lootboxPoints, SkinName = matchResult.Warship.WarshipType.Name }; return(matchResultDto); }
public MatchResultDtoWrapper(MatchResultDto matchResult) { MatchResult = matchResult; }
public ActionResult MatchResult(MatchResultDto model) { if (ModelState.IsValid) { try { var id = model.MatchGuid; var bet = new Bet { UserID = AcnID, UserName = User.Identity.Name }; bet.Place(id, model.ResultHome, model.ResultAway); //投注成功 TempData["DataUrl"] = $"data-url=/Casino/GameBet/{id}"; return RedirectToAction("GameBet", new { id }); } catch (Exception ex) { ModelState.AddModelError("Warn", ex.Message); } } else { ModelState.AddModelError("Warn", "请正确填写比赛结果比分"); } model.Match = MatchDto.Single(model.MatchGuid); //model.MatchGuid = model.MatchGuid; return View(model); }
// 猜比分 // GET: /Casino/MatchResult/id public ActionResult MatchResult(Guid id) { var model = new MatchResultDto { Match = MatchDto.Single(id), MatchGuid = id }; return View(model); }
public MatchResultViewModel(MatchResultDto matchResult) { MatchResult = matchResult; }