Skip to content

Commit

Permalink
Merge pull request #100 from frenzibyte/enforce-minmax-result
Browse files Browse the repository at this point in the history
Enforce using Min/Max result types instead of arbitrary values
  • Loading branch information
swoolcock authored Jan 20, 2021
2 parents 25c940e + 8d92702 commit 807ce3b
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ namespace osu.Game.Rulesets.Rush.Judgements
public class CollisionDamagingJudgement : RushJudgement
{
protected override double HealthPointIncreaseFor(HitResult result, bool playerCollided) =>
result switch
{
HitResult.Miss when playerCollided => -10.0,
_ => 0.0,
};
result == MinResult && playerCollided ? -10.0 : 0.0;
}
}
9 changes: 2 additions & 7 deletions osu.Game.Rulesets.Rush/Judgements/HeartJudgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ public class HeartJudgement : RushJudgement
{
public override HitResult MaxResult => HitResult.LargeBonus;

protected override double HealthPointIncreaseFor(HitResult result, bool collided)
{
if (result <= HitResult.Miss && !collided)
return 0.0;

return 50.0;
}
protected override double HealthPointIncreaseFor(HitResult result, bool collided) =>
result == MinResult && !collided ? 0.0 : 50.0;
}
}
6 changes: 1 addition & 5 deletions osu.Game.Rulesets.Rush/Objects/Drawables/DrawableDualHit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
ApplyResult(r =>
{
var lowestResult = Air.Result.Type < Ground.Result.Type ? Air.Result.Type : Ground.Result.Type;

if (!Air.IsHit && !Ground.IsHit)
r.Type = HitResult.Miss;
else
r.Type = lowestResult;
r.Type = !Air.IsHit && !Ground.IsHit ? r.Judgement.MinResult : lowestResult;
});
}

Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Rush/Objects/Drawables/DrawableHeart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
if (userTriggered)
{
if (result != HitResult.None)
ApplyResult(r => r.Type = HitResult.LargeBonus);
ApplyResult(r => r.Type = r.Judgement.MaxResult);

return;
}
Expand All @@ -63,11 +63,11 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)

// if we've passed the object and can longer hit it, miss
if (result == HitResult.None)
ApplyResult(r => r.Type = HitResult.Miss);
ApplyResult(r => r.Type = r.Judgement.MinResult);

// else if we're still able to hit it, check if the player is in the correct lane
else if (playfield.PlayerSprite.CollidesWith(HitObject))
ApplyResult(r => r.Type = HitResult.LargeBonus);
ApplyResult(r => r.Type = r.Judgement.MaxResult);
}

private class HeartHitExplosion : HeartPiece
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
if (!userTriggered)
{
if (!HitObject.HitWindows.CanBeHit(timeOffset))
ApplyResult(r => r.Type = HitResult.Miss);
ApplyResult(r => r.Type = r.Judgement.MinResult);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Rush/Objects/Drawables/DrawableMiniBoss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
if (userTriggered && timeOffset < 0)
{
var nextTick = ticks.FirstOrDefault(t => !t.IsHit);
nextTick?.TriggerResult(HitResult.SmallTickHit);
nextTick?.TriggerResult(nextTick.Result.Judgement.MaxResult);

var numHits = ticks.Count(r => r.IsHit);
var completion = (float)numHits / HitObject.RequiredHits;
Expand All @@ -120,7 +120,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
continue;
}

tick.TriggerResult(HitResult.SmallTickMiss);
tick.TriggerResult(tick.Result.Judgement.MinResult);
}

var hitResult = numHits == HitObject.RequiredHits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Rush.Judgements;
using osu.Game.Rulesets.Rush.UI;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
using osuTK.Graphics;
Expand Down Expand Up @@ -102,8 +101,7 @@ protected virtual void OnDirectionChanged(ValueChangedEvent<ScrollingDirection>
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (timeOffset >= 0)
// todo: implement judgement logic
ApplyResult(r => r.Type = HitResult.Perfect);
ApplyResult(r => r.Type = r.Judgement.MaxResult);
}

public virtual bool OnPressed(RushAction action) => false;
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Rush/Objects/Drawables/DrawableSawblade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
{
case HitResult.None:
// if we've reached the trailing "none", we successfully dodged the sawblade
ApplyResult(r => r.Type = HitResult.Perfect);
ApplyResult(r => r.Type = r.Judgement.MaxResult);
break;

case HitResult.Miss:
// sawblades only hurt the player if they collide within the trailing "miss" hit window
if (playfield.PlayerSprite.CollidesWith(HitObject))
ApplyResult(r => r.Type = HitResult.Miss);
ApplyResult(r => r.Type = r.Judgement.MinResult);

break;
}
Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Rulesets.Rush/Objects/Drawables/DrawableStarSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
if (!Head.IsHit)
{
// Head missed, judge as overall missed.
if (Head.Result.Type == HitResult.Miss)
if (Head.Result.Type == Head.Result.Judgement.MinResult)
{
ApplyResult(r => r.Type = HitResult.Miss);
ApplyResult(r => r.Type = r.Judgement.MinResult);
return;
}

Expand All @@ -158,7 +158,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
// Released before required progress for completion, judge as overall missed.
if (userTriggered && Progress < REQUIRED_COMPLETION)
{
ApplyResult(r => r.Type = HitResult.Miss);
ApplyResult(r => r.Type = r.Judgement.MinResult);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
}
else if (!HitObject.HitWindows.CanBeHit(timeOffset))
{
ApplyResult(r => r.Type = HitResult.Miss);
ApplyResult(r => r.Type = r.Judgement.MinResult);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ public DrawableStarSheetTail(DrawableStarSheet starSheet)

protected override void CheckForResult(bool userTriggered, double timeOffset)
{
var overallMissed = StarSheet.Result.Type == HitResult.Miss;
var overallMissed = StarSheet.Result.Type == StarSheet.Result.Judgement.MinResult;

// Apply tail miss at its time when the entire star sheet has already been judged as missed.
if (overallMissed && timeOffset >= 0)
{
ApplyResult(r => r.Type = HitResult.Miss);
ApplyResult(r => r.Type = r.Judgement.MinResult);
return;
}

// for now let's give the player an automatic perfect if they hold the action (like in a certain other rhythm game)
if (!userTriggered)
{
if (timeOffset >= 0)
ApplyResult(r => r.Type = HitResult.Perfect);
ApplyResult(r => r.Type = r.Judgement.MaxResult);
return;
}

Expand All @@ -42,7 +42,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
return;

// ...and an automatic perfect if they release within any "hit" judged period
ApplyResult(r => r.Type = HitResult.Perfect);
ApplyResult(r => r.Type = r.Judgement.MaxResult);
}

// FIXME: should logically be TrailingAnchor, not sure why it renders incorrectly
Expand Down

0 comments on commit 807ce3b

Please sign in to comment.