Skip to content

Commit 719cd19

Browse files
committed
feat: hide hard mode bossrush levels
1 parent 47439c2 commit 719cd19

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

src/models/level.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
*
44
* With other fields conflicting, the stageId will be different in three ways:
55
* 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
88
*
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.
1110
*/
1211
import { Level, OpDifficulty } from './operation'
1312

1413
const HARD_MODE_SUFFIX = '#f#'
14+
const BOSSRUSH_NORMAL_INFIX = 'bossrush_'
15+
const BOSSRUSH_HARD_INFIX = 'bossrush_tm'
1516

1617
const customLevelKey = '__customLevel'
1718

@@ -34,16 +35,32 @@ export function isCustomLevel(level: Level): boolean {
3435
}
3536

3637
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+
)
3841
}
3942

4043
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
4257
}
4358

4459
export function toNormalMode(stageId: string) {
4560
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)
4764
: stageId
4865
}
4966

@@ -108,7 +125,9 @@ export function matchStageIdIgnoringDifficulty(id1: string, id2: string) {
108125
return (
109126
id1 === id2 ||
110127
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
112131
)
113132
}
114133

0 commit comments

Comments
 (0)