mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +08:00
Replace calls to obsoleted GetOrDefault()
extension
This commit is contained in:
parent
856adfe6a3
commit
fb5d25405e
@ -4,7 +4,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -33,11 +32,11 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
{
|
{
|
||||||
mods = Score.Mods;
|
mods = Score.Mods;
|
||||||
|
|
||||||
fruitsHit = Score.Statistics.GetOrDefault(HitResult.Great);
|
fruitsHit = Score.Statistics.GetValueOrDefault(HitResult.Great);
|
||||||
ticksHit = Score.Statistics.GetOrDefault(HitResult.LargeTickHit);
|
ticksHit = Score.Statistics.GetValueOrDefault(HitResult.LargeTickHit);
|
||||||
tinyTicksHit = Score.Statistics.GetOrDefault(HitResult.SmallTickHit);
|
tinyTicksHit = Score.Statistics.GetValueOrDefault(HitResult.SmallTickHit);
|
||||||
tinyTicksMissed = Score.Statistics.GetOrDefault(HitResult.SmallTickMiss);
|
tinyTicksMissed = Score.Statistics.GetValueOrDefault(HitResult.SmallTickMiss);
|
||||||
misses = Score.Statistics.GetOrDefault(HitResult.Miss);
|
misses = Score.Statistics.GetValueOrDefault(HitResult.Miss);
|
||||||
|
|
||||||
// We are heavily relying on aim in catch the beat
|
// We are heavily relying on aim in catch the beat
|
||||||
double value = Math.Pow(5.0 * Math.Max(1.0, Attributes.StarRating / 0.0049) - 4.0, 2.0) / 100000.0;
|
double value = Math.Pow(5.0 * Math.Max(1.0, Attributes.StarRating / 0.0049) - 4.0, 2.0) / 100000.0;
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -37,12 +36,12 @@ namespace osu.Game.Rulesets.Mania.Difficulty
|
|||||||
{
|
{
|
||||||
mods = Score.Mods;
|
mods = Score.Mods;
|
||||||
scaledScore = Score.TotalScore;
|
scaledScore = Score.TotalScore;
|
||||||
countPerfect = Score.Statistics.GetOrDefault(HitResult.Perfect);
|
countPerfect = Score.Statistics.GetValueOrDefault(HitResult.Perfect);
|
||||||
countGreat = Score.Statistics.GetOrDefault(HitResult.Great);
|
countGreat = Score.Statistics.GetValueOrDefault(HitResult.Great);
|
||||||
countGood = Score.Statistics.GetOrDefault(HitResult.Good);
|
countGood = Score.Statistics.GetValueOrDefault(HitResult.Good);
|
||||||
countOk = Score.Statistics.GetOrDefault(HitResult.Ok);
|
countOk = Score.Statistics.GetValueOrDefault(HitResult.Ok);
|
||||||
countMeh = Score.Statistics.GetOrDefault(HitResult.Meh);
|
countMeh = Score.Statistics.GetValueOrDefault(HitResult.Meh);
|
||||||
countMiss = Score.Statistics.GetOrDefault(HitResult.Miss);
|
countMiss = Score.Statistics.GetValueOrDefault(HitResult.Miss);
|
||||||
|
|
||||||
IEnumerable<Mod> scoreIncreaseMods = Ruleset.GetModsFor(ModType.DifficultyIncrease);
|
IEnumerable<Mod> scoreIncreaseMods = Ruleset.GetModsFor(ModType.DifficultyIncrease);
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
@ -36,10 +35,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty
|
|||||||
mods = Score.Mods;
|
mods = Score.Mods;
|
||||||
accuracy = Score.Accuracy;
|
accuracy = Score.Accuracy;
|
||||||
scoreMaxCombo = Score.MaxCombo;
|
scoreMaxCombo = Score.MaxCombo;
|
||||||
countGreat = Score.Statistics.GetOrDefault(HitResult.Great);
|
countGreat = Score.Statistics.GetValueOrDefault(HitResult.Great);
|
||||||
countOk = Score.Statistics.GetOrDefault(HitResult.Ok);
|
countOk = Score.Statistics.GetValueOrDefault(HitResult.Ok);
|
||||||
countMeh = Score.Statistics.GetOrDefault(HitResult.Meh);
|
countMeh = Score.Statistics.GetValueOrDefault(HitResult.Meh);
|
||||||
countMiss = Score.Statistics.GetOrDefault(HitResult.Miss);
|
countMiss = Score.Statistics.GetValueOrDefault(HitResult.Miss);
|
||||||
|
|
||||||
// Custom multipliers for NoFail and SpunOut.
|
// Custom multipliers for NoFail and SpunOut.
|
||||||
double multiplier = 1.12; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
|
double multiplier = 1.12; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -31,10 +30,10 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
|
|||||||
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
|
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
|
||||||
{
|
{
|
||||||
mods = Score.Mods;
|
mods = Score.Mods;
|
||||||
countGreat = Score.Statistics.GetOrDefault(HitResult.Great);
|
countGreat = Score.Statistics.GetValueOrDefault(HitResult.Great);
|
||||||
countOk = Score.Statistics.GetOrDefault(HitResult.Ok);
|
countOk = Score.Statistics.GetValueOrDefault(HitResult.Ok);
|
||||||
countMeh = Score.Statistics.GetOrDefault(HitResult.Meh);
|
countMeh = Score.Statistics.GetValueOrDefault(HitResult.Meh);
|
||||||
countMiss = Score.Statistics.GetOrDefault(HitResult.Miss);
|
countMiss = Score.Statistics.GetValueOrDefault(HitResult.Miss);
|
||||||
|
|
||||||
// Custom multipliers for NoFail and SpunOut.
|
// Custom multipliers for NoFail and SpunOut.
|
||||||
double multiplier = 1.1; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
|
double multiplier = 1.1; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
|
||||||
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -146,7 +145,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
rollingMaxBaseScore += result.Judgement.MaxNumericResult;
|
rollingMaxBaseScore += result.Judgement.MaxNumericResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) + 1;
|
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) + 1;
|
||||||
|
|
||||||
hitEvents.Add(CreateHitEvent(result));
|
hitEvents.Add(CreateHitEvent(result));
|
||||||
lastHitObject = result.HitObject;
|
lastHitObject = result.HitObject;
|
||||||
@ -181,7 +180,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
rollingMaxBaseScore -= result.Judgement.MaxNumericResult;
|
rollingMaxBaseScore -= result.Judgement.MaxNumericResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) - 1;
|
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) - 1;
|
||||||
|
|
||||||
Debug.Assert(hitEvents.Count > 0);
|
Debug.Assert(hitEvents.Count > 0);
|
||||||
lastHitObject = hitEvents[^1].LastHitObject;
|
lastHitObject = hitEvents[^1].LastHitObject;
|
||||||
@ -272,8 +271,8 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
private double calculateComboRatio(int maxCombo) => maxAchievableCombo > 0 ? (double)maxCombo / maxAchievableCombo : 1;
|
private double calculateComboRatio(int maxCombo) => maxAchievableCombo > 0 ? (double)maxCombo / maxAchievableCombo : 1;
|
||||||
|
|
||||||
private double getBonusScore(Dictionary<HitResult, int> statistics)
|
private double getBonusScore(Dictionary<HitResult, int> statistics)
|
||||||
=> statistics.GetOrDefault(HitResult.SmallBonus) * Judgement.SMALL_BONUS_SCORE
|
=> statistics.GetValueOrDefault(HitResult.SmallBonus) * Judgement.SMALL_BONUS_SCORE
|
||||||
+ statistics.GetOrDefault(HitResult.LargeBonus) * Judgement.LARGE_BONUS_SCORE;
|
+ statistics.GetValueOrDefault(HitResult.LargeBonus) * Judgement.LARGE_BONUS_SCORE;
|
||||||
|
|
||||||
private ScoreRank rankFrom(double acc)
|
private ScoreRank rankFrom(double acc)
|
||||||
{
|
{
|
||||||
@ -291,7 +290,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
return ScoreRank.D;
|
return ScoreRank.D;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
|
public int GetStatistic(HitResult result) => scoreResultCounts.GetValueOrDefault(result);
|
||||||
|
|
||||||
public double GetStandardisedScore() => getScore(ScoringMode.Standardised);
|
public double GetStandardisedScore() => getScore(ScoringMode.Standardised);
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -209,13 +208,13 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
foreach (var r in Ruleset.CreateInstance().GetHitResults())
|
foreach (var r in Ruleset.CreateInstance().GetHitResults())
|
||||||
{
|
{
|
||||||
int value = Statistics.GetOrDefault(r.result);
|
int value = Statistics.GetValueOrDefault(r.result);
|
||||||
|
|
||||||
switch (r.result)
|
switch (r.result)
|
||||||
{
|
{
|
||||||
case HitResult.SmallTickHit:
|
case HitResult.SmallTickHit:
|
||||||
{
|
{
|
||||||
int total = value + Statistics.GetOrDefault(HitResult.SmallTickMiss);
|
int total = value + Statistics.GetValueOrDefault(HitResult.SmallTickMiss);
|
||||||
if (total > 0)
|
if (total > 0)
|
||||||
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
|
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
|
||||||
|
|
||||||
@ -224,7 +223,7 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
case HitResult.LargeTickHit:
|
case HitResult.LargeTickHit:
|
||||||
{
|
{
|
||||||
int total = value + Statistics.GetOrDefault(HitResult.LargeTickMiss);
|
int total = value + Statistics.GetValueOrDefault(HitResult.LargeTickMiss);
|
||||||
if (total > 0)
|
if (total > 0)
|
||||||
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
|
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ using System.Threading.Tasks;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -210,7 +209,7 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
// This is guaranteed to be a non-legacy score.
|
// This is guaranteed to be a non-legacy score.
|
||||||
// The combo must be determined through the score's statistics, as both the beatmap's max combo and the difficulty calculator will provide osu!stable combo values.
|
// The combo must be determined through the score's statistics, as both the beatmap's max combo and the difficulty calculator will provide osu!stable combo values.
|
||||||
beatmapMaxCombo = Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetOrDefault(r)).Sum();
|
beatmapMaxCombo = Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetValueOrDefault(r)).Sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateScore(beatmapMaxCombo, accuracy);
|
updateScore(beatmapMaxCombo, accuracy);
|
||||||
|
Loading…
Reference in New Issue
Block a user