Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace indexed skill access with skills.First(s is ...) #30034

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stanriders
Copy link
Member

Something that shouldve been done long ago

Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a code quality diffcalc change rather than just a diffcalc change, I'll bite.

I guess this is an improvement but I'm not sure this goes far enough? As in, if we're going to such lengths, then why not a custom thin wrapper data structure, e.g. your basic container?

public class SkillContainer
{
    private Dictionary<Type, object> skills;

    public Set<T>(T skill) => skills[typeof(T)] = skill;
    public Get<T>(T skill) => (T)skills[typeof(T)]!;
}

or something.

Heck, if it didn't fill incredibly gross to reuse it in this context, that's what DependencyContainer is.

@@ -40,7 +41,7 @@ protected override DifficultyAttributes CreateDifficultyAttributes(IBeatmap beat

CatchDifficultyAttributes attributes = new CatchDifficultyAttributes
{
StarRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier,
StarRating = Math.Sqrt(skills.First(s => s is Movement).DifficultyValue()) * difficulty_multiplier,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should really say .Single().

/// <summary>
/// Represents the Aim skill that does not include sliders length in it's calculation
/// </summary>
public class AimWithoutSliders : Aim
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this is... kinda weird? Why bother?

Why not expose WithSliders as public readonly on the skill, and then find it where you need it based on that flag alone? As in

skills.OfType<Aim>().SingleOrDefault(aim => aim.WithSliders)

or something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mostly for the tools, to be able to distinguish between two aim skills

@stanriders
Copy link
Member Author

I guess this is an improvement but I'm not sure this goes far enough? As in, if we're going to such lengths, then why not a custom thin wrapper data structure, e.g. your basic container?

I'm not sure if that's really necessery honestly, since all this tries to achieve is save someone from inevitabely shooting themselves in a foot by messing up indices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Pending Review
Development

Successfully merging this pull request may close these issues.

2 participants