-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marvin Schürz
committed
Jan 6, 2025
1 parent
5d925d3
commit 89c1843
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/common/src/verifier/checks/timing/CheckFirstLine.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { CheckMetadata } from '../../BeatmapCheck'; | ||
import type { Issue } from '../../Issue'; | ||
import type { VerifierBeatmap } from '../../VerifierBeatmap'; | ||
import { TimingPoint } from '../../../controlPoints/TimingPoint'; | ||
import { minBy } from '../../../utils/arrayUtils'; | ||
import { BeatmapCheck } from '../../BeatmapCheck'; | ||
import { IssueTemplate } from '../../template/IssueTemplate'; | ||
|
||
export class CheckFirstLine extends BeatmapCheck<any> { | ||
override get metadata(): CheckMetadata { | ||
return { | ||
category: 'Timing', | ||
message: 'First line toggles kiai or is inherited.', | ||
author: 'Naxess', | ||
}; | ||
} | ||
|
||
override templates = { | ||
inherited: new IssueTemplate('problem', '{0:timestamp} First timing line is inherited.', 'timestamp - ').withCause('The first timing line of a beatmap is inherited.'), | ||
togglesKiai: new IssueTemplate('problem', '{0:timestamp} First timing line toggles kiai.', 'timestamp - ').withCause('The first timing line of a beatmap has kiai enabled.'), | ||
noLines: new IssueTemplate('problem', 'There are no timing lines.').withCause('A beatmap has no timing lines.'), | ||
}; | ||
|
||
override async * getIssues(beatmap: VerifierBeatmap<any>): AsyncGenerator<Issue, void, undefined> { | ||
const firstTimingPoint = beatmap.controlPoints.timingPoints.first; | ||
if (!firstTimingPoint) { | ||
yield this.createIssue(this.templates.noLines, beatmap); | ||
return; | ||
} | ||
|
||
const firstControlPoint = minBy(beatmap.controlPoints.allControlPoints, it => it.time); | ||
|
||
if (!(firstControlPoint instanceof TimingPoint) && firstControlPoint.time < firstTimingPoint.time) | ||
yield this.createIssue(this.templates.inherited, beatmap, firstControlPoint.time); | ||
|
||
if (beatmap.controlPoints.effectPointAt(firstTimingPoint.time).kiaiMode) | ||
yield this.createIssue(this.templates.togglesKiai, beatmap, firstControlPoint.time); | ||
} | ||
} |