protected override APIRequest FetchScores(Action <IEnumerable <ScoreInfo> > scoresCallback) { var req = new GetScoresRequest(Score.Beatmap, Score.Ruleset); req.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineScoreID != Score.OnlineScoreID).Select(s => s.CreateScoreInfo(rulesets))); return(req); }
public GetScoresResponse Get([FromBody] GetScoresRequest request) { var response = new GetScoresResponse(); try { if (request == null) { throw new Exception("request is null - input format may be incorrect"); } if (request.publicKey != PublicKey) { throw new Exception("invalid access key"); } if (string.IsNullOrEmpty(request.game)) { throw new Exception("no game was specified"); } var maxCount = request.maxCount > 0 ? request.maxCount : int.MaxValue; response.scores = highScores.GetScores(request.game, maxCount); response.status = 0; } catch (Exception ex) { response.status = 1; response.message = ex.ToString(); } return(response); }
private void updateScores() { if (!IsLoaded) { return; } Scores = null; getScoresRequest?.Cancel(); if (api == null || Beatmap == null) { return; } loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap); getScoresRequest.Success += r => { Scores = r.Scores; loading.Hide(); }; api.Queue(getScoresRequest); }
protected override APIRequest FetchScores(Action <IEnumerable <ScoreInfo> > scoresCallback) { if (Scope == BeatmapLeaderboardScope.Local) { Scores = scoreManager.QueryScores(s => s.Beatmap.ID == Beatmap.ID).ToArray(); PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; return(null); } if (Beatmap?.OnlineBeatmapID == null) { PlaceholderState = PlaceholderState.Unavailable; return(null); } if (Scope != BeatmapLeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) { PlaceholderState = PlaceholderState.NotSupporter; return(null); } var req = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope); req.Success += r => scoresCallback?.Invoke(r.Scores); return(req); }
private void updateScores() { getScoresRequest?.Cancel(); getScoresRequest = null; pendingUpdateScores?.Cancel(); pendingUpdateScores = Schedule(() => { if (Scope == LeaderboardScope.Local) { // TODO: get local scores from wherever here. PlaceholderState = PlaceholderState.NoScores; return; } if (Beatmap?.OnlineBeatmapID == null) { PlaceholderState = PlaceholderState.Unavailable; return; } if (api?.IsLoggedIn != true) { PlaceholderState = PlaceholderState.NotLoggedIn; return; } if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) { PlaceholderState = PlaceholderState.NotSupporter; return; } PlaceholderState = PlaceholderState.Retrieving; loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope); getScoresRequest.Success += r => Schedule(() => { Scores = r.Scores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; }); getScoresRequest.Failure += e => Schedule(() => { if (e is OperationCanceledException) { return; } PlaceholderState = PlaceholderState.NetworkFailure; }); api.Queue(getScoresRequest); }); }
protected override APIRequest FetchScores(Action <IEnumerable <ScoreInfo> > scoresCallback) { if (Score.BeatmapInfo.OnlineID == null || Score.BeatmapInfo.Status <= BeatmapOnlineStatus.Pending) { return(null); } getScoreRequest = new GetScoresRequest(Score.BeatmapInfo, Score.Ruleset); getScoreRequest.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineID != Score.OnlineID).Select(s => s.CreateScoreInfo(rulesets, Beatmap.Value.BeatmapInfo))); return(getScoreRequest); }
protected override APIRequest FetchScores(Action <IEnumerable <ScoreInfo> > scoresCallback) { if (Score.Beatmap.OnlineBeatmapID == null || Score.Beatmap.Status <= BeatmapSetOnlineStatus.Pending) { return(null); } var req = new GetScoresRequest(Score.Beatmap, Score.Ruleset); req.Success += r => scoresCallback?.Invoke(r.Scores.Where(s => s.OnlineScoreID != Score.OnlineScoreID).Select(s => s.CreateScoreInfo(rulesets))); return(req); }
private void beatmapChanged(WorkingBeatmap newBeatmap) { lastRequest?.Cancel(); scores.Clear(); if (!api.IsLoggedIn) { return; } lastRequest = new GetScoresRequest(newBeatmap.BeatmapInfo); lastRequest.Success += res => res.Scores.ForEach(s => scores.Add(new PerformanceDisplay(s, newBeatmap.Beatmap))); api.Queue(lastRequest); }
private void updateLeaderboard(WorkingBeatmap beatmap) { leaderboard.Scores = null; getScoresRequest?.Cancel(); if (beatmap?.BeatmapInfo == null) { return; } getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo); getScoresRequest.Success += r => leaderboard.Scores = r.Scores; Game.API.Queue(getScoresRequest); }
private void updateScores() { getScoresRequest?.Cancel(); getScoresRequest = null; Scores = null; if (Scope == LeaderboardScope.Local) { // TODO: get local scores from wherever here. PlaceholderState = PlaceholderState.NoScores; return; } if (api?.IsLoggedIn != true) { PlaceholderState = PlaceholderState.NotLoggedIn; return; } if (Beatmap?.OnlineBeatmapID == null) { PlaceholderState = PlaceholderState.NetworkFailure; return; } PlaceholderState = PlaceholderState.Retrieving; loading.Show(); if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) { loading.Hide(); PlaceholderState = PlaceholderState.NotSupporter; return; } getScoresRequest = new GetScoresRequest(Beatmap, osuGame?.Ruleset.Value ?? Beatmap.Ruleset, Scope); getScoresRequest.Success += r => { Scores = r.Scores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; }; getScoresRequest.Failure += onUpdateFailed; api.Queue(getScoresRequest); }
private void updateScores() { if (!IsLoaded) { return; } Leaderboard.Scores = null; getScoresRequest?.Cancel(); if (api == null || beatmap?.BeatmapInfo == null || !Leaderboard.IsPresent) { return; } getScoresRequest = new GetScoresRequest(beatmap.BeatmapInfo); getScoresRequest.Success += r => Leaderboard.Scores = r.Scores; api.Queue(getScoresRequest); }
private void updateScores(BeatmapInfo beatmap) { getScoresRequest?.Cancel(); if (!beatmap.OnlineBeatmapID.HasValue) { scores.CleanAllScores(); return; } scores.IsLoading = true; getScoresRequest = new GetScoresRequest(beatmap); getScoresRequest.Success += r => { scores.Scores = r.Scores; scores.IsLoading = false; }; api.Queue(getScoresRequest); }
private void getScores() { getScoresRequest?.Cancel(); getScoresRequest = null; noScoresPlaceholder.Hide(); if (Beatmap.Value?.OnlineBeatmapID.HasValue != true || Beatmap.Value.Status <= BeatmapSetOnlineStatus.Pending) { Scores = null; content.Hide(); return; } if (scope.Value != BeatmapLeaderboardScope.Global && !userIsSupporter) { Scores = null; notSupporterPlaceholder.Show(); loading.Hide(); return; } notSupporterPlaceholder.Hide(); content.Show(); loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap.Value, Beatmap.Value.Ruleset, scope.Value, modSelector.SelectedMods); getScoresRequest.Success += scores => { loading.Hide(); Scores = scores; if (!scores.Scores.Any()) { noScoresPlaceholder.ShowWithScope(scope.Value); } }; api.Queue(getScoresRequest); }
public async Task <ActionResult <GetScoresResponse> > GetScores([FromRoute] GetScoresRequest request) { if (request.Score < 0 || request.Score > 5) { return(BadRequest("Score is out of range")); } var query = new GetScoresQuery { Score = request.Score }; var result = await _mediator.Send(query); if (!result.Success) { return(StatusCode(500, "Unable to get score data at this time")); } var response = _mapper.Map <GetScoresResponse>(result); return(response); }
private void updateScores() { // don't display any scores or placeholder until the first Scores_Set has been called. // this avoids scope changes flickering a "no scores" placeholder before initialisation of song select is finished. if (!scoresLoadedOnce) { return; } getScoresRequest?.Cancel(); getScoresRequest = null; pendingUpdateScores?.Cancel(); pendingUpdateScores = Schedule(() => { if (Scope == LeaderboardScope.Local) { // TODO: get local scores from wherever here. PlaceholderState = PlaceholderState.NoScores; return; } if (Beatmap?.OnlineBeatmapID == null) { PlaceholderState = PlaceholderState.Unavailable; return; } if (api?.IsLoggedIn != true) { PlaceholderState = PlaceholderState.NotLoggedIn; return; } if (Scope != LeaderboardScope.Global && !api.LocalUser.Value.IsSupporter) { PlaceholderState = PlaceholderState.NotSupporter; return; } PlaceholderState = PlaceholderState.Retrieving; loading.Show(); getScoresRequest = new GetScoresRequest(Beatmap, ruleset.Value ?? Beatmap.Ruleset, Scope); getScoresRequest.Success += r => Schedule(() => { Scores = r.Scores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; }); getScoresRequest.Failure += e => Schedule(() => { if (e is OperationCanceledException) { return; } PlaceholderState = PlaceholderState.NetworkFailure; }); api.Queue(getScoresRequest); }); }