mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Fix mod using reference equality unless casted to IMod
This commit is contained in:
parent
6849eabf2c
commit
43f8f3638a
@ -13,7 +13,7 @@ using osu.Game.Rulesets.Mods;
|
|||||||
|
|
||||||
namespace osu.Game.Online.API
|
namespace osu.Game.Online.API
|
||||||
{
|
{
|
||||||
public class APIMod : IMod
|
public class APIMod : IMod, IEquatable<APIMod>
|
||||||
{
|
{
|
||||||
[JsonProperty("acronym")]
|
[JsonProperty("acronym")]
|
||||||
public string Acronym { get; set; }
|
public string Acronym { get; set; }
|
||||||
@ -52,7 +52,7 @@ namespace osu.Game.Online.API
|
|||||||
return resultMod;
|
return resultMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(IMod other) => Acronym == other?.Acronym;
|
public bool Equals(APIMod other) => Acronym == other?.Acronym;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
// 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 : IEquatable<IMod>
|
public interface IMod
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The shortened name of this mod.
|
/// The shortened name of this mod.
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
/// The base class for gameplay modifiers.
|
/// The base class for gameplay modifiers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
public abstract class Mod : IMod, IJsonSerializable
|
public abstract class Mod : IMod, IEquatable<Mod>, IJsonSerializable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of this mod.
|
/// The name of this mod.
|
||||||
@ -149,6 +149,6 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(IMod other) => GetType() == other?.GetType();
|
public bool Equals(Mod other) => GetType() == other?.GetType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,11 +252,11 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
protected class DeserializedMod : IMod
|
protected class DeserializedMod : IMod, IEquatable<DeserializedMod>
|
||||||
{
|
{
|
||||||
public string Acronym { get; set; }
|
public string Acronym { get; set; }
|
||||||
|
|
||||||
public bool Equals(IMod other) => Acronym == other?.Acronym;
|
public bool Equals(DeserializedMod other) => Acronym == other?.Acronym;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{User} playing {Beatmap}";
|
public override string ToString() => $"{User} playing {Beatmap}";
|
||||||
|
Loading…
Reference in New Issue
Block a user