1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:13:21 +08:00

Refactor fail reason output to not perform string interpolation unless hooked

This commit is contained in:
Dean Herbert 2023-11-16 15:29:32 +09:00
parent 265ae6fd30
commit 3c513d0b62
No known key found for this signature in database

View File

@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
double currentHp;
double currentHpUncapped;
do
while (true)
{
currentHp = 1;
currentHpUncapped = 1;
@ -57,7 +57,6 @@ namespace osu.Game.Rulesets.Osu.Scoring
double lastTime = DrainStartTime;
int currentBreak = 0;
bool fail = false;
string failReason = string.Empty;
for (int i = 0; i < Beatmap.HitObjects.Count; i++)
{
@ -92,7 +91,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
{
fail = true;
testDrop *= 0.96;
failReason = $"hp too low ({currentHp} < {lowestHpEver})";
OnIterationFail?.Invoke($"FAILED drop {testDrop}: hp too low ({currentHp} < {lowestHpEver})");
break;
}
@ -117,7 +116,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
{
fail = true;
testDrop *= 0.96;
failReason = $"overkill ({currentHp} - {hpOverkill} <= {lowestHpEver})";
OnIterationFail?.Invoke($"FAILED drop {testDrop}: overkill ({currentHp} - {hpOverkill} <= {lowestHpEver})");
break;
}
@ -129,7 +128,7 @@ namespace osu.Game.Rulesets.Osu.Scoring
fail = true;
testDrop *= 0.94;
hpMultiplierNormal *= 1.01;
failReason = $"end hp too low ({currentHp} < {lowestHpEnd})";
OnIterationFail?.Invoke($"FAILED drop {testDrop}: end hp too low ({currentHp} < {lowestHpEnd})");
}
double recovery = (currentHpUncapped - 1) / Beatmap.HitObjects.Count;
@ -139,18 +138,15 @@ namespace osu.Game.Rulesets.Osu.Scoring
fail = true;
testDrop *= 0.96;
hpMultiplierNormal *= 1.01;
failReason = $"recovery too low ({recovery} < {hpRecoveryAvailable})";
OnIterationFail?.Invoke($"FAILED drop {testDrop}: recovery too low ({recovery} < {hpRecoveryAvailable})");
}
if (fail)
if (!fail)
{
OnIterationFail?.Invoke($"FAILED drop {testDrop}: {failReason}");
continue;
OnIterationSuccess?.Invoke($"PASSED drop {testDrop}");
return testDrop;
}
OnIterationSuccess?.Invoke($"PASSED drop {testDrop}");
return testDrop;
} while (true);
}
void reduceHp(double amount)
{