mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 20:12:57 +08:00
Fix mod equality checks not working as intended
This commit is contained in:
parent
bd0704c575
commit
6bdaca1e3b
@ -8,5 +8,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
public class APIMod : IMod
|
public class APIMod : IMod
|
||||||
{
|
{
|
||||||
public string Acronym { get; set; }
|
public string Acronym { get; set; }
|
||||||
|
|
||||||
|
public bool Equals(IMod other) => Acronym == other?.Acronym;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public interface IMod
|
public interface IMod : IEquatable<IMod>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The shortened name of this mod.
|
/// The shortened name of this mod.
|
||||||
|
@ -70,5 +70,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
|
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Mod CreateCopy() => (Mod)Activator.CreateInstance(GetType());
|
public virtual Mod CreateCopy() => (Mod)Activator.CreateInstance(GetType());
|
||||||
|
|
||||||
|
public bool Equals(IMod other) => GetType() == other?.GetType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,6 +177,8 @@ namespace osu.Game.Scoring
|
|||||||
protected class DeserializedMod : IMod
|
protected class DeserializedMod : IMod
|
||||||
{
|
{
|
||||||
public string Acronym { get; set; }
|
public string Acronym { get; set; }
|
||||||
|
|
||||||
|
public bool Equals(IMod other) => Acronym == other?.Acronym;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{User} playing {Beatmap}";
|
public override string ToString() => $"{User} playing {Beatmap}";
|
||||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Screens.Multi.Play
|
|||||||
if (ruleset.Value.ID != playlistItem.Ruleset.ID)
|
if (ruleset.Value.ID != playlistItem.Ruleset.ID)
|
||||||
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
|
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
|
||||||
|
|
||||||
if (!playlistItem.RequiredMods.All(m => Mods.Value.Contains(m)))
|
if (!playlistItem.RequiredMods.All(m => Mods.Value.Any(m.Equals)))
|
||||||
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
||||||
|
|
||||||
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);
|
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);
|
||||||
|
Loading…
Reference in New Issue
Block a user