-
Notifications
You must be signed in to change notification settings - Fork 2
/
AlternatingMonoPattern.ts
50 lines (44 loc) · 1.71 KB
/
AlternatingMonoPattern.ts
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
import { TaikoDifficultyHitObject } from '../../TaikoDifficultyHitObject';
import { MonoStreak } from './MonoStreak';
import { RepeatingHitPatterns } from './RepeatingHitPatterns';
/**
* Encodes a list of {@link MonoStreak}s. {@link MonoStreak}s with the same
* {@link MonoStreak.runLength} are grouped together.
*/
export class AlternatingMonoPattern {
/**
* {@link MonoStreak}s that are grouped together within this {@link AlternatingMonoPattern}.
*/
readonly monoStreaks: MonoStreak[] = [];
/**
* The parent {@link RepeatingHitPatterns} that contains this {@link AlternatingMonoPattern}
*/
declare parent: RepeatingHitPatterns;
/**
* Index of this {@link AlternatingMonoPattern} within it's parent {@link RepeatingHitPatterns}
*/
index = 0;
/**
* The first {@link TaikoDifficultyHitObject} in this {@link AlternatingMonoPattern}.
*/
get firstHitObject(): TaikoDifficultyHitObject {
return this.monoStreaks[0].firstHitObject;
}
/**
* Determine if this {@link AlternatingMonoPattern} is a repetition
* of another {@link AlternatingMonoPattern}. This is a strict comparison
* and is true if and only if the colour sequence is exactly the same.
*/
isRepetitionOf(other: AlternatingMonoPattern): boolean {
return this.hasIdenticalMonoLength(other) &&
other.monoStreaks.length === this.monoStreaks.length &&
other.monoStreaks[0].isRim === this.monoStreaks[0].isRim;
}
/**
* Determine if this {@link AlternatingMonoPattern} has the same
* mono length of another {@link AlternatingMonoPattern}.
*/
hasIdenticalMonoLength(other: AlternatingMonoPattern): boolean {
return other.monoStreaks[0].runLength === this.monoStreaks[0].runLength;
}
}