-
Notifications
You must be signed in to change notification settings - Fork 3
/
LastNoteHidingBarlineCheck.cs
102 lines (89 loc) · 3.28 KB
/
LastNoteHidingBarlineCheck.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System.Collections.Generic;
using System.Linq;
using MapsetParser.objects;
using MapsetParser.objects.hitobjects;
using MapsetParser.statics;
using MapsetVerifierFramework.objects;
using MapsetVerifierFramework.objects.attributes;
using MapsetVerifierFramework.objects.metadata;
using MVTaikoChecks.Utils;
using static MVTaikoChecks.Aliases.Mode;
using static MVTaikoChecks.Aliases.Level;
namespace MVTaikoChecks.Checks.Compose
{
[Check]
public class LastNoteHidingBarlineCheck : BeatmapCheck
{
private const string _MINOR = nameof(_MINOR);
private const string _PROBLEM = nameof(_PROBLEM);
public override CheckMetadata GetMetadata() =>
new BeatmapCheckMetadata()
{
Author = "Nostril",
Category = "Compose",
Message = "Unsnapped last note hiding barline",
Modes = new Beatmap.Mode[] { MODE_TAIKO },
Documentation = new Dictionary<string, string>()
{
{
"Purpose",
@"
Check if the last object in the beatmap is not 1ms earlier than a barline."
},
{
"Reasoning",
@"
This causes the last barline in the map to not be rendered."
}
}
};
public override Dictionary<string, IssueTemplate> GetTemplates() =>
new Dictionary<string, IssueTemplate>()
{
{
_MINOR,
new IssueTemplate(
LEVEL_MINOR,
"{0} Last spinner/slider end in the map is hiding its barline, due to being unsnapped 1ms early",
"timestamp - "
).WithCause("The spinner/slider end is unsnapped 1ms early.")
},
{
_PROBLEM,
new IssueTemplate(
LEVEL_PROBLEM,
"{0} Last note in the map is hiding its barline, due to being unsnapped 1ms early",
"timestamp - "
).WithCause("The note is unsnapped 1ms early.")
}
};
public override IEnumerable<Issue> GetIssues(Beatmap beatmap)
{
if (beatmap.hitObjects.Count == 0)
{
yield break;
}
var lastObject = beatmap.hitObjects.Last();
var unsnapFromLastBarline = lastObject.GetTailOffsetFromNextBarlineMs();
if (unsnapFromLastBarline > -2.0 && unsnapFromLastBarline <= -1.0)
{
if (lastObject is Circle)
{
yield return new Issue(
GetTemplate(_PROBLEM),
beatmap,
Timestamp.Get(lastObject.GetEndTime())
);
}
else
{
yield return new Issue(
GetTemplate(_MINOR),
beatmap,
Timestamp.Get(lastObject.GetEndTime())
);
}
}
}
}
}