Skip to content

Commit

Permalink
made all the changes again without cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yaggod committed Jul 29, 2024
1 parent 7d75616 commit c2577e8
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 14 deletions.
38 changes: 25 additions & 13 deletions osu-trainer/DifficultyCalculator.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using FsBeatmapProcessor;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using osu_trainer.ODCalculators;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace osu_trainer
{
Expand All @@ -17,7 +14,9 @@ class DifficultyCalculator
static string tempBeatmapPath = "temp.osu";
static Semaphore diffCalcInProgress;

static DifficultyCalculator() {

static DifficultyCalculator()
{
diffCalcInProgress = new Semaphore(1, 1);
}

Expand Down Expand Up @@ -55,14 +54,27 @@ private static decimal MsToApproachRate(decimal ms)
}
public static decimal CalculateMultipliedOD(Beatmap map, decimal BpmMultiplier)
{
decimal newbpmMs = OverallDifficultyToMs(map.OverallDifficulty) / BpmMultiplier;
decimal newbpmOD = MsToOverallDifficulty(newbpmMs);
decimal newbpmMs = OverallDifficultyToMs(map.OverallDifficulty, map.Mode)/ BpmMultiplier;
decimal newbpmOD = MsToOverallDifficulty(newbpmMs, map.Mode);
newbpmOD = (decimal)Math.Round(newbpmOD * 10.0M) / 10.0M;
newbpmOD = JunUtils.Clamp(newbpmOD, 0, 11);
newbpmOD = JunUtils.Clamp(newbpmOD, 0, map.Mode == GameMode.Mania ? 10 : 11);
return newbpmOD;
}
private static decimal OverallDifficultyToMs(decimal od) => -6.0M * od + 79.5M;
private static decimal MsToOverallDifficulty(decimal ms) => (79.5M - ms) / 6.0M;
private static decimal OverallDifficultyToMs(decimal od, GameMode mode)
{
ODCalculator odCalculator = ODCalculator.GetCalculatorForGamemode(mode);
return odCalculator.OverallDifficultyToMs(od);
}



private static decimal MsToOverallDifficulty(decimal ms, GameMode mode)
{

ODCalculator odCalculator = ODCalculator.GetCalculatorForGamemode(mode);
return odCalculator.MsToOverallDifficulty(ms);
}

public static (decimal, decimal, decimal) CalculateStarRating(Beatmap map)
{
if (map == null)
Expand Down Expand Up @@ -109,12 +121,12 @@ public static (decimal, decimal, decimal) CalculateStarRating(Beatmap map)
Console.WriteLine("Could not calculate difficulty");
return (0, 0, 0);
}
decimal stars = oppaiData.GetValue("stars").ToObject<decimal>();
decimal aimStars = oppaiData.GetValue("aim_stars").ToObject<decimal>();
decimal stars = oppaiData.GetValue("stars").ToObject<decimal>();
decimal aimStars = oppaiData.GetValue("aim_stars").ToObject<decimal>();
decimal speedStars = oppaiData.GetValue("speed_stars").ToObject<decimal>();


return (stars, aimStars, speedStars);
}
}
}
}
1 change: 1 addition & 0 deletions osu-trainer/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ private void ToggleHpCsArOdDisplay(object sender, EventArgs e)

enabled = (editor.State != EditorState.NOT_READY);
ODSlider.Enabled = enabled;
ODSlider.MaxValue = editor.GetMode() == GameMode.Mania ? 10 : 11; // od higher than 10 is invalid for o!m since it doesn't scaled with dt
ODDisplay.Enabled = enabled ? true : false;
ODDisplay.BackColor = enabled ? Colors.ReadOnlyBg : SystemColors.ControlDark;
ODDisplay.ForeColor = Colors.ReadOnlyFg;
Expand Down
55 changes: 55 additions & 0 deletions osu-trainer/ODCalculators/ODCalculator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using FsBeatmapProcessor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace osu_trainer.ODCalculators
{
internal class ODCalculator
{
private static readonly ODCalculator standartODCalculator = new ODCalculator(79.5M, 6M);
private static readonly ODCalculator taikoODCalculator = new ODCalculator(49.5M, 3M);
private static readonly ODCalculator catchODCalculator = new ODCalculator(0M, 0M);
private static readonly ODCalculator maniaODCalculator = new ODCalculator(63.5M, 3M);

private readonly decimal _offset;
private readonly decimal _multiplier;

public decimal OverallDifficultyToMs(decimal od)
{
return _offset - od * _multiplier;
}
public decimal MsToOverallDifficulty(decimal ms)
{
if (_multiplier == 0)
return 0;
return (_offset - ms) / _multiplier;
}

public static ODCalculator GetCalculatorForGamemode(GameMode mode)
{
switch (mode)
{
case GameMode.osu:
return standartODCalculator;
case GameMode.Taiko:
return taikoODCalculator;
case GameMode.CatchtheBeat:
return catchODCalculator;
case GameMode.Mania:
return maniaODCalculator;
default:
throw new ArgumentException(nameof(mode));
}
}

private ODCalculator(decimal offset, decimal multiplier)
{
_offset = offset;
_multiplier = multiplier;
}

}
}
1 change: 1 addition & 0 deletions osu-trainer/osu-trainer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BeatmapEditor.cs" />
<Compile Include="ODCalculators\ODCalculator.cs" />
<Compile Include="Colors.cs" />
<Compile Include="Controls\AdvancedControl.cs">
<SubType>Component</SubType>
Expand Down
2 changes: 1 addition & 1 deletion osu-trainer/version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github repository name: FunOrange/osu-trainer
application name: osu-trainer.exe
current version: 1.6.6
current version: 1.7.0
check for updates: true

0 comments on commit c2577e8

Please sign in to comment.