3
3
*
4
4
* With other fields conflicting, the stageId will be different in three ways:
5
5
* 1. a001_ex04 / a001_ex04#f#
6
- * 2. ro1_e_1_1 / ro1_n_1_1
7
- * 3. act1bossrush_01 / act1bossrush_tm01
6
+ * 2. act1bossrush_01 / act1bossrush_tm01
7
+ * 3. ro1_e_1_1 / ro1_n_1_1
8
8
*
9
- * Normally, levels of the last two kinds will never be used in Copilot,
10
- * so we do not care about them and just remove them from the list.
9
+ * Only the first two kinds are supported in MAA Copilot.
11
10
*/
12
11
import { Level , OpDifficulty } from './operation'
13
12
14
13
const HARD_MODE_SUFFIX = '#f#'
14
+ const BOSSRUSH_NORMAL_INFIX = 'bossrush_'
15
+ const BOSSRUSH_HARD_INFIX = 'bossrush_tm'
15
16
16
17
const customLevelKey = '__customLevel'
17
18
@@ -34,16 +35,32 @@ export function isCustomLevel(level: Level): boolean {
34
35
}
35
36
36
37
export function isHardMode ( stageId : string ) {
37
- return stageId . endsWith ( HARD_MODE_SUFFIX )
38
+ return (
39
+ stageId . endsWith ( HARD_MODE_SUFFIX ) || stageId . includes ( BOSSRUSH_HARD_INFIX )
40
+ )
38
41
}
39
42
40
43
export function toHardMode ( stageId : string ) {
41
- return isHardMode ( stageId ) ? stageId : stageId + HARD_MODE_SUFFIX
44
+ if ( isHardMode ( stageId ) ) {
45
+ return stageId
46
+ }
47
+
48
+ const replacedStageId = stageId . replace (
49
+ BOSSRUSH_NORMAL_INFIX ,
50
+ BOSSRUSH_HARD_INFIX ,
51
+ )
52
+ if ( replacedStageId !== stageId ) {
53
+ return replacedStageId
54
+ }
55
+
56
+ return stageId + HARD_MODE_SUFFIX
42
57
}
43
58
44
59
export function toNormalMode ( stageId : string ) {
45
60
return isHardMode ( stageId )
46
- ? stageId . slice ( 0 , - HARD_MODE_SUFFIX . length )
61
+ ? stageId
62
+ . replace ( HARD_MODE_SUFFIX , '' )
63
+ . replace ( BOSSRUSH_HARD_INFIX , BOSSRUSH_NORMAL_INFIX )
47
64
: stageId
48
65
}
49
66
@@ -108,7 +125,9 @@ export function matchStageIdIgnoringDifficulty(id1: string, id2: string) {
108
125
return (
109
126
id1 === id2 ||
110
127
id1 === id2 + HARD_MODE_SUFFIX ||
111
- id1 + HARD_MODE_SUFFIX === id2
128
+ id1 + HARD_MODE_SUFFIX === id2 ||
129
+ id1 . replace ( BOSSRUSH_HARD_INFIX , BOSSRUSH_NORMAL_INFIX ) === id2 ||
130
+ id1 . replace ( BOSSRUSH_NORMAL_INFIX , BOSSRUSH_HARD_INFIX ) === id2
112
131
)
113
132
}
114
133
0 commit comments