Skip to content

Commit

Permalink
add adjustable range limit for keymodes
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Dec 16, 2024
1 parent 6a00561 commit 23c9d24
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions fluXis.Game/Map/MapInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace fluXis.Game.Map;

public class MapInfo
{
public static int MinKeymode { get; set; } = 1;
public static int MaxKeymode { get; set; } = -1; // allow anything

public string AudioFile { get; set; } = string.Empty;
public string BackgroundFile { get; set; } = string.Empty;
public string CoverFile { get; set; } = string.Empty;
Expand Down Expand Up @@ -121,34 +124,43 @@ public bool Validate(out string issue)
{
if (HitObjects.Count == 0)
{
issue = "Map has no hit objects";
issue = "Map has no hit objects.";
return false;
}

if (TimingPoints.Count == 0)
{
issue = "Map has no timing points";
issue = "Map has no timing points.";
return false;
}

foreach (var timingPoint in TimingPoints)
{
if (timingPoint.BPM <= 0)
{
issue = "A timing point has an invalid BPM";
issue = "A timing point has an invalid BPM.";
return false;
}

if (timingPoint.Signature <= 0)
{
issue = "A timing point has an invalid signature";
issue = "A timing point has an invalid signature.";
return false;
}
}

if (HitObjects.Any(hitObject => hitObject.Lane < 1))
{
issue = "Map has an invalid key count";
issue = "A hit object in this map is in a lane below 1.";
return false;
}

var min = HitObjects.MinBy(x => x.Lane).Lane;
var max = HitObjects.MaxBy(x => x.Lane).Lane;

if (min < MinKeymode || (MaxKeymode > 0 && max > MaxKeymode))
{
issue = "Map has an invalid keymode.";
return false;
}

Expand Down

0 comments on commit 23c9d24

Please sign in to comment.