Skip to content

Commit e78cc6e

Browse files
authored
fix: amend (#1528)
1 parent 83bb040 commit e78cc6e

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/routes/arena.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,19 @@ router.post("/create", authenticate(), async (req, res) => {
4343
}
4444

4545
// 临时代码,处理 THUAI8 由于 hardcode 导致的 Buddhist 必须在 Monster 前面的 BUG
46+
const active_team_id = team_label_binds[0].team_id;
4647
if (contest_name === "THUAI8") {
4748
const buddhistIndex = team_label_binds.findIndex(
4849
(bind) => bind.label === "Buddhist",
4950
);
5051
const monsterIndex = team_label_binds.findIndex(
5152
(bind) => bind.label === "Monster",
5253
);
53-
if (buddhistIndex !== -1 && monsterIndex !== -1) {
54+
if (
55+
buddhistIndex !== -1 &&
56+
monsterIndex !== -1 &&
57+
buddhistIndex > monsterIndex
58+
) {
5459
const temp = team_label_binds[buddhistIndex];
5560
team_label_binds[buddhistIndex] = team_label_binds[monsterIndex];
5661
team_label_binds[monsterIndex] = temp;
@@ -94,14 +99,14 @@ router.post("/create", authenticate(), async (req, res) => {
9499
console.debug("user_team_id: ", user_team_id);
95100
if (!user_team_id) {
96101
return res.status(403).send("403 Forbidden: User not in team");
97-
} else if (user_team_id !== team_ids[0]) {
102+
} else if (user_team_id !== active_team_id) {
98103
return res.status(403).send("403 Forbidden: User not in team");
99104
}
100105
}
101106

102107
const active_rooms = await ContHasFunc.count_room_team(
103108
contest_id,
104-
team_ids[0],
109+
active_team_id,
105110
);
106111
console.debug("active_rooms: ", active_rooms);
107112
if (active_rooms > 6) {

src/routes/competition.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,11 @@ router.post("/start-one", authenticate(), async (req, res) => {
530530
const monsterIndex = team_label_binds.findIndex(
531531
(bind) => bind.label === "Monster",
532532
);
533-
if (buddhistIndex !== -1 && monsterIndex !== -1) {
533+
if (
534+
buddhistIndex !== -1 &&
535+
monsterIndex !== -1 &&
536+
buddhistIndex > monsterIndex
537+
) {
534538
const temp = team_label_binds[buddhistIndex];
535539
team_label_binds[buddhistIndex] = team_label_binds[monsterIndex];
536540
team_label_binds[monsterIndex] = temp;

0 commit comments

Comments
 (0)