From 0c95459f3192834117743c6439097183c36f79f4 Mon Sep 17 00:00:00 2001 From: Carlos Pinto Date: Thu, 3 Nov 2022 21:15:24 +0000 Subject: [PATCH] add trustworthy mod --- .../Beatmaps/HishigataBeatmapConverter.cs | 9 ++++++- .../HishigataRuleset.cs | 6 +++++ .../Mods/HishigataModTrustworthyStrings.cs | 16 +++++++++++ .../Mods/HishigataModTrustworthy.cs | 27 +++++++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Rulesets.Hishigata/Localisation/Mods/HishigataModTrustworthyStrings.cs create mode 100644 osu.Game.Rulesets.Hishigata/Mods/HishigataModTrustworthy.cs diff --git a/osu.Game.Rulesets.Hishigata/Beatmaps/HishigataBeatmapConverter.cs b/osu.Game.Rulesets.Hishigata/Beatmaps/HishigataBeatmapConverter.cs index 262e17c..cfb16ee 100644 --- a/osu.Game.Rulesets.Hishigata/Beatmaps/HishigataBeatmapConverter.cs +++ b/osu.Game.Rulesets.Hishigata/Beatmaps/HishigataBeatmapConverter.cs @@ -24,6 +24,9 @@ public HishigataBeatmapConverter(IBeatmap beatmap, Ruleset ruleset) // https://github.com/ppy/osu/tree/master/osu.Game/Rulesets/Objects/Types public override bool CanConvert() => Beatmap.HitObjects.All(x => x is IHasPosition); + // trustworthy mod + public bool FeignsAllowed { get; set; } = true; + protected override IEnumerable ConvertHitObject(HitObject original, IBeatmap beatmap, CancellationToken cancellationToken) { var difficulty = beatmap.BeatmapInfo.Difficulty; @@ -34,7 +37,11 @@ protected override IEnumerable ConvertHitObject(HitObject or float angle = getHitObjectAngle(position) / 90; int lane = (int)Math.Round(angle); - bool isFeign = original.Samples.Any(x => x.Name == HitSampleInfo.HIT_WHISTLE); + bool isFeign = false; + if (FeignsAllowed) + { + isFeign = original.Samples.Any(x => x.Name == HitSampleInfo.HIT_WHISTLE); + } if (lane >= 4) lane -= 4; switch (original) diff --git a/osu.Game.Rulesets.Hishigata/HishigataRuleset.cs b/osu.Game.Rulesets.Hishigata/HishigataRuleset.cs index 2f0407f..24b28a5 100644 --- a/osu.Game.Rulesets.Hishigata/HishigataRuleset.cs +++ b/osu.Game.Rulesets.Hishigata/HishigataRuleset.cs @@ -64,6 +64,12 @@ public override IEnumerable GetModsFor(ModType type) new HishigataModAutoplay(), }; + case ModType.Conversion: + return new Mod[] + { + new HishigataModTrustworthy(), + }; + case ModType.Fun: return new Mod[] { diff --git a/osu.Game.Rulesets.Hishigata/Localisation/Mods/HishigataModTrustworthyStrings.cs b/osu.Game.Rulesets.Hishigata/Localisation/Mods/HishigataModTrustworthyStrings.cs new file mode 100644 index 0000000..b2388c8 --- /dev/null +++ b/osu.Game.Rulesets.Hishigata/Localisation/Mods/HishigataModTrustworthyStrings.cs @@ -0,0 +1,16 @@ +using osu.Framework.Localisation; + +namespace osu.Game.Rulesets.Hishigata.Localisation.Mods +{ + public static class HishigataModTrustworthyStrings + { + private const string prefix = @"osu.Game.Rulesets.Hishigata.Resources.Localisation.Mods.HishigataModTrustworthyStrings"; + + /// + /// "Notes don't switch sides." + /// + public static LocalisableString ModDescription => new TranslatableString(getKey(@"mod_description"), @"Notes don't switch sides."); + + private static string getKey(string key) => $"{prefix}:{key}"; + } +} diff --git a/osu.Game.Rulesets.Hishigata/Mods/HishigataModTrustworthy.cs b/osu.Game.Rulesets.Hishigata/Mods/HishigataModTrustworthy.cs new file mode 100644 index 0000000..053544b --- /dev/null +++ b/osu.Game.Rulesets.Hishigata/Mods/HishigataModTrustworthy.cs @@ -0,0 +1,27 @@ +using osu.Framework.Graphics.Sprites; +using osu.Framework.Localisation; +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Hishigata.Localisation.Mods; +using osu.Game.Rulesets.Hishigata.Beatmaps; +using osu.Game.Rulesets.Mods; + +namespace osu.Game.Rulesets.Hishigata.Mods +{ + public class HishigataModTrustworthy : Mod, IApplicableToBeatmapConverter + { + public override string Name => "Trustworthy"; + public override string Acronym => "TW"; + public override LocalisableString Description => HishigataModTrustworthyStrings.ModDescription; + public override double ScoreMultiplier => 0.8; + public override ModType Type => ModType.Conversion; + //public override bool UserPlayable => true; + public override IconUsage? Icon => FontAwesome.Solid.Check; + //public override bool HasImplementation => true; + + public void ApplyToBeatmapConverter(IBeatmapConverter beatmapConverter) + { + var converter = (HishigataBeatmapConverter)beatmapConverter; + converter.FeignsAllowed = false; + } + } +}