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 }])