Skip to content

Commit

Permalink
Merge pull request #11 from defvs/mods-addition
Browse files Browse the repository at this point in the history
Mods addition: "No Regen" and "Damage Multiplier"
  • Loading branch information
EVAST9919 authored Sep 20, 2022
2 parents c4fdf89 + 1d0feb9 commit d2f2801
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 5 deletions.
39 changes: 39 additions & 0 deletions osu.Game.Rulesets.Touhosu/Mods/TouhosuModDamageMultiplier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Touhosu.Scoring;

namespace osu.Game.Rulesets.Touhosu.Mods
{
public class TouhosuModDamageMultiplier : Mod, IApplicableToHealthProcessor
{
public override double ScoreMultiplier => 1.0;

public override string Name => "Damage Multiplier";
public override string Acronym => "DM";
public override IconUsage? Icon => OsuIcon.ModHardRock;
public override ModType Type => ModType.DifficultyIncrease;
public override LocalisableString Description => "Bullet hits hurt more!";
public override Type[] IncompatibleMods => new[] { typeof(ModEasy) };

public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{
((TouhosuHealthProcessor)healthProcessor).LossMultiplier = DamageMultiplier.Value;
}

[SettingSource("Damage increase", "Multiplier to damage taken when hitting a projectile")]
public BindableNumber<double> DamageMultiplier { get; } = new BindableDouble
{
MinValue = 1.1,
MaxValue = 5,
Default = 3,
Value = 3,
Precision = 0.1
};
}
}
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Touhosu/Mods/TouhosuModHidden.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using osu.Game.Rulesets.Touhosu.Objects.Drawables;
using osu.Framework.Localisation;
using osu.Game.Rulesets.Touhosu.Objects.Drawables;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Localisation;

namespace osu.Game.Rulesets.Touhosu.Mods
{
Expand Down
26 changes: 26 additions & 0 deletions osu.Game.Rulesets.Touhosu/Mods/TouhosuModNoRegen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Touhosu.Scoring;

namespace osu.Game.Rulesets.Touhosu.Mods
{
public class TouhosuModNoRegen : Mod, IApplicableToHealthProcessor
{
public override double ScoreMultiplier => 1.0;
public override string Name => "No Regen";
public override string Acronym => "NR";
public override IconUsage? Icon => OsuIcon.HeartBreak;
public override ModType Type => ModType.DifficultyIncrease;
public override LocalisableString Description => "No health regeneration.";
public override Type[] IncompatibleMods => new[] { typeof(ModEasy) };

public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{
((TouhosuHealthProcessor)healthProcessor).NoRegen = true;
}
}
}
4 changes: 3 additions & 1 deletion osu.Game.Rulesets.Touhosu/Mods/TouhosuModSuddenDeath.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using osu.Game.Rulesets.Mods;
using System;
using osu.Game.Rulesets.Mods;

namespace osu.Game.Rulesets.Touhosu.Mods
{
public class TouhosuModSuddenDeath : ModSuddenDeath
{
public override Type[] IncompatibleMods => new[] { typeof(TouhosuModNoRegen), typeof(TouhosuModDamageMultiplier) };
}
}
25 changes: 24 additions & 1 deletion osu.Game.Rulesets.Touhosu/Scoring/TouhosuHealthProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;

namespace osu.Game.Rulesets.Touhosu.Scoring
{
public class TouhosuHealthProcessor : HealthProcessor
{
public bool NoRegen { get; set; }

public double LossMultiplier { get; set; } = 1.0;

protected override double GetHealthIncreaseFor(JudgementResult result)
{
double adjustment = 1.0;

switch (result.Type)
{
case HitResult.Perfect:
if (NoRegen)
adjustment = 0;
break;

case HitResult.Miss:
adjustment *= LossMultiplier;
break;
}

return base.GetHealthIncreaseFor(result) * adjustment;
}
}
}
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Touhosu/TouhosuRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public override IEnumerable<Mod> GetModsFor(ModType type)
case ModType.DifficultyIncrease:
return new Mod[]
{
new TouhosuModDamageMultiplier(),
new TouhosuModNoRegen(),
new TouhosuModSuddenDeath(),
new MultiMod(new TouhosuModDoubleTime(), new TouhosuModNightcore()),
new TouhosuModHidden()
Expand Down
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Touhosu/UI/TouhosuPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Touhosu.Objects;
using osu.Game.Rulesets.Touhosu.Objects.Drawables;
using osu.Game.Rulesets.Touhosu.Extensions;

namespace osu.Game.Rulesets.Touhosu.UI
{
Expand Down

0 comments on commit d2f2801

Please sign in to comment.