活动:清理数据
This commit is contained in:
@@ -4,7 +4,6 @@ import { resResult, shouldRefresh } from '../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, WAR_TYPE } from '../../consts';
|
||||
import { TaskParamInter, TaskListReturn } from '../../domain/roleField/task';
|
||||
import { EPlace, HeroType } from '../../db/Hero';
|
||||
import { getRoleOnlineInfo } from '../redisService';
|
||||
import { HeroScores } from '../../db/PvpHistoryOpp';
|
||||
import { ItemInter } from '../../pubUtils/interface';
|
||||
import { UserTaskModel, UserTaskType } from '../../db/UserTask';
|
||||
@@ -15,6 +14,9 @@ import { getSeconds, getZeroPointD } from '../../pubUtils/timeUtil';
|
||||
import { RoleStatus } from '../../db/ComBattleTeam';
|
||||
import { getActivities } from '../activity/activityService';
|
||||
import { CheckTask } from './taskObj';
|
||||
import { getEquipById } from '../equipService';
|
||||
import { JewelType } from '../../db/Jewel';
|
||||
import { checkPopUpConditionInCreateHero } from '../activity/popUpShopService';
|
||||
|
||||
export async function checkTaskWithRoles(serverId: number, roleId: string, sid: string, taskType: TASK_TYPE, roles: RoleType[]) {
|
||||
for (let role of roles) {
|
||||
@@ -52,6 +54,7 @@ export async function checkTaskInCreateHero(serverId: number, roleId: string, si
|
||||
task.setParam(TASK_TYPE.HERO_QUALITY_STAR_UP, { heroes });
|
||||
task.setParam(TASK_TYPE.HERO_LV, { heroes });
|
||||
await task.saveAndPush(sid);
|
||||
await checkPopUpConditionInCreateHero(serverId, roleId, heroes);
|
||||
}
|
||||
|
||||
export async function checkTaskInHeroStarUp(serverId: number, roleId: string, sid: string, hero: HeroType, oldStar: number) {
|
||||
@@ -72,11 +75,10 @@ export async function checkTaskInHeroWakeUp(serverId: number, roleId: string, si
|
||||
}
|
||||
|
||||
export async function checkTaskInHeroQUalityUp(serverId: number, roleId: string, sid: string, hero: HeroType) {
|
||||
// 任务
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_QUALITY_UP, { hero });
|
||||
// 任务
|
||||
await checkTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT, { hero });
|
||||
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.HERO_QUALITY_UP, { hero });
|
||||
task.setParam(TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT, { hero });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInHeroTrain(serverId: number, roleId: string, sid: string, hero: HeroType, trainCount: number) {
|
||||
@@ -86,6 +88,23 @@ export async function checkTaskInHeroTrain(serverId: number, roleId: string, sid
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInActiveScroll(serverId: number, roleId: string, sid: string, scrollActive: boolean, hero: HeroType) {
|
||||
if (!scrollActive) {
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.HERO_UNLOCK, { hero });
|
||||
task.setParam(TASK_TYPE.ROLE_SCROLL_ACTIVE, { scrollActive });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkTaskInGuildTrain(serverId: number, roleId: string, sid: string, warId: number, isSuccess: boolean, isComplete: boolean) {
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.GUILD_TRAIN_SUCESS, { isSuccess });
|
||||
task.setParam(TASK_TYPE.GUILD_TRAIN, {});
|
||||
task.setParam(TASK_TYPE.GUILD_TRAIN_COUNT, { isComplete, warId });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* battle.normalBattleHandler.battleEnd 中会触发的任务,因为有点多提出来了
|
||||
*/
|
||||
@@ -100,6 +119,7 @@ export async function checkTaskInHeroTrain(serverId: number, roleId: string, sid
|
||||
task.setParam(TASK_TYPE.BATTLE_TOWER, { warId, count: 1 });
|
||||
task.setParam(TASK_TYPE.BATTLE_VESTIGE, { warId, count: 1 });
|
||||
task.setParam(TASK_TYPE.BATTLE_EXPEDITION, { warId, count: 1 });
|
||||
task.setParam(TASK_TYPE.BATTLE_MAIN_ELITE, { warId, count: 1 });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
@@ -118,33 +138,114 @@ export async function checkTaskInBattleSweep(serverId: number, roleId: string, s
|
||||
}
|
||||
|
||||
|
||||
export async function checkTaskInComBattleStart(roleStatus: RoleStatus[], capId: string) {
|
||||
export async function checkTaskInComBattleStart(roleStatus: RoleStatus[], capId: string, blueprtId: number) {
|
||||
// console.log('********', JSON.stringify(roleStatus), capId, quality)
|
||||
for (let { roleId, isRobot } of roleStatus) {
|
||||
if (!isRobot) {
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
|
||||
let task = new CheckTask(role.serverId, roleId);
|
||||
task.setRole(role);
|
||||
if (roleId == capId && roleStatus.length > 1) { // 招募队友
|
||||
await checkTaskWithRole(role.serverId, roleId, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, role);
|
||||
task.setParam(TASK_TYPE.COM_BATTLE_CREATE_TEAM, {});
|
||||
} else if (roleId !== capId) { // 协助寻宝
|
||||
await checkTaskWithRole(role.serverId, roleId, null, TASK_TYPE.COM_BATTLE_ASSIST_TEAM, role);
|
||||
task.setParam(TASK_TYPE.COM_BATTLE_ASSIST_TEAM, {});
|
||||
}
|
||||
await checkTaskWithRole(role.serverId, roleId, null, TASK_TYPE.COM_BATTLE, role);
|
||||
task.setParam(TASK_TYPE.COM_BATTLE, {});
|
||||
task.setParam(TASK_TYPE.COM_BATTLE_LV, { gid: blueprtId });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkTaskInPvpEnd(serverId: number, roleId: string, sid: string, isSuccess: boolean, heroScores: HeroScores[]) {
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.PVP_WIN, { isSuccess })
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.PVP_WIN_SERIES, { isSuccess });
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.PVP_HERO_SCORE, { heroScores });
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.PVP_WIN, { isSuccess });
|
||||
task.setParam(TASK_TYPE.PVP_WIN_SERIES, { isSuccess });
|
||||
task.setParam(TASK_TYPE.PVP_HERO_SCORE, { heroScores });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInGacha(serverId: number, roleId: string, sid: string, count: number, heroes: HeroType[]) {
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.GACHA, { count });
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.GACHA_QUALITY_COUNT, { heroes });
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.GACHA, { count });
|
||||
task.setParam(TASK_TYPE.GACHA_QUALITY_COUNT, { heroes });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
|
||||
export async function checkTaskInComposeEquip(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[]) {
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.EQUIP_COMPOSE, { count: newEplace.length - oldEplace.length });
|
||||
task.setParam(TASK_TYPE.EQUIP_COMPOSE_CNT, { oldEplace, newEplace });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInEquipLvUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceIds: number[]) {
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.EQUIP_LV_TO, { oldEplace, newEplace, ePlaceIds });
|
||||
task.setParam(TASK_TYPE.EQUIP_LV_UP, { count: ePlaceIds.length });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInPutJewel(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, originJewel: JewelType, curJewel: JewelType) {
|
||||
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.EQUIP_PUT_JEWEL, { oldEquip, newEplace, jewels: [originJewel, curJewel ] });
|
||||
task.setParam(TASK_TYPE.EQUIP_PUT_JEWEL_CNT, { oldEquip, newEquip });
|
||||
task.setParam(TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, { oldEquip, newEplace, jewels: [originJewel, curJewel ] });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInPutStone(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, jewel: JewelType) {
|
||||
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.EQUIP_PUT_STONE, { oldEquip, newEquip });
|
||||
task.setParam(TASK_TYPE.EQUIP_PUT_STONE_CNT, { oldEquip, newEquip });
|
||||
task.setParam(TASK_TYPE.EQUIP_STONE_CNT, { oldEquip, newEquip });
|
||||
task.setParam(TASK_TYPE.EQUIP_STONE_CNT_LV, { oldEquip, newEquip });
|
||||
task.setParam(TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, { oldEquip, newEplace, jewels: [jewel ] });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean) {
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
if(isUpStar) {
|
||||
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
|
||||
task.setParam(TASK_TYPE.EQUIP_STAR_UP_TO, { oldEquip, newEquip });
|
||||
task.setParam(TASK_TYPE.EQUIP_SUIT_SEID_NUM, { oldEplace, newEplace, ePlaceId, hid });
|
||||
}
|
||||
task.setParam(TASK_TYPE.EQUIP_STAR_UP_CNT, { hid, ePlaceId });
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInEquipQualityUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpQuality: boolean) {
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
if(isUpQuality) {
|
||||
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
|
||||
task.setParam(TASK_TYPE.EQUIP_QUALITY_UP, { hid, ePlaceId });
|
||||
task.setParam(TASK_TYPE.EQUIP_QUALITY_UP_TO, { oldEquip, newEquip })
|
||||
}
|
||||
task.setParam(TASK_TYPE.EQUIP_QUALITY_UP_CNT, {});
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInEquipReset(serverId: number, roleId: string, sid: string) {
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.JEWEL_RESET);
|
||||
}
|
||||
|
||||
export async function checkTaskInEquipQuench(serverId: number, roleId: string, sid: string, isSuccess: boolean) {
|
||||
let task = new CheckTask(serverId, roleId);
|
||||
task.setParam(TASK_TYPE.JEWEL_QUENCH, {});
|
||||
if(isSuccess) {
|
||||
task.setParam(TASK_TYPE.JEWEL_QUENCH_SUCCESS, { isSuccess });
|
||||
}
|
||||
await task.saveAndPush(sid);
|
||||
}
|
||||
|
||||
export async function checkTaskInComposeStone(serverId: number, roleId: string, sid: string, count: number) {
|
||||
await checkTask(serverId, roleId, sid, TASK_TYPE.STONE_COMPOSE, { count });
|
||||
}
|
||||
|
||||
|
||||
// 获取task状态
|
||||
export async function getCurTask(roleId: string, session: FrontendOrBackendSession) {
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
|
||||
Reference in New Issue
Block a user