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

Add IMod and change ShortenedName to Acronym

This commit is contained in:
Dean Herbert 2018-11-30 17:16:00 +09:00
parent 84f3d4f48d
commit d97a15a504
41 changed files with 58 additions and 50 deletions

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public abstract class ManiaKeyMod : Mod, IApplicableToBeatmapConverter
{
public override string ShortenedName => Name;
public override string Acronym => Name;
public abstract int KeyCount { get; }
public override ModType Type => ModType.Conversion;
public override double ScoreMultiplier => 1; // TODO: Implement the mania key mod score multiplier

View File

@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mania.Mods
public class ManiaModDualStages : Mod, IPlayfieldTypeMod, IApplicableToBeatmapConverter, IApplicableToBeatmap<ManiaHitObject>
{
public override string Name => "Dual Stages";
public override string ShortenedName => "DS";
public override string Acronym => "DS";
public override string Description => @"Double the stages, double the fun!";
public override ModType Type => ModType.Conversion;
public override double ScoreMultiplier => 1;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mania.Mods
public class ManiaModFadeIn : Mod
{
public override string Name => "Fade In";
public override string ShortenedName => "FI";
public override string Acronym => "FI";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => @"Keys appear out of nowhere!";

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 1;
public override string Name => "One Key";
public override string ShortenedName => "1K";
public override string Acronym => "1K";
public override string Description => @"Play with one key.";
}
}

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 2;
public override string Name => "Two Keys";
public override string ShortenedName => "2K";
public override string Acronym => "2K";
public override string Description => @"Play with two keys.";
}
}

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 3;
public override string Name => "Three Keys";
public override string ShortenedName => "3K";
public override string Acronym => "3K";
public override string Description => @"Play with three keys.";
}
}

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 4;
public override string Name => "Four Keys";
public override string ShortenedName => "4K";
public override string Acronym => "4K";
public override string Description => @"Play with four keys.";
}
}

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 5;
public override string Name => "Five Keys";
public override string ShortenedName => "5K";
public override string Acronym => "5K";
public override string Description => @"Play with five keys.";
}
}

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 6;
public override string Name => "Six Keys";
public override string ShortenedName => "6K";
public override string Acronym => "6K";
public override string Description => @"Play with six keys.";
}
}

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 7;
public override string Name => "Seven Keys";
public override string ShortenedName => "7K";
public override string Acronym => "7K";
public override string Description => @"Play with seven keys.";
}
}

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 8;
public override string Name => "Eight Keys";
public override string ShortenedName => "8K";
public override string Acronym => "8K";
public override string Description => @"Play with eight keys.";
}
}

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public override int KeyCount => 9;
public override string Name => "Nine Keys";
public override string ShortenedName => "9K";
public override string Acronym => "9K";
public override string Description => @"Play with nine keys.";
}
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Mods
public class ManiaModMirror : Mod, IApplicableToRulesetContainer<ManiaHitObject>
{
public override string Name => "Mirror";
public override string ShortenedName => "MR";
public override string Acronym => "MR";
public override ModType Type => ModType.Conversion;
public override double ScoreMultiplier => 1;
public override bool Ranked => true;

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mania.Mods
public class ManiaModRandom : Mod, IApplicableToRulesetContainer<ManiaHitObject>
{
public override string Name => "Random";
public override string ShortenedName => "RD";
public override string Acronym => "RD";
public override ModType Type => ModType.Conversion;
public override FontAwesome Icon => FontAwesome.fa_osu_dice;
public override string Description => @"Shuffle around the keys!";

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public class OsuModAutopilot : Mod
{
public override string Name => "Autopilot";
public override string ShortenedName => "AP";
public override string Acronym => "AP";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_autopilot;
public override ModType Type => ModType.Automation;
public override string Description => @"Automatic cursor movement - just follow the rhythm.";

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public class OsuModSpunOut : Mod
{
public override string Name => "Spun Out";
public override string ShortenedName => "SO";
public override string Acronym => "SO";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_spunout;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => @"Spinners will be automatically completed.";

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public class OsuModTarget : Mod
{
public override string Name => "Target";
public override string ShortenedName => "TP";
public override string Acronym => "TP";
public override ModType Type => ModType.Conversion;
public override FontAwesome Icon => FontAwesome.fa_osu_mod_target;
public override string Description => @"Practice keeping up with the beat of the song.";

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Mods
internal class OsuModTransform : Mod, IApplicableToDrawableHitObjects
{
public override string Name => "Transform";
public override string ShortenedName => "TR";
public override string Acronym => "TR";
public override FontAwesome Icon => FontAwesome.fa_arrows;
public override ModType Type => ModType.Fun;
public override string Description => "Everything rotates. EVERYTHING.";

View File

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.Mods
internal class OsuModWiggle : Mod, IApplicableToDrawableHitObjects
{
public override string Name => "Wiggle";
public override string ShortenedName => "WG";
public override string Acronym => "WG";
public override FontAwesome Icon => FontAwesome.fa_certificate;
public override ModType Type => ModType.Fun;
public override string Description => "They just won't stay still...";

View File

@ -94,7 +94,7 @@ namespace osu.Game.Tests.NonVisual
private class ModA : Mod
{
public override string Name => nameof(ModA);
public override string ShortenedName => nameof(ModA);
public override string Acronym => nameof(ModA);
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(ModIncompatibleWithA), typeof(ModIncompatibleWithAAndB) };
@ -103,7 +103,7 @@ namespace osu.Game.Tests.NonVisual
private class ModB : Mod
{
public override string Name => nameof(ModB);
public override string ShortenedName => nameof(ModB);
public override string Acronym => nameof(ModB);
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(ModIncompatibleWithAAndB) };
@ -112,7 +112,7 @@ namespace osu.Game.Tests.NonVisual
private class ModIncompatibleWithA : Mod
{
public override string Name => $"Incompatible With {nameof(ModA)}";
public override string ShortenedName => $"Incompatible With {nameof(ModA)}";
public override string Acronym => $"Incompatible With {nameof(ModA)}";
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(ModA) };
@ -130,7 +130,7 @@ namespace osu.Game.Tests.NonVisual
private class ModIncompatibleWithAAndB : Mod
{
public override string Name => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
public override string ShortenedName => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
public override string Acronym => $"Incompatible With {nameof(ModA)} and {nameof(ModB)}";
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(ModA), typeof(ModB) };

View File

@ -187,7 +187,7 @@ namespace osu.Game.Tests.Visual
private static int importId;
private int getImportId() => ++importId;
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.ShortenedName))}", () => selectedMods.Value = mods);
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => selectedMods.Value = mods);
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));

View File

@ -120,7 +120,7 @@ namespace osu.Game.Online.API.Requests.Responses
base.Ruleset = value;
// Evaluate the mod string
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.Acronym)).ToArray();
}
}
}

View File

@ -0,0 +1,10 @@
namespace osu.Game.Rulesets.Mods
{
public interface IMod
{
/// <summary>
/// The shortened name of this mod.
/// </summary>
string Acronym { get; }
}
}

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mods
/// <summary>
/// The base class for gameplay modifiers.
/// </summary>
public abstract class Mod : IJsonSerializable
public abstract class Mod : IMod, IJsonSerializable
{
/// <summary>
/// The name of this mod.
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mods
/// <summary>
/// The shortened name of this mod.
/// </summary>
public abstract string ShortenedName { get; }
public abstract string Acronym { get; }
/// <summary>
/// The icon of this mod.

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModAutoplay : Mod, IApplicableFailOverride
{
public override string Name => "Autoplay";
public override string ShortenedName => "AT";
public override string Acronym => "AT";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_auto;
public override ModType Type => ModType.Automation;
public override string Description => "Watch a perfect automated play through the song.";

View File

@ -8,7 +8,7 @@ namespace osu.Game.Rulesets.Mods
public class ModCinema : ModAutoplay
{
public override string Name => "Cinema";
public override string ShortenedName => "CN";
public override string Acronym => "CN";
public override bool HasImplementation => false;
public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema;
public override string Description => "Watch the video without visual distractions.";

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModDaycore : ModHalfTime
{
public override string Name => "Daycore";
public override string ShortenedName => "DC";
public override string Acronym => "DC";
public override FontAwesome Icon => FontAwesome.fa_question;
public override string Description => "Whoaaaaa...";

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModDoubleTime : Mod, IApplicableToClock
{
public override string Name => "Double Time";
public override string ShortenedName => "DT";
public override string Acronym => "DT";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_doubletime;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Zoooooooooom...";

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModEasy : Mod, IApplicableToDifficulty
{
public override string Name => "Easy";
public override string ShortenedName => "EZ";
public override string Acronym => "EZ";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_easy;
public override ModType Type => ModType.DifficultyReduction;
public override double ScoreMultiplier => 0.5;

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModFlashlight : Mod
{
public override string Name => "Flashlight";
public override string ShortenedName => "FL";
public override string Acronym => "FL";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_flashlight;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Restricted view area.";

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModHalfTime : Mod, IApplicableToClock
{
public override string Name => "Half Time";
public override string ShortenedName => "HT";
public override string Acronym => "HT";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_halftime;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => "Less zoom...";

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModHardRock : Mod, IApplicableToDifficulty
{
public override string Name => "Hard Rock";
public override string ShortenedName => "HR";
public override string Acronym => "HR";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hardrock;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Everything just got a bit harder...";

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModHidden : Mod, IReadFromConfig, IApplicableToDrawableHitObjects
{
public override string Name => "Hidden";
public override string ShortenedName => "HD";
public override string Acronym => "HD";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_hidden;
public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => true;

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModNightcore : ModDoubleTime
{
public override string Name => "Nightcore";
public override string ShortenedName => "NC";
public override string Acronym => "NC";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_nightcore;
public override string Description => "Uguuuuuuuu...";

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModNoFail : Mod, IApplicableFailOverride
{
public override string Name => "No Fail";
public override string ShortenedName => "NF";
public override string Acronym => "NF";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_nofail;
public override ModType Type => ModType.DifficultyReduction;
public override string Description => "You can't fail, no matter what.";

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModPerfect : ModSuddenDeath
{
public override string Name => "Perfect";
public override string ShortenedName => "PF";
public override string Acronym => "PF";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_perfect;
public override string Description => "SS or quit.";

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModRelax : Mod
{
public override string Name => "Relax";
public override string ShortenedName => "RX";
public override string Acronym => "RX";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_relax;
public override ModType Type => ModType.Automation;
public override double ScoreMultiplier => 1;

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModSuddenDeath : Mod, IApplicableToScoreProcessor
{
public override string Name => "Sudden Death";
public override string ShortenedName => "SD";
public override string Acronym => "SD";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_suddendeath;
public override ModType Type => ModType.DifficultyIncrease;
public override string Description => "Miss and fail.";

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mods
public class MultiMod : Mod
{
public override string Name => string.Empty;
public override string ShortenedName => string.Empty;
public override string Acronym => string.Empty;
public override string Description => string.Empty;
public override double ScoreMultiplier => 0;

View File

@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Mods
public sealed class NoModMod : Mod
{
public override string Name => "No Mod";
public override string ShortenedName => "NM";
public override string Acronym => "NM";
public override double ScoreMultiplier => 1;
}
}

View File

@ -53,19 +53,19 @@ namespace osu.Game.Scoring
}
set
{
modsJson = null;
mods = value;
ModsJson = null;
}
}
private Mod[] getModsFromRuleset(DeserializedMod[] mods) => Ruleset.CreateInstance().GetAllMods().Where(mod => mods.Any(d => d.ShortenedName == mod.ShortenedName)).ToArray();
private Mod[] getModsFromRuleset(DeserializedMod[] mods) => Ruleset.CreateInstance().GetAllMods().Where(mod => mods.Any(d => d.Acronym == mod.Acronym)).ToArray();
private string modsJson;
[Column("Mods")]
public string ModsJson
{
get => modsJson ?? JsonConvert.SerializeObject(Mods);
get => modsJson ?? (modsJson = JsonConvert.SerializeObject(mods));
set
{
modsJson = value;
@ -121,11 +121,9 @@ namespace osu.Game.Scoring
public bool DeletePending { get; set; }
[Serializable]
protected class DeserializedMod : Mod
protected class DeserializedMod : IMod
{
public override string Name { get; } = string.Empty;
public override string ShortenedName { get; } = string.Empty;
public override double ScoreMultiplier { get; } = 0;
public string Acronym { get; set; }
}
}
}