From c65a9a500b45e89b0179f53ac560c5e521ed1c6a Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 25 May 2021 20:02:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A0=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=AD=94=E6=A1=88=E7=9A=84=E4=BD=93=E5=9E=8B,=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=AE=A1=E5=88=86=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/controllers/exam.controller.ts | 23 ++++++++++++++--------- src/api/controllers/puzzle.controller.ts | 21 +++++++++++++-------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/api/controllers/exam.controller.ts b/src/api/controllers/exam.controller.ts index 85e43e4..ddd83e6 100644 --- a/src/api/controllers/exam.controller.ts +++ b/src/api/controllers/exam.controller.ts @@ -106,25 +106,30 @@ class ExamController extends BaseController { if (type == 1) { // type = 1 为客户端上报的超时消息, 直接判负 result = -1 overtime = 1 - } else if (time < 0){ + } else if (time < 0 && record.type !== 3){ result = -1 overtime = 1 } statMap.timeLast = Date.now() statMap.answer.set(id, result) statMap.total ++ - if (result == 0) { - statMap.rightCount++ - statMap.comboCount++ - statMap.maxCombo = Math.max(statMap.maxCombo, statMap.comboCount) - } else { - statMap.errorCount++ - statMap.comboCount = 0 + if (record.type !== 3) { + if (result == 0) { + statMap.rightCount++ + statMap.comboCount++ + statMap.maxCombo = Math.max(statMap.maxCombo, statMap.comboCount) + } else { + statMap.errorCount++ + statMap.comboCount = 0 + } } statMap.timeLeft = (statMap.timeLast - history.createdAt.getTime()) / 1000 history.status = 1 - let score = result ? calcExamScore(time, statMap.comboCount) : 0 + let score = result === 0 ? calcExamScore(time, statMap.comboCount) : 0 + if(record.type === 3) { + score = 0 + } statMap.score += score history.markModified('members') await history.save() diff --git a/src/api/controllers/puzzle.controller.ts b/src/api/controllers/puzzle.controller.ts index 6594674..e0a6bec 100644 --- a/src/api/controllers/puzzle.controller.ts +++ b/src/api/controllers/puzzle.controller.ts @@ -117,13 +117,15 @@ class PuzzleController extends BaseController { statMap.timeLast = Date.now() statMap.answer.set(id, result) statMap.total ++ - if (result == 0) { - statMap.rightCount++ - statMap.comboCount++ - statMap.maxCombo = Math.max(statMap.maxCombo, statMap.comboCount) - } else { - statMap.errorCount++ - statMap.comboCount = 0 + if (record.type !== 1) { + if (result == 0) { + statMap.rightCount++ + statMap.comboCount++ + statMap.maxCombo = Math.max(statMap.maxCombo, statMap.comboCount) + } else { + statMap.errorCount++ + statMap.comboCount = 0 + } } history.status = 1 history.markModified('members') @@ -131,7 +133,10 @@ class PuzzleController extends BaseController { await history.save() let rspData: any = { result: result === 0, answer: record.answers[0], stats: history.members } if (mode == 1) { - let score = result ? calcPvpScore(history.scheduleKey, statMap.comboCount) : 0 + let score = result === 0 ? calcPvpScore(history.scheduleKey, statMap.comboCount) : 0 + if (record.type === 3) { + score = 0 + } await broadcast(history.room, 'answer', {accountid, result, score}) await updateScore(history.room, [{accountid, score }])