Skip to content

Commit

Permalink
Merge branch 'simulate-parameter-handling' into mod-options-parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
minisbett committed Oct 18, 2024
2 parents 4ae649d + 2269f1b commit 3d040c4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions PerformanceCalculator/Simulate/CatchSimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class CatchSimulateCommand : SimulateCommand

[UsedImplicitly]
[Option(Template = "-T|--tiny-droplets <tinys>", Description = "Number of tiny droplets hit. Will override accuracy if used. Otherwise is automatically calculated.")]
public override int? Mehs { get; set; }
public override int? Mehs { get; }

[UsedImplicitly]
[Option(Template = "-D|--droplets <droplets>", Description = "Number of droplets hit. Will override accuracy if used. Otherwise is automatically calculated.")]
public override int? Goods { get; set; }
public override int? Goods { get; }

public override Ruleset Ruleset => new CatchRuleset();

Expand Down
24 changes: 12 additions & 12 deletions PerformanceCalculator/Simulate/ManiaSimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ public class ManiaSimulateCommand : SimulateCommand
{
[UsedImplicitly]
[Option(Template = "-M|--mehs <mehs>", Description = "Number of mehs. Will override accuracy if used. Otherwise is automatically calculated.")]
public override int? Mehs { get; set; }
public override int? Mehs { get; }

[UsedImplicitly]
[Option(Template = "-G|--goods <goods>", Description = "Number of goods. Will override accuracy if used. Otherwise is automatically calculated.")]
public override int? Goods { get; set; }
public override int? Goods { get; }

[UsedImplicitly]
[Option(Template = "-O|--oks <oks>", Description = "Number of oks. Will override accuracy if used. Otherwise is automatically calculated.")]
private int? oks { get; set; }
private int? oks { get; }

[UsedImplicitly]
[Option(Template = "-T|--greats <greats>", Description = "Number of greats. Will override accuracy if used. Otherwise is automatically calculated.")]
private int? greats { get; set; }
private int? greats { get; }

public override Ruleset Ruleset => new ManiaRuleset();

Expand Down Expand Up @@ -68,28 +68,28 @@ protected override Dictionary<HitResult, int> GenerateHitResults(double accuracy
// Each great and perfect increases total by 5 (great-meh=5)
// There is no difference in accuracy between them, so just halve arbitrarily (favouring perfects for an odd number).
int greatsAndPerfects = Math.Min(delta / 5, remainingHits);
greats = greatsAndPerfects / 2;
int perfects = greatsAndPerfects - greats.Value;
delta -= (greats.Value + perfects) * 5;
remainingHits -= greats.Value + perfects;
int countGreat = greatsAndPerfects / 2;
int perfects = greatsAndPerfects - countGreat;
delta -= (countGreat + perfects) * 5;
remainingHits -= countGreat + perfects;

// Each good increases total by 3 (good-meh=3).
countGood = Math.Min(delta / 3, remainingHits);
delta -= countGood.Value * 3;
remainingHits -= countGood.Value;

// Each ok increases total by 1 (ok-meh=1).
oks = delta;
remainingHits -= oks.Value;
int countOk = delta;
remainingHits -= countOk;

// Everything else is a meh, as initially assumed.
countMeh = remainingHits;

return new Dictionary<HitResult, int>
{
{ HitResult.Perfect, perfects },
{ HitResult.Great, greats.Value },
{ HitResult.Ok, oks.Value },
{ HitResult.Great, countGreat },
{ HitResult.Ok, countOk },
{ HitResult.Good, countGood.Value },
{ HitResult.Meh, countMeh.Value },
{ HitResult.Miss, countMiss }
Expand Down
4 changes: 2 additions & 2 deletions PerformanceCalculator/Simulate/OsuSimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public class OsuSimulateCommand : SimulateCommand
{
[UsedImplicitly]
[Option(Template = "-M|--mehs <mehs>", Description = "Number of mehs. Will override accuracy if used. Otherwise is automatically calculated.")]
public override int? Mehs { get; set; }
public override int? Mehs { get; }

[UsedImplicitly]
[Option(Template = "-G|--goods <goods>", Description = "Number of goods. Will override accuracy if used. Otherwise is automatically calculated.")]
public override int? Goods { get; set; }
public override int? Goods { get; }

[UsedImplicitly]
[Option(Template = "-c|--combo <combo>", Description = "Maximum combo during play. Defaults to beatmap maximum.")]
Expand Down
12 changes: 6 additions & 6 deletions PerformanceCalculator/Simulate/SimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public abstract class SimulateCommand : ProcessorCommand
[UsedImplicitly]
[Required]
[Argument(0, Name = "beatmap", Description = "Required. Can be either a path to beatmap file (.osu) or beatmap ID.")]
public string Beatmap { get; set; }
public string Beatmap { get; }

[UsedImplicitly]
[Option(Template = "-a|--accuracy <accuracy>", Description = "Accuracy. Enter as decimal 0-100. Defaults to 100. Scales hit results as well and is rounded to the nearest possible value for the beatmap.")]
public double Accuracy { get; set; } = 100;
public double Accuracy { get; } = 100;

[UsedImplicitly]
[Option(CommandOptionType.MultipleValue, Template = "-m|--mod <mod>", Description = "One for each mod. The mods to compute the performance with. Values: hr, dt, hd, fl, etc...")]
public string[] Mods { get; set; }
public string[] Mods { get; }

[UsedImplicitly]
[Option(CommandOptionType.MultipleValue, Template = "-o|--mod-option <option>",
Expand All @@ -40,7 +40,7 @@ public abstract class SimulateCommand : ProcessorCommand

[UsedImplicitly]
[Option(Template = "-X|--misses <misses>", Description = "Number of misses. Defaults to 0.")]
public int Misses { get; set; }
public int Misses { get; }

//
// Options implemented in the ruleset-specific commands
Expand All @@ -49,10 +49,10 @@ public abstract class SimulateCommand : ProcessorCommand
// -> Taiko does not have Mehs
//
[UsedImplicitly]
public virtual int? Mehs { get; set; }
public virtual int? Mehs { get; }

[UsedImplicitly]
public virtual int? Goods { get; set; }
public virtual int? Goods { get; }

[UsedImplicitly]
public virtual int? Combo { get; }
Expand Down
2 changes: 1 addition & 1 deletion PerformanceCalculator/Simulate/TaikoSimulateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TaikoSimulateCommand : SimulateCommand
{
[UsedImplicitly]
[Option(Template = "-G|--goods <goods>", Description = "Number of goods. Will override accuracy if used. Otherwise is automatically calculated.")]
public override int? Goods { get; set; }
public override int? Goods { get; }

[UsedImplicitly]
[Option(Template = "-c|--combo <combo>", Description = "Maximum combo during play. Defaults to beatmap maximum.")]
Expand Down

0 comments on commit 3d040c4

Please sign in to comment.