Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Dec 30, 2017
1 parent a44266d commit 36c54b9
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
18 changes: 9 additions & 9 deletions OsuHelper/Services/BeatmapProcessorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private double TimeToOverallDifficulty(TimeSpan time)
return (78 - ms) / 6;
}

public BeatmapTraits CalculateTraitsWithMods(Beatmap beatmap, Mods mods)
public BeatmapTraits CalculateBeatmapTraitsWithMods(Beatmap beatmap, Mods mods)
{
// No mods - just return base traits
if (mods == Mods.None)
Expand All @@ -44,19 +44,19 @@ public BeatmapTraits CalculateTraitsWithMods(Beatmap beatmap, Mods mods)

// Carry over unchanged traits
var maxCombo = beatmap.Traits.MaxCombo;
var duration = beatmap.Traits.Duration;
var tempo = beatmap.Traits.Tempo;
var sr = beatmap.Traits.StarRating; // can't calculate this

// Calculate duration and tempo
var duration = beatmap.Traits.Duration;
var tempo = beatmap.Traits.Tempo;
if (mods.HasFlag(Mods.DoubleTime))
{
duration = beatmap.Traits.Duration.Multiply(1 / 1.5);
duration = beatmap.Traits.Duration.Divide(1.5);
tempo = beatmap.Traits.Tempo * 1.5;
}
else if (mods.HasFlag(Mods.HalfTime))
{
duration = beatmap.Traits.Duration.Multiply(1 / 0.75);
duration = beatmap.Traits.Duration.Divide(0.75);
tempo = beatmap.Traits.Tempo * 0.75;
}

Expand All @@ -75,13 +75,13 @@ public BeatmapTraits CalculateTraitsWithMods(Beatmap beatmap, Mods mods)
}
if (mods.HasFlag(Mods.DoubleTime))
{
ar = TimeToApproachRate(ApproachRateToTime(ar).Multiply(1 / 1.5));
od = TimeToOverallDifficulty(OverallDifficultyToTime(od).Multiply(1 / 1.5));
ar = TimeToApproachRate(ApproachRateToTime(ar).Divide(1.5));
od = TimeToOverallDifficulty(OverallDifficultyToTime(od).Divide(1.5));
}
else if (mods.HasFlag(Mods.HalfTime))
{
ar = TimeToApproachRate(ApproachRateToTime(ar).Multiply(1 / 0.75));
od = TimeToOverallDifficulty(OverallDifficultyToTime(od).Multiply(1 / 0.75));
ar = TimeToApproachRate(ApproachRateToTime(ar).Divide(0.75));
od = TimeToOverallDifficulty(OverallDifficultyToTime(od).Divide(0.75));
}

// Calculate CS and HP
Expand Down
2 changes: 1 addition & 1 deletion OsuHelper/Services/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public async Task<string> GetBeatmapRawAsync(string beatmapId)
return response;
}

public async Task<Stream> GetMapSetPreviewAsync(string mapSetId)
public async Task<Stream> GetBeatmapSetPreviewAsync(string mapSetId)
{
// Try get from cache first
var cached = _cacheService.RetrieveOrDefault<Stream>($"BeatmapPreview-{mapSetId}");
Expand Down
2 changes: 1 addition & 1 deletion OsuHelper/Services/IBeatmapProcessorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace OsuHelper.Services
{
public interface IBeatmapProcessorService
{
BeatmapTraits CalculateTraitsWithMods(Beatmap beatmap, Mods mods);
BeatmapTraits CalculateBeatmapTraitsWithMods(Beatmap beatmap, Mods mods);
}
}
2 changes: 1 addition & 1 deletion OsuHelper/Services/IDataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public interface IDataService

Task<string> GetBeatmapRawAsync(string beatmapId);

Task<Stream> GetMapSetPreviewAsync(string mapSetId);
Task<Stream> GetBeatmapSetPreviewAsync(string mapSetId);

Task<IReadOnlyList<Play>> GetUserTopPlaysAsync(string userId, GameMode gameMode);

Expand Down
2 changes: 1 addition & 1 deletion OsuHelper/Services/IRecommendationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace OsuHelper.Services
{
public interface IRecommendationService
{
Task<IReadOnlyList<Recommendation>> GetRecommendationsAsync(IProgress<double> progress);
Task<IReadOnlyList<Recommendation>> GetRecommendationsAsync(IProgress<double> progressHandler);
}
}
2 changes: 1 addition & 1 deletion OsuHelper/Services/RecommendationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ await candidatePlaysGroups.ParallelForEachAsync(async group =>
var beatmap = await _dataService.GetBeatmapAsync(play.BeatmapId, GameMode);

// Calculate traits with mods
var traitsWithMods = _beatmapProcessorService.CalculateTraitsWithMods(beatmap, play.Mods);
var traitsWithMods = _beatmapProcessorService.CalculateBeatmapTraitsWithMods(beatmap, play.Mods);

// Add recommendation to the list
var recommendation = new Recommendation(beatmap, count, play.Mods, traitsWithMods, play.Accuracy,
Expand Down
7 changes: 4 additions & 3 deletions OsuHelper/ViewModels/BeatmapDetailsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.Net;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
Expand Down Expand Up @@ -50,6 +49,7 @@ public BeatmapDetailsViewModel(ISettingsService settingsService, IDataService da
_dataService = dataService;
_audioService = audioService;

// Commands
OpenPageCommand = new RelayCommand(OpenPage);
DownloadCommand = new RelayCommand(Download);
DownloadDirectCommand = new RelayCommand(DownloadDirect);
Expand All @@ -58,6 +58,7 @@ public BeatmapDetailsViewModel(ISettingsService settingsService, IDataService da
StopPreviewCommand = new RelayCommand(StopPreview, () => IsPreviewPlaying);
TogglePreviewCommand = new RelayCommand(TogglePreview);

// Messages
MessengerInstance.Register<ShowBeatmapDetailsMessage>(this, m =>
{
Beatmap = m.Beatmap;
Expand Down Expand Up @@ -92,7 +93,7 @@ private async void PlayPreview()

try
{
using (var stream = await _dataService.GetMapSetPreviewAsync(Beatmap.MapSetId))
using (var stream = await _dataService.GetBeatmapSetPreviewAsync(Beatmap.MapSetId))
await _audioService.PlayAsync(stream);
}
catch (HttpErrorStatusCodeException ex) when (ex.StatusCode == HttpStatusCode.Forbidden)
Expand Down
1 change: 1 addition & 0 deletions OsuHelper/ViewModels/NotificationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public string Content

public NotificationViewModel()
{
// Messages
MessengerInstance.Register<ShowNotificationMessage>(this, m =>
{
Title = m.Title;
Expand Down

0 comments on commit 36c54b9

Please sign in to comment.