修正检查所有人是否都已经答了当前题的bug

This commit is contained in:
zhl 2021-05-06 11:27:39 +08:00
parent 81ee1f0316
commit e480435aa4

View File

@ -1,5 +1,6 @@
import {
beginGame, closeRoom,
beginGame,
closeRoom,
endGame,
sendQuestion,
updateRound,
@ -34,15 +35,22 @@ export function transformRecord(records: any[]) {
})
}
/**
*
*
* @param history
* @param {string} qid
* @return {boolean}
*/
export function checkSubFinish(history: any, qid: string) {
let count = 0
for (let [key, val] of history.members) {
if (val.answer?.has(qid)) {
count ++
if (!val.answer?.has(qid)) {
return false
}
}
return count >= history.questions.length;
return true
}
/**
*
* @param {string} roomId
@ -81,9 +89,9 @@ export async function sendOneQuestion(history: any) {
qdata.no = history.current
await updateRound(roomId, history.current)
await sendQuestion(roomId, qdata)
history.current ++
history.current++
await history.save()
new Schedule().beginSchedule(BaseConst.MATCH_ANSWER_TIME, async function (){
new Schedule().beginSchedule(BaseConst.MATCH_ANSWER_TIME, async function () {
let subHistory = await PuzzleSession.findById(history.id)
let datas = []
for (let [accountid, data] of subHistory.members) {
@ -91,7 +99,7 @@ export async function sendOneQuestion(history: any) {
data.answer.set(qid, 0)
data.errorCount++
data.comboCount = 0
datas.push({accountid, score: -1})
datas.push({ accountid, score: -1 })
}
}
subHistory.markModified('members')