1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 11:23:00 +08:00

Fix mod using reference equality unless casted to IMod

This commit is contained in:
Salman Ahmed 2020-12-27 02:42:13 +03:00
parent 6849eabf2c
commit 43f8f3638a
4 changed files with 7 additions and 8 deletions

View File

@ -13,7 +13,7 @@ using osu.Game.Rulesets.Mods;
namespace osu.Game.Online.API
{
public class APIMod : IMod
public class APIMod : IMod, IEquatable<APIMod>
{
[JsonProperty("acronym")]
public string Acronym { get; set; }
@ -52,7 +52,7 @@ namespace osu.Game.Online.API
return resultMod;
}
public bool Equals(IMod other) => Acronym == other?.Acronym;
public bool Equals(APIMod other) => Acronym == other?.Acronym;
public override string ToString()
{

View File

@ -1,12 +1,11 @@
// 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.
using System;
using Newtonsoft.Json;
namespace osu.Game.Rulesets.Mods
{
public interface IMod : IEquatable<IMod>
public interface IMod
{
/// <summary>
/// The shortened name of this mod.

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mods
/// The base class for gameplay modifiers.
/// </summary>
[ExcludeFromDynamicCompile]
public abstract class Mod : IMod, IJsonSerializable
public abstract class Mod : IMod, IEquatable<Mod>, IJsonSerializable
{
/// <summary>
/// The name of this mod.
@ -149,6 +149,6 @@ namespace osu.Game.Rulesets.Mods
return copy;
}
public bool Equals(IMod other) => GetType() == other?.GetType();
public bool Equals(Mod other) => GetType() == other?.GetType();
}
}

View File

@ -252,11 +252,11 @@ namespace osu.Game.Scoring
}
[Serializable]
protected class DeserializedMod : IMod
protected class DeserializedMod : IMod, IEquatable<DeserializedMod>
{
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}";