更新json
This commit is contained in:
@@ -40,8 +40,7 @@ export class EventBattleHandler {
|
||||
}
|
||||
let { status, type, eventId: dataEventId, question } = event;
|
||||
|
||||
let flag = checkEventStatus(type, status);
|
||||
if(!flag) {
|
||||
if(status != EVENT_RECORD_STATUS.WAITING) {
|
||||
return resResult(STATUS.EVENT_STATUS_ERROR);
|
||||
}
|
||||
if(dataEventId != eventId) {
|
||||
@@ -51,7 +50,24 @@ export class EventBattleHandler {
|
||||
if(!curQuestion) return resResult(STATUS.EVENT_QUESTION_NOT_FOUND);
|
||||
|
||||
let {isCorrect, answerNo} = checkQuiz(questionId, answer);
|
||||
await EventRecordModel.saveEventAnswer(eventCode, questionId, isCorrect?EVENT_ANSWER_STATUS.CORRECT:EVENT_ANSWER_STATUS.WRONG);
|
||||
let result = await EventRecordModel.saveEventAnswer(eventCode, questionId, isCorrect?EVENT_ANSWER_STATUS.CORRECT:EVENT_ANSWER_STATUS.WRONG);
|
||||
if(!result) {
|
||||
return resResult(STATUS.EVENT_RECORD_NOT_FOUND);
|
||||
}
|
||||
let { question: newQuestion } = result;
|
||||
let isClear = true, allCorrect = true;
|
||||
for(let {status} of newQuestion) {
|
||||
if(status) {
|
||||
if(status == EVENT_ANSWER_STATUS.WRONG) {
|
||||
allCorrect = false;
|
||||
}
|
||||
}else {
|
||||
isClear = false; allCorrect = false;
|
||||
}
|
||||
}
|
||||
if(isClear) {
|
||||
await EventRecordModel.setStatusByCode(roleId, eventCode, allCorrect?EVENT_RECORD_STATUS.BATTLE_SUCCESS:EVENT_RECORD_STATUS.BATTLE_FAIL);
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, { eventCode, eventId, questionId, isCorrect, answerNo });
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ function pushEventMsg(app: Application, roleId: string, channelName: string, msg
|
||||
export function checkEventStatus(type: number, status: number) {
|
||||
|
||||
let flag: boolean; // 检查状态是否正确
|
||||
if(type == EVENT_TYPE.BATTLE) {
|
||||
if(type == EVENT_TYPE.BATTLE||type ==EVENT_TYPE.QUIZ) {
|
||||
if(status == EVENT_RECORD_STATUS.BATTLE_SUCCESS) {
|
||||
flag = true;
|
||||
} else if (status == EVENT_RECORD_STATUS.BATTLE_FAIL) {
|
||||
|
||||
Reference in New Issue
Block a user