活动:清理数据

This commit is contained in:
陆莹
2022-03-21 19:50:46 +08:00
parent 1c3d1c209c
commit 4f5edb7386
60 changed files with 1447 additions and 1076 deletions
+491 -25
View File
@@ -17,11 +17,13 @@ import { SevenDaysData } from "../../domain/activityField/sevenDaysField";
import { ThirtyDaysData } from "../../domain/activityField/thirtyDaysField";
import { TreasureHuntData } from "../../domain/activityField/treasureHuntField";
import { TaskListReturn, TaskParam, TaskParamInter, UpdateTaskParam } from "../../domain/roleField/task";
import { gameData } from "../../pubUtils/data";
import { gameData, getDicBlueprtById, getEquipSuitByHero } from "../../pubUtils/data";
import { getZeroPoint } from "../../pubUtils/timeUtil";
import { resResult } from "../../pubUtils/util";
import { getActivities, getActivitiesByType, getActivityByServerId } from "../activity/activityService";
import { getRoleCreateTime, getRoleOnlineInfo, getServerCreateTime } from "../redisService";
import { getEquipById, getJewelByEquip } from "../equipService";
import { isRandSeUnLock } from "../../pubUtils/playerCe";
export class CheckTask {
serverId: number; // 区id
@@ -167,18 +169,28 @@ export class CheckSingleTask {
// 检查一般任务
let dicTasks = gameData.taskType.get(taskType);
for (let dicTask of dicTasks) {
let groups = new Map<string, { type: number, group: string, taskParam: number[], taskIds: number[] }>(); // 以group做区分
for (let { id, type, group, taskParam } of dicTasks) {
if (!groups.has(`${type}_${group}`)) {
groups.set(`${type}_${group}`, { type, group, taskParam, taskIds: [] });
}
groups.get(`${type}_${group}`).taskIds.push(id);
}
for (let [_typeAndGroup, { type, group, taskParam, taskIds }] of groups) {
let taskUpdateParam = await this.checkIsMatch(dicTask.taskParam, async () => {
let data = await UserTaskRecModel.findByRoleAndGroup(roleId, dicTask.type, taskType, dicTask.group);
let taskUpdateParam = await this.checkIsMatch(taskParam, async () => {
let data = await UserTaskRecModel.findByRoleAndGroup(roleId, type, taskType, group);
return data? data.records: []
});
if (taskUpdateParam) {
let rec = await UserTaskRecModel.setOrIncTask(roleId, dicTask.type, taskType, dicTask.group, taskUpdateParam);
let rec = await UserTaskRecModel.setOrIncTask(roleId, type, taskType, group, taskUpdateParam);
if (!rec) continue;
if (rec.received && rec.received.includes(dicTask.id)) continue; // 已领取,不再推送
let received = rec.received || [];
this.addTaskPushMessage({ type: dicTask.type, id: dicTask.id, count: rec.count, received: received.includes(dicTask.id) });
for (let id of taskIds) {
if (rec.received && rec.received.includes(id)) continue; // 已领取,不再推送
let received = rec.received || [];
this.addTaskPushMessage({ type, id: id, count: rec.count, received: received.includes(id) });
}
}
}
@@ -354,7 +366,7 @@ export class CheckSingleTask {
case TASK_TYPE.ROLE_LV: // 3. 主公达x级
{
let { lv, oldLv } = param;
if(oldLv < dicTaskParam[0] && lv >= dicTaskParam[0]) {
if(lv > oldLv) {
result = { set: lv }
}
break;
@@ -384,11 +396,14 @@ export class CheckSingleTask {
break;
}
}
if(count + 1 >= dicTaskParam[1]) {
if(index == -1) {
records.push(`${hero.hid}_${count + 1}`);
} else {
records[index] = `${hero.hid}_${count + 1}`;
}
if(count + 1 >= dicTaskParam[1]) {
result = { inc: 1, records }
} else {
records.push(`${hero.hid}_${count + 1}`);
result = { records }
}
break;
@@ -457,11 +472,14 @@ export class CheckSingleTask {
break;
}
}
if( count < dicTaskParam[1] && count + trainCount >= dicTaskParam[1]) {
if(index == -1) {
records[index] = `${hero.hid}_${count + trainCount}`;
result = { inc: 1, records }
} else {
records.push(`${hero.hid}_${count + trainCount}`);
}
if( count < dicTaskParam[1] && count + trainCount >= dicTaskParam[1]) {
result = { inc: 1, records }
} else {
result = { records }
}
break;
@@ -503,11 +521,14 @@ export class CheckSingleTask {
break;
}
}
if( count < dicTaskParam[1] && count + stageUpCnt >= dicTaskParam[1]) {
if(index == -1) {
records[index] = `${hero.hid}_${count + stageUpCnt}`;
result = { inc: 1, records }
} else {
records.push(`${hero.hid}_${count + stageUpCnt}`);
}
if( count < dicTaskParam[1] && count + stageUpCnt >= dicTaskParam[1]) {
result = { inc: 1, records }
} else {
result = { records }
}
break;
@@ -528,19 +549,73 @@ export class CheckSingleTask {
}
break;
}
case TASK_TYPE.CHAT:
case TASK_TYPE.ROLE_SCHOOL_UNLOCK: // 17. 百家学宫解锁x个安置位
{
if (dicTaskParam[0] == 0 || dicTaskParam[0] == param.chatType) {
result = { inc: param.count };
result = { inc: 1 };
break;
}
case TASK_TYPE.ROLE_SCHOOL_PUT_HERO: // 18. 百家学宫放置x个武将
{
let { hid, preHid } = param;
if (hid > 0 && preHid <= 0) { // 放置
result = { inc: 1 };
} else if (hid <= 0 && preHid > 0) { // 卸下
result = { inc: -1 };
}
break;
}
case TASK_TYPE.FRIEND_NUM:
case TASK_TYPE.ROLE_TITLE: // 19. 爵位升至x
{
let { title, oldTitle } = param;
if(title > oldTitle) {
result = { set: title };
}
break;
}
case TASK_TYPE.ROLE_TERAPH_STRENGTHEN: // 20. 神像强化x次
{
let { count } = param;
result = { inc: count };
break;
}
case TASK_TYPE.ROLE_SCROLL_ACTIVE: // 21. 名将谱激活x武将
{
let { scrollActive } = param;
if(scrollActive) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.FRIEND_NUM: // 34. 拥有x名好友
{
let role = this.getRole();
result = { set: role.friendCnt };
break;
}
case TASK_TYPE.FRIEND_SEND_HEART: // 35. 赠送x次友情点
{
let { count } = param;
if(count > 0) {
result = { inc: count };
}
break;
}
case TASK_TYPE.CHAT: // 36. 聊天频道发言x次
{
let { chatType, count = 1 } = param;
if (dicTaskParam[0] == 0 || dicTaskParam[0] == chatType) {
result = { inc: count };
}
break;
}
case TASK_TYPE.BATTLE_COST_AP: // 37. 消耗体力
{
let { count } = param;
if(count > 0) {
result = { inc: count };
}
break;
}
case TASK_TYPE.BATTLE_WITH_HERO: // 38. 使用hId武将挑战x关卡x次
{
let { warId, battleHeroes } = param;
@@ -553,7 +628,7 @@ export class CheckSingleTask {
{
let { warId, count } = param;
let dicWar = gameData.war.get(warId);
if (dicWar.warType == WAR_TYPE.NORMAL) {
if (dicWar.warType == WAR_TYPE.NORMAL && this.checkIdList(dicTaskParam, 0, warId)) {
result = { inc: count };
}
break;
@@ -567,6 +642,14 @@ export class CheckSingleTask {
}
break;
}
case TASK_TYPE.BATTLE_EVENT: // 41. 奇遇(答题/解救百姓/劫匪) x 次
{
let { eventType } = param;
if(dicTaskParam[0] == 0|| dicTaskParam[0] == eventType) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.BATTLE_DAILY_STAR: // 42. 每日x星通关 x 次
{
let { warId, battleStar } = param;
@@ -603,6 +686,12 @@ export class CheckSingleTask {
}
break;
}
case TASK_TYPE.BATTLE_TOWER_LV: // 46. 通关镇念塔x层
{
let { towerLv } = param;
result = { set: towerLv };
break;
}
case TASK_TYPE.BATTLE_TOWER: // 47. 通关镇念塔x次
{
let { warId, count } = param;
@@ -630,11 +719,20 @@ export class CheckSingleTask {
}
break;
}
case TASK_TYPE.BATTLE_EXPEDITION_BOX: // 50. 领取x次远征 x宝箱
{
let { point } = param;
if(dicTaskParam[0] == 0 || dicTaskParam[0] == point) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.COM_BATTLE_CREATE_TEAM: // 51. 寻宝招募队友x次
{
result = { inc: 1 };
break;
}
case TASK_TYPE.COM_BATTLE_ASSIST_TEAM: // 53. 协助寻宝x次
{
result = { inc: 1 };
@@ -645,11 +743,6 @@ export class CheckSingleTask {
result = { inc: 1 };
break;
}
case TASK_TYPE.PVP_RECEIVE_BOX: // 59. 领取x次pvp巅峰之路宝箱
{
result = { inc: 1 };
break;
}
case TASK_TYPE.PVP: // 57. pvp挑战 x 次
{
result = { inc: 1 };
@@ -663,6 +756,11 @@ export class CheckSingleTask {
}
break;
}
case TASK_TYPE.PVP_RECEIVE_BOX: // 59. 领取x次pvp巅峰之路宝箱
{
result = { inc: 1 };
break;
}
case TASK_TYPE.PVP_WIN_SERIES: // 60. pvp连胜x次
{
let { isSuccess } = param;
@@ -688,6 +786,87 @@ export class CheckSingleTask {
break;
}
case TASK_TYPE.PVP_RANK: // 62. pvp赛季排名达到 x 名
{
let { pvpRank } = param;
let records = await getRecord();
let oldPvpRank = parseInt(records[0]);
if(isNaN(oldPvpRank)) oldPvpRank = 0;
if(pvpRank > oldPvpRank) {
records[0] = `${pvpRank}`;
result = { set: pvpRank, records }
}
break;
}
case TASK_TYPE.GUILD_JOB: // 63. 军团官职晋升为x
{
let { guildJob } = param;
let records = await getRecord();
let oldGuildJob = parseInt(records[0]);
if(isNaN(oldGuildJob)) oldGuildJob = 0;
if(guildJob > oldGuildJob) {
records[0] = `${guildJob}`;
result = { set: guildJob, records }
}
break;
}
case TASK_TYPE.GUILD_DONATE: // 64. 军团捐献x次
{
result = { inc: 1 };
break;
}
case TASK_TYPE.GUILD_RECEIVE_BOX: //65. 领取x次军团活跃宝箱
{
result = { inc: 1 };
break;
}
case TASK_TYPE.GUILD_ASSIST_REFINE: // 67. 助力炼器堂研发加速x次
{
result = { inc: 1 };
break;
}
case TASK_TYPE.GUILD_TRAIN_SUCESS: // 68. 练兵场军团成功压制x次
{
let { isSuccess } = param;
if(isSuccess) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.GUILD_BOSS: // 69. 演武台军团挑战x次boss
{
result = { inc: 1 };
break;
}
case TASK_TYPE.GUILD_TRAIN: // 70. 挑战练兵场X次
{
result = { inc: 1 };
break;
}
case TASK_TYPE.GUILD_ACTIVITY: // 71. 参与 xxx 军团活动 x 次
{
let { aid } = param;
if (dicTaskParam[0] == 0 || aid == dicTaskParam[0]) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.GUILD_JOIN: // 72. 加入军团
{
result = { set: 1 };
break;
}
case TASK_TYPE.BATTLE_MAIN_ELITE: // 73. 精英通关第x关
{
let { warId, count } = param;
let dicWar = gameData.war.get(warId);
if (dicWar.warType == WAR_TYPE.MAIN_ELITE && this.checkIdList(dicTaskParam, 0, warId)) {
result = { inc: count };
}
break;
}
case TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT: // 74. x名初始x品质武将升至X品质
{
let { hero } = param;
@@ -714,6 +893,23 @@ export class CheckSingleTask {
}
break;
}
case TASK_TYPE.GUILD_TRAIN_COUNT: // 79. 练兵场通关x关x次
{
let { warId, isComplete } = param;
if(isComplete && this.checkIdList(dicTaskParam, 0, warId)) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.HERO_UNLOCK: // 80. 名将谱x阵营全部激活
{
let { hero } = param;
let dicHero = gameData.hero.get(hero.hid);
if(dicHero && dicHero.camp == dicTaskParam[1]) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.GACHA_QUALITY_COUNT: // 81. 抽到*次品质*武将
{
let { heroes } = param;
@@ -727,6 +923,11 @@ export class CheckSingleTask {
}
break;
}
case TASK_TYPE.ROLE_TERAPH_STAGE_UP: // 82. 神像进阶
{
result = { inc: 1 };
break;
}
case TASK_TYPE.HERO_WAKE_UP_COUNT: // 84. x名武将觉醒
{
let { hero, oldColorStar } = param;
@@ -735,6 +936,271 @@ export class CheckSingleTask {
}
break;
}
case TASK_TYPE.ACTIVITY_RMB: // 86. 某个活动充值*元
{
let { count } = param;
result = { inc: count };
break;
}
case TASK_TYPE.EQUIP_LV_TO: // 87. x件装备强化至x级
{
let { oldEplace, newEplace, ePlaceIds } = param;
let addCount = 0;
for(let eplaceId of ePlaceIds) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, eplaceId);
if(oldEquip.lv < param[1] && newEquip.lv >= param[1]) {
addCount += 1;
} else if (oldEquip.lv >= param[1] && newEquip.lv < param[1]) {
addCount -= 1;
}
}
if(addCount != 0) {
result = { inc: addCount };
}
break;
}
case TASK_TYPE.EQUIP_PUT_JEWEL: // 88. x件装备镶嵌X阶天晶石
{
let { oldEquip, newEquip, jewels } = param;
let { oldJewel, newJewel } = getJewelByEquip(oldEquip, newEquip, jewels);
let oldLv = gameData.jewel.get(oldJewel?.id)?.lv || 0;
let lv = gameData.jewel.get(newJewel?.id)?.lv || 0;
if(lv >= dicTaskParam[1] && oldLv < dicTaskParam[1]) {
result = { inc: 1 };
} else if (lv < dicTaskParam[1] && oldLv >= dicTaskParam[1]) {
result = { inc: -1 };
}
break;
}
case TASK_TYPE.EQUIP_PUT_STONE: // 89. x件装备镶嵌X个地玉石
{
let { oldEquip, newEquip } = param;
let oldStoneCnt = oldEquip.stones.filter(cur => cur.stone != 0).length;
let newStoneCnt = newEquip.stones.filter(cur => cur.stone != 0).length;
if(oldStoneCnt < param[1] && newStoneCnt >= param[1]) {
result = { inc: 1 };
} else if (oldStoneCnt >= param[1] && newStoneCnt < param[1]) {
result = { inc: -1 };
}
break;
}
case TASK_TYPE.EQUIP_STAR_UP_TO: // 90. x件装备升至X星
{
let { oldEquip, newEquip } = param;
let oldStar = oldEquip?.star||0;
let star = newEquip?.star||0
if(oldStar < param[1] && star >= param[1]) {
result = { inc: 1 };
};
break;
}
case TASK_TYPE.EQUIP_STAR_UP_CNT: // 91. x件装备升星X次
{
let { hid, ePlaceId } = param;
let records = await getRecord();
let count = 0, index = -1;
for(let i = 0; i < records.length; i++) {
let arr = records[i].split('|');
if(parseInt(arr[0]) == hid && parseInt(arr[1]) == ePlaceId) {
count = parseInt(arr[2]);
index = i;
break;
}
}
if(index == -1) {
records.push(`${hid}_${ePlaceId}_${count + 1}`);
} else {
records[index] = `${hid}_${ePlaceId}_${count + 1}`;
}
if(count + 1 >= dicTaskParam[1]) {
result = { inc: 1, records }
} else {
result = { records }
}
break;
}
case TASK_TYPE.EQUIP_SUIT_SEID_NUM: // 92. x名武将激活X条套装属性
{
let { oldEplace, newEplace, hid } = param;
let dicEquipSuit = getEquipSuitByHero(hid);
let oldSuitStars: number[] = [], newSuitStars: number[] = [];
for(let equipId of dicEquipSuit.equips) {
let oldEquip = oldEplace.find(cur => cur.equipId == equipId);
oldSuitStars.push(oldEquip? oldEquip.star: 0);
let newEquip = newEplace.find(cur => cur.equipId == equipId);
newSuitStars.push(newEquip? newEquip.star: 0);
}
let oldStar = Math.min(...oldSuitStars);
let newStar = Math.min(...newSuitStars);
let oldCount = 0, count = 0;
for(let { star } of dicEquipSuit.effect) {
if(oldStar >= star) oldCount++;
if(newStar >= star) count++;
}
if(oldCount < param[1] && count >= param[1]) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.EQUIP_QUALITY_UP: // 93. x件装备进行升品
{
let { hid, ePlaceId } = param;
let records = await getRecord();
if(records.indexOf(`${hid}_${ePlaceId}`) == -1) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.EQUIP_QUALITY_UP_CNT: // 94. 装备升品X次
{
result = { inc: 1 };
break;
}
case TASK_TYPE.EQUIP_QUALITY_UP_TO: // 95. X件装备升品至Y品质
{
let { oldEquip, newEquip } = param;
let oldQuality = oldEquip?.quality||0;
let quality = newEquip?.quality||0;
if(oldQuality < param[1] && quality >= param[1]) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.EQUIP_COMPOSE: // 96. 装备X件装备
{
let { count } = param;
result = { inc: count };
break;
}
case TASK_TYPE.EQUIP_COMPOSE_CNT: // 97. x名武将各装备x件装备
{
let { oldEplace, newEplace } = param;
if(oldEplace.length < dicTaskParam[1] && newEplace.length >= dicTaskParam[1]) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.EQUIP_LV_UP: // 98. 装备强化X次
{
let { count } = param;
result = { inc: count };
break;
}
case TASK_TYPE.EQUIP_PUT_JEWEL_CNT: // 99. X件装备镶嵌天晶
{
let { oldEquip, newEquip } = param;
if(oldEquip.jewel && !newEquip.jewel) {
result = { inc: -1 };
} else if (!oldEquip.jewel && newEquip.jewel) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.EQUIP_PUT_STONE_CNT: // 100. X件装备镶嵌地玉
{
let { oldEquip, newEquip } = param;
let oldStoneCnt = oldEquip.stones.filter(cur => cur.stone != 0).length;
let newStoneCnt = newEquip.stones.filter(cur => cur.stone != 0).length;
if(oldStoneCnt > 0 && newStoneCnt == 0) {
result = { inc: -1 };
} else if (oldStoneCnt == 0 && newStoneCnt > 0) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.EQUIP_STONE_CNT: // 101. 镶嵌X个地玉
{
let { oldEquip, newEquip } = param;
let oldStoneCnt = oldEquip.stones.filter(cur => cur.stone != 0).length;
let newStoneCnt = newEquip.stones.filter(cur => cur.stone != 0).length;
result = { inc: newStoneCnt - oldStoneCnt };
break;
}
case TASK_TYPE.EQUIP_STONE_CNT_LV: // 102. X件装备镶嵌X个大于等于X阶地玉
{
let { oldEquip, newEquip } = param;
let oldStoneLvs = oldEquip.stones.map(cur => {
let dicStone = gameData.stone.get(cur.stone);
return dicStone?dicStone.lv: 0;
});
let newStoneLvs = newEquip.stones.map(cur => {
let dicStone = gameData.stone.get(cur.stone);
return dicStone?dicStone.lv: 0;
});
let oldCount = oldStoneLvs.filter(lv => lv >= param[2]).length;
let newCount = newStoneLvs.filter(lv => lv >= param[2]).length;
if(oldCount < param[1] && newCount >= param[1]) {
result = { inc: 1 };
} else if (oldCount >= param[1] && newCount < param[1]) {
result = { inc: -1 }
}
break;
}
case TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT: // 103.X个天晶的Y条特性词条被激活
{
let { oldEquip, newEquip, jewels } = param;
let { oldJewel, newJewel } = getJewelByEquip(oldEquip, newEquip, jewels);
let oldRandSe = oldJewel?.randSe||[];
let oldUnlockSeCnt = oldRandSe.filter(se => {
return isRandSeUnLock(oldJewel.id, se.id, oldEquip.stones);
}).length;
let newRandSe = newJewel?.randSe||[];
let newUnlockSeCnt = newRandSe.filter(se => {
return isRandSeUnLock(newJewel.id, se.id, newEquip.stones);
}).length;
if(oldUnlockSeCnt < param[1] && newUnlockSeCnt >= param[1]) {
result = { inc: -1 };
} else if (oldUnlockSeCnt >= param[1] && newUnlockSeCnt < param[1]) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.STONE_COMPOSE: // 104. 地玉合成X次
{
let { count } = param;
result = { inc: count };
break;
}
case TASK_TYPE.JEWEL_RESET: // 105. 天晶洗炼X次
{
result = { inc: 1 };
break;
}
case TASK_TYPE.JEWEL_QUENCH: // 106. 天晶淬炼X次
{
result = { inc: 1 };
break;
}
case TASK_TYPE.JEWEL_QUENCH_SUCCESS: // 107. 天晶成功淬炼X次
{
let { isSuccess } = param;
if(isSuccess) {
result = { inc: 1 };
}
break;
}
case TASK_TYPE.COM_BATTLE_LV: // 108. 寻宝x品阶x次
{
let { gid } = param;
let dicJewel = getDicBlueprtById(gid);
if(dicTaskParam[0] == dicJewel.lv) {
result = { inc: 1 };
}
break
}
case TASK_TYPE.GUILD_REFINE: // 109. 炼器堂兑换X品阶天晶X次
{
let { quality, count } = param;
if(dicTaskParam[0] == quality) {
result = { inc: count };
}
break;
}
}
return result
}
+117 -16
View File
@@ -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);