Skip to content

Commit

Permalink
feat(challenge): disable blood bonus for challenges
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Nov 20, 2024
1 parent 326d20f commit 59b9538
Show file tree
Hide file tree
Showing 12 changed files with 1,742 additions and 32 deletions.
6 changes: 6 additions & 0 deletions src/GZCTF/ClientApp/src/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,8 @@ export interface ChallengeEditDetailModel {
containerExposePort: number;
/** 是否需要记录访问流量 */
enableTrafficCapture?: boolean | null;
/** 是否禁用三血奖励 */
disableBloodBonus?: boolean | null;
/**
* 初始分数
* @format int32
Expand Down Expand Up @@ -1106,6 +1108,8 @@ export interface ChallengeUpdateModel {
containerExposePort?: number | null;
/** 是否需要记录访问流量 */
enableTrafficCapture?: boolean | null;
/** 是否禁用三血奖励 */
disableBloodBonus?: boolean | null;
/**
* 初始分数
* @format int32
Expand Down Expand Up @@ -1398,6 +1402,8 @@ export interface ChallengeInfo {
solved?: number;
/** 题目三血 */
bloods?: Blood[];
/** 是否禁用三血奖励 */
disableBloodBonus?: boolean;
}

export interface Blood {
Expand Down
4 changes: 4 additions & 0 deletions src/GZCTF/ClientApp/src/locales/en-US/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
"description": "Description",
"difficulty": "Difficulty Factor",
"disable": "Are you sure you want to disable challenge {{name}}?",
"blood_bonus": {
"description": "Enable blood bonus for this challenge",
"label": "Blood Bonus"
},
"empty": {
"description": "Click the top right to create the first challenge",
"title": "Ouch! This game has no challenge yet."
Expand Down
4 changes: 4 additions & 0 deletions src/GZCTF/ClientApp/src/locales/zh-CN/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
"description": "所有动态附件均会以此文件名下载",
"label": "全局附件名"
},
"blood_bonus": {
"description": "启用题目的三血加分",
"label": "三血奖励"
},
"bonus": {
"description": "三血奖励加成是指当一个题目被前三个队伍解出时,每个队伍可以得到的分值奖励。三血的奖励基于题目的当前分值,并以一个固定百分比的形式累加至该队伍的得分中。",
"first_blood": "一血奖励 (%)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,36 +338,40 @@ const GameChallengeEdit: FC = () => {
</Stack>
</Grid.Col>
<Grid.Col span={1}>
<Stack gap="sm">
<NumberInput
label={t('admin.content.games.challenges.score')}
min={0}
required
disabled={disabled}
stepHoldDelay={500}
stepHoldInterval={(t) => Math.max(1000 / t ** 2, 25)}
value={challengeInfo?.originalScore ?? 500}
onChange={(e) =>
typeof e !== 'string' && setChallengeInfo({ ...challengeInfo, originalScore: e })
}
/>
<NumberInput
label={t('admin.content.games.challenges.difficulty')}
decimalScale={2}
fixedDecimalScale
step={0.2}
min={0.1}
required
disabled={disabled}
value={challengeInfo?.difficulty ?? 100}
stepHoldDelay={500}
stepHoldInterval={(t) => Math.max(1000 / t ** 2, 25)}
onChange={(e) =>
typeof e !== 'string' && setChallengeInfo({ ...challengeInfo, difficulty: e })
}
/>
<Stack h="100%">
<Group wrap="nowrap">
<NumberInput
label={t('admin.content.games.challenges.score')}
min={0}
required
disabled={disabled}
stepHoldDelay={500}
stepHoldInterval={(t) => Math.max(1000 / t ** 2, 25)}
value={challengeInfo?.originalScore ?? 500}
onChange={(e) =>
typeof e !== 'string' &&
setChallengeInfo({ ...challengeInfo, originalScore: e })
}
/>
<NumberInput
label={t('admin.content.games.challenges.difficulty')}
decimalScale={2}
fixedDecimalScale
step={0.2}
min={0.1}
required
disabled={disabled}
value={challengeInfo?.difficulty ?? 100}
stepHoldDelay={500}
stepHoldInterval={(t) => Math.max(1000 / t ** 2, 25)}
onChange={(e) =>
typeof e !== 'string' && setChallengeInfo({ ...challengeInfo, difficulty: e })
}
/>
</Group>
<Input.Wrapper
label={t('admin.content.games.challenges.min_score_radio.label')}
h="3.8rem"
required
>
<Slider
Expand All @@ -392,6 +396,17 @@ const GameChallengeEdit: FC = () => {
})}
/>
</Input.Wrapper>
<Switch
disabled={disabled}
checked={!challengeInfo?.disableBloodBonus}
label={SwitchLabel(
t('admin.content.games.challenges.blood_bonus.label'),
t('admin.content.games.challenges.blood_bonus.description')
)}
onChange={(e) =>
setChallengeInfo({ ...challengeInfo, disableBloodBonus: !e.target.checked })
}
/>
</Stack>
</Grid.Col>
<Grid.Col span={1}>
Expand Down
Loading

0 comments on commit 59b9538

Please sign in to comment.