Add ability to add "OK" or 100s via right click

This commit is contained in:
Dean Herbert
2022-10-18 18:27:05 +09:00
parent a7b3aa62fb
commit 74e1b5794b

View File

@ -21,6 +21,7 @@ using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osuTK.Graphics; using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Tests.Visual.Gameplay namespace osu.Game.Tests.Visual.Gameplay
{ {
@ -92,7 +93,7 @@ namespace osu.Game.Tests.Visual.Gameplay
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Width = 0.5f, Width = 0.5f,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Text = "Left click to add miss" Text = $"Left click to add miss\nRight click to add OK/{base_ok}"
} }
} }
}, },
@ -102,7 +103,9 @@ namespace osu.Game.Tests.Visual.Gameplay
}; };
sliderMaxCombo.Current.BindValueChanged(_ => rerun()); sliderMaxCombo.Current.BindValueChanged(_ => rerun());
graphs.MissLocations.BindCollectionChanged((_, __) => rerun()); graphs.MissLocations.BindCollectionChanged((_, __) => rerun());
graphs.NonPerfectLocations.BindCollectionChanged((_, __) => rerun());
graphs.MaxCombo.BindTo(sliderMaxCombo.Current); graphs.MaxCombo.BindTo(sliderMaxCombo.Current);
@ -110,6 +113,9 @@ namespace osu.Game.Tests.Visual.Gameplay
}); });
} }
private const int base_great = 300;
private const int base_ok = 100;
private void rerun() private void rerun()
{ {
graphs.Clear(); graphs.Clear();
@ -118,33 +124,50 @@ namespace osu.Game.Tests.Visual.Gameplay
runForProcessor("lazer-standardised", Color4.YellowGreen, new ScoreProcessor(new OsuRuleset()) { Mode = { Value = ScoringMode.Standardised } }); runForProcessor("lazer-standardised", Color4.YellowGreen, new ScoreProcessor(new OsuRuleset()) { Mode = { Value = ScoringMode.Standardised } });
runForProcessor("lazer-classic", Color4.MediumPurple, new ScoreProcessor(new OsuRuleset()) { Mode = { Value = ScoringMode.Classic } }); runForProcessor("lazer-classic", Color4.MediumPurple, new ScoreProcessor(new OsuRuleset()) { Mode = { Value = ScoringMode.Classic } });
runScoreV1();
runScoreV2();
}
private void runScoreV1()
{
int totalScore = 0; int totalScore = 0;
int currentCombo = 0; int currentCombo = 0;
const int base_score = 300; void applyHitV1(int baseScore)
runForAlgorithm("ScoreV1 (classic)", Color4.Purple, () =>
{ {
if (baseScore == 0)
{
currentCombo = 0;
return;
}
const float score_multiplier = 1; const float score_multiplier = 1;
totalScore += base_score; totalScore += baseScore;
// combo multiplier // combo multiplier
// ReSharper disable once PossibleLossOfFraction // ReSharper disable once PossibleLossOfFraction
totalScore += (int)(Math.Max(0, currentCombo - 1) * (base_score / 25 * score_multiplier)); totalScore += (int)(Math.Max(0, currentCombo - 1) * (baseScore / 25 * score_multiplier));
currentCombo++; currentCombo++;
}, () => }
{
currentCombo = 0;
}, () =>
{
// Arbitrary value chosen towards the upper range.
const double score_multiplier = 4;
return (int)(totalScore * score_multiplier); runForAlgorithm("ScoreV1 (classic)", Color4.Purple,
}); () => applyHitV1(base_great),
() => applyHitV1(base_ok),
() => applyHitV1(0),
() =>
{
// Arbitrary value chosen towards the upper range.
const double score_multiplier = 4;
return (int)(totalScore * score_multiplier);
});
}
private void runScoreV2()
{
int currentCombo = 0;
double comboPortion = 0; double comboPortion = 0;
int maxCombo = sliderMaxCombo.Current.Value; int maxCombo = sliderMaxCombo.Current.Value;
@ -154,33 +177,43 @@ namespace osu.Game.Tests.Visual.Gameplay
int currentHits = 0; int currentHits = 0;
double comboPortionMax = 0;
for (int i = 0; i < maxCombo; i++) for (int i = 0; i < maxCombo; i++)
comboPortionMax += base_score * (1 + (i + 1) / 10.0); applyHitV2(base_great);
runForAlgorithm("ScoreV2", Color4.OrangeRed, () => double comboPortionMax = comboPortion;
comboPortion = 0;
maxBaseScore = 0;
currentBaseScore = 0;
currentHits = 0;
void applyHitV2(int baseScore)
{ {
maxBaseScore += base_score; maxBaseScore += baseScore;
currentBaseScore += base_score; currentBaseScore += baseScore;
comboPortion += base_score * (1 + ++currentCombo / 10.0); comboPortion += baseScore * (1 + ++currentCombo / 10.0);
currentHits++; currentHits++;
}, () => }
{
currentHits++;
maxBaseScore += base_score;
currentCombo = 0; runForAlgorithm("ScoreV2", Color4.OrangeRed,
}, () => () => applyHitV2(base_great),
{ () => applyHitV2(base_ok),
double accuracy = currentBaseScore / maxBaseScore; () =>
{
currentHits++;
maxBaseScore += base_great;
currentCombo = 0;
}, () =>
{
double accuracy = currentBaseScore / maxBaseScore;
return (int)Math.Round return (int)Math.Round
( (
700000 * comboPortion / comboPortionMax + 700000 * comboPortion / comboPortionMax +
300000 * Math.Pow(accuracy, 10) * ((double)currentHits / maxCombo) 300000 * Math.Pow(accuracy, 10) * ((double)currentHits / maxCombo)
); );
}); });
} }
private void runForProcessor(string name, Color4 colour, ScoreProcessor processor) private void runForProcessor(string name, Color4 colour, ScoreProcessor processor)
@ -195,11 +228,12 @@ namespace osu.Game.Tests.Visual.Gameplay
runForAlgorithm(name, colour, runForAlgorithm(name, colour,
() => processor.ApplyResult(new OsuJudgementResult(new HitCircle(), new OsuJudgement()) { Type = HitResult.Great }), () => processor.ApplyResult(new OsuJudgementResult(new HitCircle(), new OsuJudgement()) { Type = HitResult.Great }),
() => processor.ApplyResult(new OsuJudgementResult(new HitCircle(), new OsuJudgement()) { Type = HitResult.Ok }),
() => processor.ApplyResult(new OsuJudgementResult(new HitCircle(), new OsuJudgement()) { Type = HitResult.Miss }), () => processor.ApplyResult(new OsuJudgementResult(new HitCircle(), new OsuJudgement()) { Type = HitResult.Miss }),
() => (int)processor.TotalScore.Value); () => (int)processor.TotalScore.Value);
} }
private void runForAlgorithm(string name, Color4 colour, Action applyHit, Action applyMiss, Func<int> getTotalScore) private void runForAlgorithm(string name, Color4 colour, Action applyHit, Action applyNonPerfect, Action applyMiss, Func<int> getTotalScore)
{ {
int maxCombo = sliderMaxCombo.Current.Value; int maxCombo = sliderMaxCombo.Current.Value;
@ -209,6 +243,8 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
if (graphs.MissLocations.Contains(i)) if (graphs.MissLocations.Contains(i))
applyMiss(); applyMiss();
else if (graphs.NonPerfectLocations.Contains(i))
applyNonPerfect();
else else
applyHit(); applyHit();
@ -243,6 +279,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public class GraphContainer : Container public class GraphContainer : Container
{ {
public readonly BindableList<double> MissLocations = new BindableList<double>(); public readonly BindableList<double> MissLocations = new BindableList<double>();
public readonly BindableList<double> NonPerfectLocations = new BindableList<double>();
public Bindable<int> MaxCombo = new Bindable<int>(); public Bindable<int> MaxCombo = new Bindable<int>();
@ -287,6 +324,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}; };
MissLocations.BindCollectionChanged((_, _) => updateMissLocations()); MissLocations.BindCollectionChanged((_, _) => updateMissLocations());
NonPerfectLocations.BindCollectionChanged((_, _) => updateMissLocations());
MaxCombo.BindValueChanged(_ => MaxCombo.BindValueChanged(_ =>
{ {
@ -345,6 +383,19 @@ namespace osu.Game.Tests.Visual.Gameplay
X = (float)miss / MaxCombo.Value, X = (float)miss / MaxCombo.Value,
}); });
} }
foreach (int miss in NonPerfectLocations)
{
missLines.Add(new Box
{
Colour = Color4.Orange,
Origin = Anchor.TopCentre,
Width = 1,
RelativeSizeAxes = Axes.Y,
RelativePositionAxes = Axes.X,
X = (float)miss / MaxCombo.Value,
});
}
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
@ -365,9 +416,14 @@ namespace osu.Game.Tests.Visual.Gameplay
return base.OnMouseMove(e); return base.OnMouseMove(e);
} }
protected override bool OnClick(ClickEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
MissLocations.Add((int)(e.MousePosition.X / DrawWidth * MaxCombo.Value)); int combo = (int)(e.MousePosition.X / DrawWidth * MaxCombo.Value);
if (e.Button == MouseButton.Left)
MissLocations.Add(combo);
else
NonPerfectLocations.Add(combo);
return true; return true;
} }
} }