活动:修复任务
This commit is contained in:
@@ -68,6 +68,8 @@ export class GachaHandler {
|
||||
let userHeroes = await HeroModel.findByRole(roleId);
|
||||
|
||||
let items: RewardInter[] = [], heroInfo: CreateHeroParam[] = [], resultList: GachaResult[] = [];
|
||||
|
||||
let activityData = [];//活动需要统计抽中的英雄、碎片品质
|
||||
for (let i = 0; i < count; i++) {
|
||||
// 按照一般概率抽出
|
||||
let { dic: { id: base } } = getRandEelmWithWeight(dicGacha.percent);
|
||||
@@ -79,6 +81,7 @@ export class GachaHandler {
|
||||
result.setSetPickHero(pickHero);
|
||||
let hasHero = userHeroes.find(cur => cur.hid == result.hid);
|
||||
if (hasHero) { // 已有转换为碎片
|
||||
activityData.push({ hid: hasHero.hid, quality: hasHero.quality });
|
||||
let { pieceId, count } = transPiece(result.hid);
|
||||
result.transferToPiece(pieceId, count);
|
||||
items.push({ id: pieceId, count });
|
||||
@@ -121,7 +124,10 @@ export class GachaHandler {
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GASHA, count, true, {});
|
||||
//活动统计
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.GASHA, count)
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.GACHA_QUALITY_COUNT, count, { heroes })
|
||||
for (let hero of heroes) {
|
||||
activityData.push({ hid: hero.hid, quality: hero.quality });
|
||||
}
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.GACHA_QUALITY_COUNT, count, { heroes: activityData })
|
||||
|
||||
let resultRefFreeTime = 0;
|
||||
if (dicGacha.free.count > 0) {
|
||||
|
||||
@@ -298,6 +298,7 @@ export class RoleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
let sid = session.get('sid');
|
||||
let funcs: number[] = session.get('funcs');
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
let { hid } = msg;
|
||||
|
||||
@@ -325,6 +326,7 @@ export class RoleHandler {
|
||||
update.favour += SCROLL.SCROLL_ACTIVE_FAVOUR;
|
||||
update.favourLv = getFriendLvByExp(update.favour);
|
||||
}
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.HERO_UNLOCK, 1, { dicHeroes: [dicHero] })
|
||||
} else {
|
||||
if (star > scrollStar) { // 可以升星
|
||||
update.scrollStar++;
|
||||
|
||||
@@ -57,76 +57,6 @@ export async function getPlayerPopUpShopData(activityId: number, serverId: numbe
|
||||
return allPlayerShop;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * 弹出礼包任务特殊处理
|
||||
// *
|
||||
// * @param {number} serverId 区Id
|
||||
// * @param {number} activityId 活动Id
|
||||
// * @param {string} roleId 角色Id
|
||||
// *
|
||||
// */
|
||||
// export async function checkPopUpActivityTask(serverId: number, sid: number, funcs: number[], roleId: string, taskType: number, addCount: number) {
|
||||
// let { activityGroupId } = await ServerlistModel.findByServerId(serverId);
|
||||
// let allActivity = await ActivityModel.findOpenActivityByType(activityGroupId, ACTIVITY_TYPE.POP_UP_SHOP, new Date());
|
||||
// for (let activity of allActivity) {
|
||||
// let allTaskData: any[] = JSON.parse(activity.data);
|
||||
// for (let task of allTaskData) {
|
||||
// if (task.taskType == taskType) {
|
||||
// let popShopData = new PopUpShopData(task, activity.activityId);
|
||||
// let taskRecord = await ActivityPopUpShopModel.findDataByTaskId(serverId, activity.activityId, roleId, popShopData.id, popShopData.taskType)
|
||||
// let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null
|
||||
|
||||
// let beginTime = new Date();
|
||||
// let endTime = moment(new Date()).add(task.duration, 'h').toDate();
|
||||
// if (taskType == TASK_TYPE.ROLE_TERAPH_STAGE_UP) {//只要触发就弹出礼包商店
|
||||
// //推送
|
||||
// let playerRecord = await ActivityPopUpShopModel.addTaskPushMessage(serverId, activity.activityId, roleId, task.id, task.taskType, addCount, beginTime, endTime);
|
||||
// popShopData.setPlayerRecords(playerRecord)
|
||||
// // pushMessage = pushMessage.concat(popShopData);
|
||||
// } else if (taskType == TASK_TYPE.EQUIP_QUALITY_COUNT || taskType == TASK_TYPE.GACHA_QUALITY_COUNT) {//每天统计
|
||||
|
||||
// }
|
||||
|
||||
// // if (!taskRecord || !taskRecord.isPush) {
|
||||
// // let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, parma, recordData);
|
||||
// // if (addCount) {
|
||||
|
||||
// // if (taskType == TASK_TYPE.ROLE_LV || taskType == TASK_TYPE.ROLE_TITLE || taskType == TASK_TYPE.BATTLE_TOWER_LV) {
|
||||
// // let playerRecord = await ActivityPopUpShopModel.setTaskCount(serverId, activity.activityId, roleId, task.id, task.taskType, addCount);
|
||||
// // //推送
|
||||
// // if (task.condition <= playerRecord.totalCount) {
|
||||
// // playerRecord = await ActivityPopUpShopModel.pushMessage(serverId, activity.activityId, roleId, task.id, task.taskType, beginTime, endTime);
|
||||
// // popShopData.setPlayerRecords(playerRecord)
|
||||
// // pushMessage = pushMessage.concat(popShopData);
|
||||
// // }
|
||||
// // } else if (taskType == TASK_TYPE.ROLE_TERAPH_STAGE_UP) {//只要触发就弹出礼包商店
|
||||
// // //推送
|
||||
// // let playerRecord = await ActivityPopUpShopModel.addTaskPushMessage(serverId, activity.activityId, roleId, task.id, task.taskType, addCount, beginTime, endTime);
|
||||
// // popShopData.setPlayerRecords(playerRecord)
|
||||
// // pushMessage = pushMessage.concat(popShopData);
|
||||
// // } else if (taskType == TASK_TYPE.EQUIP_QUALITY_COUNT || taskType == TASK_TYPE.GACHA_QUALITY_COUNT) {//每天统计
|
||||
|
||||
// // } else {
|
||||
// // let playerRecord = await ActivityPopUpShopModel.addTaskCount(serverId, activity.activityId, roleId, task.id, task.taskType, addCount);
|
||||
// // //推送
|
||||
// // if (task.condition <= playerRecord.totalCount) {
|
||||
// // playerRecord = await ActivityPopUpShopModel.pushMessage(serverId, activity.activityId, roleId, task.id, task.taskType, beginTime, endTime);
|
||||
// // popShopData.setPlayerRecords(playerRecord)
|
||||
// // pushMessage = pushMessage.concat(popShopData);
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// // if (record) {
|
||||
// // await ActivityPopUpShopModel.addTaskRecord(serverId, activity.activityId, roleId, task.id, task.taskType, JSON.stringify(record));
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 结算购买礼包的奖励
|
||||
*
|
||||
|
||||
@@ -240,12 +240,11 @@ export async function createHeroes(roleId: string, roleName: string, serverId: n
|
||||
let heroNum = 0;
|
||||
let skinIds = new Array<number>();
|
||||
let conditions = new Array<{ type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>();
|
||||
let heroes: HeroType[] = [], calHeroResults = [], calAllHeroResults = [], dicHeroes = [];
|
||||
let heroes: HeroType[] = [], calHeroResults = [], calAllHeroResults = [];
|
||||
|
||||
for (let heroInfo of heroInfos) {
|
||||
let dicHero = gameData.hero.get(heroInfo.hid);
|
||||
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = dicHero;
|
||||
dicHeroes.push(dicHero);
|
||||
|
||||
let info = { roleId, roleName, serverId, quality, star, job, hName, skins: [{ id: initialSkin, enable: true }] };
|
||||
let curHero = await HeroModel.createHero(Object.assign(info, heroInfo));
|
||||
@@ -271,7 +270,6 @@ export async function createHeroes(roleId: string, roleName: string, serverId: n
|
||||
//成长任务
|
||||
await accomplishTask(serverId, roleId, TASK_TYPE.HERO_NUM, heroNum)
|
||||
await accomplishTask(serverId, roleId, TASK_TYPE.HERO_QUALITY, heroNum, { heroes })
|
||||
await accomplishTask(serverId, roleId, TASK_TYPE.HERO_UNLOCK, heroNum, { dicHeroes })
|
||||
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults, taskPushMessage }
|
||||
}
|
||||
|
||||
|
||||
@@ -754,14 +754,13 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
|
||||
let recordDate = moment(new Date()).startOf('d').toDate()
|
||||
let recordData: ActivityPopUpShopRecordModelType = await ActivityPopUpShopRecordModel.findRecordData(serverId, activity.activityId, roleId, task.id, task.taskType, recordDate)
|
||||
let { addCount } = isComplete(roleId, task.taskType, task.taskParam, count, parma, null);
|
||||
if (recordData && (recordData.count < task.condition) && (recordData.count + addCount >= task.condition)) {//完成当天任务
|
||||
let playerRecord = await ActivityPopUpShopModel.addTaskPushMessage(serverId, activity.activityId, roleId, task.id, task.taskType, count, beginTime, endTime);
|
||||
let oldCount = (recordData && recordData.count) ? recordData.count : 0;
|
||||
if (oldCount < task.condition && (oldCount + addCount >= task.condition)) {//完成当天任务
|
||||
let playerRecord = await ActivityPopUpShopModel.addTaskPushMessage(serverId, activity.activityId, roleId, task.id, task.taskType, addCount, beginTime, endTime);
|
||||
popShopData.setPlayerRecords(playerRecord)
|
||||
pushMessage = pushMessage.concat(popShopData);
|
||||
await ActivityPopUpShopRecordModel.addRecord(serverId, activity.activityId, roleId, task.id, task.taskType, recordDate, addCount)
|
||||
} else {
|
||||
await ActivityPopUpShopRecordModel.addRecord(serverId, activity.activityId, roleId, task.id, task.taskType, recordDate, addCount)
|
||||
}
|
||||
await ActivityPopUpShopRecordModel.addRecord(serverId, activity.activityId, roleId, task.id, task.taskType, recordDate, addCount)
|
||||
} else if (taskType == TASK_TYPE.GUILD_TRAIN_COUNT) {//军团练兵场通关层数推送所有团员
|
||||
if (task.taskParam[0] == parma.trainId) {
|
||||
let playerRecord = await ActivityPopUpShopModel.addTaskPushMessage(serverId, activity.activityId, roleId, task.id, task.taskType, count, beginTime, endTime);
|
||||
|
||||
Reference in New Issue
Block a user