修改超时消息的处理方式

This commit is contained in:
zhl 2021-05-13 19:16:09 +08:00
parent a56c87eea8
commit efd6b15088
2 changed files with 11 additions and 12 deletions

View File

@ -93,10 +93,16 @@ class PuzzleController extends BaseController {
if (!history) { if (!history) {
throw new ZError(13, 'not found match info') throw new ZError(13, 'not found match info')
} }
let record = await Puzzle.findById(id)
if (!record) {
throw new ZError(12, 'question not found')
}
let result = record.a1 == answer ? 1 : 0
if (type == 1) {
result = 0
}
if (history.status == 9 || history.hasExpired()) { if (history.status == 9 || history.hasExpired()) {
history.status = 9 result = 0
await history.save()
throw new ZError(17, 'match end')
} }
if (!history.members.has(accountid)) { if (!history.members.has(accountid)) {
throw new ZError(14, 'not in current match') throw new ZError(14, 'not in current match')
@ -108,14 +114,7 @@ class PuzzleController extends BaseController {
if (statMap.answer.has(id)) { if (statMap.answer.has(id)) {
throw new ZError(15, 'current question already answered') throw new ZError(15, 'current question already answered')
} }
let record = await Puzzle.findById(id)
if (!record) {
throw new ZError(12, 'question not found')
}
let result = record.a1 == answer ? 1 : 0
if (type == 1) {
result = 0
}
statMap.answer.set(id, result) statMap.answer.set(id, result)
if (result == 1) { if (result == 1) {
statMap.rightCount++ statMap.rightCount++

View File

@ -8,7 +8,7 @@ import {
import { BaseModule } from './Base' import { BaseModule } from './Base'
@dbconn() @dbconn()
@index({ accoundId: 1}, { unique: true }) @index({ accountId: 1}, { unique: true })
@modelOptions({ schemaOptions: { collection: 'game_user', timestamps: true } }) @modelOptions({ schemaOptions: { collection: 'game_user', timestamps: true } })
class GameUserClass extends BaseModule { class GameUserClass extends BaseModule {
@prop() @prop()