任务:埋点48/71
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { getGamedata } from '../../../pubUtils/gamedata';
|
||||
import { EventRecordModel } from '../../../db/EventRecord';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_ANSWER_STATUS } from '../../../consts';
|
||||
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_ANSWER_STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { checkEvent, checkEventStatus, getEventSuccessStatus, getEvent, checkQuiz } from '../../../services/eventSercive';
|
||||
import { handleFixedReward } from '../../../services/rewardService';
|
||||
import { handleFixedReward, addItems } from '../../../services/rewardService';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new EventBattleHandler(app);
|
||||
@@ -100,17 +101,16 @@ export class EventBattleHandler {
|
||||
if(dataEventId != eventId) {
|
||||
return resResult(STATUS.EVENT_WRONG_ID);
|
||||
}
|
||||
let dicEvent = getGamedata('dic_zyz_event');
|
||||
let curEvent = dicEvent.find(cur => cur.eventID == eventId);
|
||||
if(!curEvent) {
|
||||
let dicEvent = gameData.event.get(eventId);
|
||||
if(!dicEvent) {
|
||||
return resResult(STATUS.EVENT_INFO_NOT_FOUND);
|
||||
}
|
||||
|
||||
// 保存状态
|
||||
let result = await EventRecordModel.setStatusByCode(roleId, eventCode, isSuccess?EVENT_RECORD_STATUS.SUCCESS_RECEIVED:EVENT_RECORD_STATUS.FAIL_RECEIVED);
|
||||
// 保存奖励
|
||||
let rewardStr = isSuccess?curEvent.winReward:curEvent.loseReward;
|
||||
let goods = await handleFixedReward(roleId, roleName, sid, rewardStr, 1);
|
||||
let reward = isSuccess?dicEvent.winReward:dicEvent.loseReward;
|
||||
let goods = await addItems(roleId, roleName, sid, reward);
|
||||
if(eventStatus == EVENT_STATUS.STARTING) { // 如果是第一次开启的挑战,保存成开启状态
|
||||
await RoleModel.setEventStatus(roleId, EVENT_STATUS.OPEN);
|
||||
// 第一场时间挑战完,开始正常刷新事件,所以刷新时间也重置起来
|
||||
@@ -119,6 +119,8 @@ export class EventBattleHandler {
|
||||
}
|
||||
// 推送消息刷新
|
||||
await checkEvent(session, true);
|
||||
// 任务
|
||||
await checkTask(roleId, sid, TASK_TYPE.BATTLE_EVENT, 1, true, { eventType: dicEvent.eventType })
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
isSuccess,
|
||||
eventCode: result.eventCode,
|
||||
|
||||
Reference in New Issue
Block a user