Skip to content

Commit 1b5d093

Browse files
authored
Merge branch 'dev' into feat/sortByRarity
2 parents 13238e5 + 053840b commit 1b5d093

File tree

10 files changed

+58
-19
lines changed

10 files changed

+58
-19
lines changed
47.4 KB
Loading
34.4 KB
Loading
38.2 KB
Loading
43.7 KB
Loading
16.6 KB
Loading

src/apis/arknights.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ export const useLevels = ({ suspense }: { suspense?: boolean } = {}) => {
2929

3030
res.data = res.data.filter((level) => {
3131
if (
32-
// 引航者试炼
33-
level.levelId.includes('bossrush') ||
3432
// 肉鸽
3533
level.levelId.includes('roguelike') ||
3634
// 保全派驻

src/components/editor/NumericInput2.tsx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
NumericInput,
44
NumericInputProps,
55
} from '@blueprintjs/core'
6+
import { useRef, useState } from 'react'
67

78
type MixedNumericInputProps = HTMLInputProps & NumericInputProps
89

@@ -13,20 +14,34 @@ export interface NumericInput2Props extends MixedNumericInputProps {
1314
export const NumericInput2 = ({
1415
intOnly,
1516
min,
17+
minorStepSize,
18+
value,
1619
onValueChange,
1720
...props
1821
}: NumericInput2Props) => {
1922
const allowNegative = min === undefined || min < 0
2023

24+
const inputRef = useRef<HTMLInputElement>(null)
25+
const [endsWithDot, setEndsWithDot] = useState(false)
26+
27+
if (minorStepSize && minorStepSize < 0.001) {
28+
// not yet fixed in current version: https://github.com/palantir/blueprint/issues/4497
29+
process.env.NODE_ENV === 'development' &&
30+
console.warn('minorStepSize cannot be smaller than 0.001')
31+
32+
minorStepSize = 0.001
33+
}
34+
2135
return (
2236
<NumericInput
2337
allowNumericCharactersOnly
2438
min={min}
39+
minorStepSize={minorStepSize}
40+
inputRef={inputRef}
41+
value={endsWithDot ? value + '.' : value}
42+
onBlur={() => setEndsWithDot(false)}
43+
onButtonClick={(num, str) => onValueChange?.(num, str, inputRef.current)}
2544
onValueChange={(num, str, inputEl) => {
26-
if (!onValueChange) {
27-
return
28-
}
29-
3045
// count hyphens to determine the sign, so that user can toggle the sign
3146
// by pressing hyphen key, regardless of the cursor position
3247
let hyphens = 0
@@ -36,6 +51,14 @@ export const NumericInput2 = ({
3651
return ''
3752
})
3853

54+
const dots = str.split('.').length - 1
55+
56+
if (dots > 1 || (dots === 1 && intOnly)) {
57+
return
58+
}
59+
60+
setEndsWithDot(str.endsWith('.'))
61+
3962
num = parseFloat(str)
4063

4164
if (Number.isNaN(num) || !Number.isFinite(num)) {
@@ -50,7 +73,7 @@ export const NumericInput2 = ({
5073
num = ~~num
5174
}
5275

53-
onValueChange(num, str, inputEl)
76+
onValueChange?.(num, str, inputEl)
5477
}}
5578
{...props}
5679
/>

src/components/editor/action/EditorActionDistance.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ export const EditorActionDistance = ({
7171
>
7272
<div className="flex">
7373
<NumericInput2
74-
intOnly
7574
selectAllOnFocus
7675
className="mr-2"
7776
placeholder="X 距离"
78-
minorStepSize={0.5}
77+
stepSize={0.5}
7978
onValueChange={(value) => onChange(transform.fromX(value))}
8079
onBlur={onBlur}
8180
value={value?.[0]?.toString() ?? ''}
@@ -88,10 +87,9 @@ export const EditorActionDistance = ({
8887
/>
8988

9089
<NumericInput2
91-
intOnly
9290
selectAllOnFocus
9391
placeholder="Y 距离"
94-
minorStepSize={0.5}
92+
stepSize={0.5}
9593
onValueChange={(value) => onChange(transform.fromY(value))}
9694
onBlur={onBlur}
9795
value={value?.[1]?.toString() ?? ''}

src/components/editor/operator/EditorOperatorSkillTimes.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const EditorOperatorSkillTimes = <
2222

2323
return (
2424
<NumericInput2
25+
intOnly
2526
defaultValue={0}
2627
onValueChange={(val) => onChange(Math.min(val, 100))}
2728
onBlur={onBlur}

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)