1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Make ScoreProcessor abstract and avoid making AddJudgement virtual.

This commit is contained in:
Dean Herbert 2016-11-29 22:02:37 +09:00
parent eb70ae788c
commit d71b284642
5 changed files with 30 additions and 34 deletions

View File

@ -10,23 +10,20 @@ namespace osu.Game.Modes.Osu
{ {
class OsuScoreProcessor : ScoreProcessor class OsuScoreProcessor : ScoreProcessor
{ {
public override void AddJudgement(JudgementInfo judgement) protected override void UpdateCalculations(JudgementInfo judgement)
{ {
base.AddJudgement(judgement); if (judgement != null)
switch (judgement.Result)
{ {
case HitResult.Hit: switch (judgement.Result)
Combo.Value++; {
break; case HitResult.Hit:
case HitResult.Miss: Combo.Value++;
Combo.Value = 0; break;
break; case HitResult.Miss:
Combo.Value = 0;
break;
}
} }
}
protected override void UpdateCalculations()
{
base.UpdateCalculations();
int score = 0; int score = 0;
int maxScore = 0; int maxScore = 0;
@ -51,8 +48,6 @@ namespace osu.Game.Modes.Osu
maxScore += 300; maxScore += 300;
break; break;
} }
} }
TotalScore.Value = score; TotalScore.Value = score;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Modes.Catch
protected override PlayMode PlayMode => PlayMode.Catch; protected override PlayMode PlayMode => PlayMode.Catch;
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(); public override ScoreProcessor CreateScoreProcessor() => null;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
} }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Modes.Mania
protected override PlayMode PlayMode => PlayMode.Mania; protected override PlayMode PlayMode => PlayMode.Mania;
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(); public override ScoreProcessor CreateScoreProcessor() => null;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
} }

View File

@ -19,7 +19,7 @@ namespace osu.Game.Modes.Taiko
protected override PlayMode PlayMode => PlayMode.Taiko; protected override PlayMode PlayMode => PlayMode.Taiko;
public override ScoreProcessor CreateScoreProcessor() => new ScoreProcessor(); public override ScoreProcessor CreateScoreProcessor() => null;
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
} }

View File

@ -11,37 +11,38 @@ using osu.Game.Modes.Objects.Drawables;
namespace osu.Game.Modes namespace osu.Game.Modes
{ {
public class ScoreProcessor public abstract class ScoreProcessor
{ {
public virtual Score GetScore() => new Score(); public virtual Score GetScore() => new Score();
public BindableDouble TotalScore = new BindableDouble { MinValue = 0 }; public readonly BindableDouble TotalScore = new BindableDouble { MinValue = 0 };
public BindableDouble Accuracy = new BindableDouble { MinValue = 0, MaxValue = 1 }; public readonly BindableDouble Accuracy = new BindableDouble { MinValue = 0, MaxValue = 1 };
public BindableInt Combo = new BindableInt(); public readonly BindableInt Combo = new BindableInt();
public BindableInt MaximumCombo = new BindableInt(); public readonly BindableInt MaximumCombo = new BindableInt();
public List<JudgementInfo> Judgements = new List<JudgementInfo>(); public readonly List<JudgementInfo> Judgements = new List<JudgementInfo>();
public virtual void AddJudgement(JudgementInfo judgement) public ScoreProcessor()
{
Combo.ValueChanged += delegate { MaximumCombo.Value = Math.Max(MaximumCombo.Value, Combo.Value); };
}
public void AddJudgement(JudgementInfo judgement)
{ {
Judgements.Add(judgement); Judgements.Add(judgement);
UpdateCalculations();
UpdateCalculations(judgement);
judgement.ComboAtHit = (ulong)Combo.Value; judgement.ComboAtHit = (ulong)Combo.Value;
if (Combo.Value > MaximumCombo.Value)
MaximumCombo.Value = Combo.Value;
} }
/// <summary> /// <summary>
/// Update any values that potentially need post-processing on a judgement change. /// Update any values that potentially need post-processing on a judgement change.
/// </summary> /// </summary>
protected virtual void UpdateCalculations() /// <param name="newJudgement">A new JudgementInfo that triggered this calculation. May be null.</param>
{ protected abstract void UpdateCalculations(JudgementInfo newJudgement);
}
} }
} }