diff --git a/game-server/app/servers/role/handler/equipHandler.ts b/game-server/app/servers/role/handler/equipHandler.ts index 3bf1e7f22..bc20e121c 100644 --- a/game-server/app/servers/role/handler/equipHandler.ts +++ b/game-server/app/servers/role/handler/equipHandler.ts @@ -8,12 +8,12 @@ import { HeroModel, EPlace } from "../../../db/Hero"; import { calPlayerCeAndSave } from "../../../services/playerCeService"; import { gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipStarIdByEquipId, getNextEquipStar } from "../../../pubUtils/data"; import { BAG, EQUIP } from "../../../pubUtils/dicParam"; -import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip } from "../../../services/equipService"; +import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, checkTaskInComposeEquip, checkTaskInEquipLvUp, checkTaskInComposeStone, checkTaskInEquipReset, checkTaskInEquipQuench } from "../../../services/equipService"; import { isNumber, pick } from 'underscore'; import { JewelModel } from "../../../db/Jewel"; import { getJewelRandSe } from "../../../pubUtils/itemUtils"; -import { checkTask, checkTaskInPutJewel, checkTaskWithEplaces, checkTaskWithHero } from "../../../services/taskService"; +import { checkTaskInEquipQualityUp, checkTaskInEquipStarUp, checkTaskInPutJewel, checkTaskInPutStone } from '../../../services/equipService'; export default function (app: Application) { new HandlerService(app, {}); @@ -28,6 +28,8 @@ export class EquipHandler { public async composeEquip(msg: { hid: number, ePlaceId: number }, session: BackendSession) { let roleId: string = session.get('roleId'); let sid: string = session.get('sid'); + let serverId: number = session.get('serverId'); + let { hid, ePlaceId } = msg; if(!isNumber(ePlaceId) || ePlaceId > 4 || ePlaceId < 1) return resResult(STATUS.WRONG_PARMS); @@ -49,9 +51,7 @@ export class EquipHandler { let newEplace = [...oldEplace, newEquip]; hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COMPOSE_EQUIP, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]); - - await checkTask(roleId, sid, TASK_TYPE.EQUIP_COMPOSE, 1, true, {}); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_COMPOSE_CNT, oldEplace, newEplace, [ePlaceId], {}); + await checkTaskInComposeEquip(serverId, roleId, sid, oldEplace, newEplace, ePlaceId); return resResult(STATUS.SUCCESS, { curHero: { @@ -95,9 +95,7 @@ export class EquipHandler { let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, { lv: newLv }); hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]); - - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_LV_TO, oldEplace, newEplace, [ePlaceId]); - await checkTask(roleId, sid, TASK_TYPE.EQUIP_LV_UP, 1, true, {}); + await checkTaskInEquipLvUp(serverId, roleId, sid, oldEplace, newEplace, [ePlaceId]); const curHero = { hid, @@ -110,7 +108,7 @@ export class EquipHandler { // 装备栏一键强化至相应等级 public async strengthenAll(msg: { hid: number, lv: number }, session: BackendSession) { let roleId: string = session.get('roleId'); - // let roleName: string = session.get('roleName'); + let serverId: number = session.get('serverId'); let sid: string = session.get('sid'); let { hid, lv } = msg; // lv: 升到哪一级 @@ -144,9 +142,7 @@ export class EquipHandler { let { newEplace, updatedEplace } = updateEplaces(ePlace, eplaceIds); await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, { ePlace: newEplace }, [...eplaceIds.keys()]); - - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_LV_TO, ePlace, newEplace, [...eplaceIds.keys()]); - await checkTask(roleId, sid, TASK_TYPE.EQUIP_LV_UP, eplaceIds.size, true, {}); + await checkTaskInEquipLvUp(serverId, roleId, sid, ePlace, newEplace, [...eplaceIds.keys()]); const curHero = { hid, @@ -209,10 +205,7 @@ export class EquipHandler { let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, update); hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_QUALITY, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]); - if(isUpQuality) { - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP, oldEplace, newEplace, [ePlaceId], { hid }); - await checkTask(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1, true, {}); - } + await checkTaskInEquipQualityUp(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, hid, isUpQuality); const curHero = { hid, isUpQuality, @@ -282,11 +275,7 @@ export class EquipHandler { let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, update); hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STAR, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId]); - if(isUpStar) { - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_TO, oldEplace, newEplace, [ePlaceId]); - await checkTask(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, true, {}); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_SUIT_SEID_NUM, oldEplace, newEplace, [ePlaceId], { hid }); - } + await checkTaskInEquipStarUp(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, hid, isUpStar); const curHero = { hid, @@ -302,6 +291,7 @@ export class EquipHandler { let { hid, ePlaceId, jewel: seqId } = msg; let roleId: string = session.get('roleId'); let sid: string = session.get('sid'); + let serverId: number = session.get('serverId'); let hero = await HeroModel.findByHidAndRole(hid, roleId); if (!hero) return resResult(STATUS.HERO_NOT_FIND); @@ -328,7 +318,7 @@ export class EquipHandler { if(canChange) canSentMineToOrigin = true; let { newEplace, updatedEplace } = updateEplace(originEplace, ePlaceId, { jewel: canChange? originJewel.seqId: 0 }); await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, originHero, { ePlace: newEplace }, [ePlaceId], { oldJewel: jewel, newJewel: canChange? originJewel:null }); - await checkTaskInPutJewel(roleId, sid, originEplace, newEplace, ePlaceId, jewel, canChange? originJewel:null); + await checkTaskInPutJewel(serverId, roleId, sid, originEplace, newEplace, ePlaceId, jewel, canChange? originJewel:null); originHeroResult = { hid: originHero.hid, ePlace: updatedEplace }; } @@ -341,7 +331,7 @@ export class EquipHandler { let curJewel = await JewelModel.putOnOrOff(seqId, hid, ePlaceId); let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, { jewel: seqId }); await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId], { oldJewel: originJewel, newJewel: curJewel }); - await checkTaskInPutJewel(roleId, sid, oldEplace, newEplace, ePlaceId, originJewel, curJewel); + await checkTaskInPutJewel(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, originJewel, curJewel); let curHero = { hid, @@ -356,6 +346,7 @@ export class EquipHandler { let { hid, ePlaceId } = msg; let roleId: string = session.get('roleId'); let sid: string = session.get('sid'); + let serverId: number = session.get('serverId'); let hero = await HeroModel.findByHidAndRole(hid, roleId); if (!hero) return resResult(STATUS.HERO_NOT_FIND); @@ -368,7 +359,7 @@ export class EquipHandler { let curJewel = await JewelModel.putOnOrOff(curEquip.jewel, 0, 0); let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, { jewel: 0 }); await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_JEWEL, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId], { oldJewel: curJewel }); - await checkTaskInPutJewel(roleId, sid, oldEplace, newEplace, ePlaceId, null, curJewel); + await checkTaskInPutJewel(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, null, curJewel); let curHero = { hid, @@ -384,6 +375,7 @@ export class EquipHandler { let roleId: string = session.get('roleId'); let roleName: string = session.get('roleName'); let sid: string = session.get('sid'); + let serverId: number = session.get('sid'); let hero = await HeroModel.findByHidAndRole(hid, roleId); if (!hero) return resResult(STATUS.HERO_NOT_FIND); @@ -411,10 +403,7 @@ export class EquipHandler { let { newEplace, updatedEplace } = updateEplace(oldEplace, ePlaceId, { stones: newStone }); let jewel = await JewelModel.findbySeqId(curEquip.jewel); await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STONE, sid, roleId, hero, { ePlace: newEplace }, [ePlaceId], { jewel }); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE, oldEplace, newEplace, [ePlaceId]); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT, oldEplace, newEplace, [ePlaceId]); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT_LV, oldEplace, newEplace, [ePlaceId]); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEplace, newEplace, [ePlaceId], { jewels: [ jewel ] }); + await checkTaskInPutStone(serverId, roleId, sid, oldEplace, newEplace, ePlaceId, jewel); let curHero = { hid, @@ -517,9 +506,8 @@ export class EquipHandler { // 装备洗炼 public async resetRandSe(msg: { seqId: number }, session: BackendSession) { let roleId: string = session.get('roleId'); - // let roleName: string = session.get('roleName'); + let serverId: number = session.get('serverId'); let sid: string = session.get('sid'); - let { seqId } = msg; let jewel = await JewelModel.findbySeqId(seqId); @@ -537,8 +525,7 @@ export class EquipHandler { await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, sid, roleId, hero, {}, [ePlaceId], { oldJewel: jewel, newJewel }); } - await checkTask(roleId, sid, TASK_TYPE.JEWEL_RESET, 1, true, {}); - + await checkTaskInEquipReset(serverId, roleId, sid); return resResult(STATUS.SUCCESS, { curJewel: pick(newJewel, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) }); } @@ -591,7 +578,7 @@ export class EquipHandler { // 淬火 public async quench(msg: { seqId: number }, session: BackendSession) { let roleId: string = session.get('roleId'); - // let roleName: string = session.get('roleName'); + let serverId: number = session.get('serverId'); let sid: string = session.get('sid'); let { seqId } = msg; @@ -620,9 +607,7 @@ export class EquipHandler { await calPlayerCeAndSave(HERO_SYSTEM_TYPE.JEWEL_QUENCH, sid, roleId, hero, {}, [ePlaceId], { oldJewel: jewel, newJewel }); } - await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH, 1, true, {}); - if(isSuccess) await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1, true, {}); - + await checkTaskInEquipQuench(serverId, roleId, sid, isSuccess); return resResult(STATUS.SUCCESS, { isSuccess, curJewel: pick(newJewel, ['seqId', 'id', 'hid', 'ePlaceId', 'randSe', 'previewRandSe']) }); } @@ -688,6 +673,7 @@ export class EquipHandler { let roleId: string = session.get('roleId'); let roleName: string = session.get('roleName'); let sid: string = session.get('sid'); + let serverId: number = session.get('serverId'); let check = new CheckMeterial(roleId); let isEnough = await check.composeStone(id, count); @@ -698,7 +684,8 @@ export class EquipHandler { if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH); let goods = await addItems(roleId, roleName, sid, [{ id, count }], ITEM_CHANGE_REASON.COMPOSE_STONE); - await checkTask(roleId, sid, TASK_TYPE.STONE_COMPOSE, count, true, {}); + + await checkTaskInComposeStone(serverId, roleId, sid, count); return resResult(STATUS.SUCCESS, { goods }); } diff --git a/game-server/app/services/equipService.ts b/game-server/app/services/equipService.ts index d4b6c2b81..8e1eceae6 100644 --- a/game-server/app/services/equipService.ts +++ b/game-server/app/services/equipService.ts @@ -3,6 +3,8 @@ import { EPlace, Stone } from "../db/Hero"; import { gameData } from "../pubUtils/data"; import { JewelType, RandSe } from '../db/Jewel'; import { getJewelRandSe } from '../pubUtils/itemUtils'; +import { checkActivityTask, checkTask, checkTaskWithEplaces, checkTaskWithEplace } from './taskService'; +import { TASK_TYPE } from '../consts'; export function getRandSeResult(id: number, randSe: RandSe[]) { let { randomEffect, effectCount } = gameData.jewel.get(id); @@ -103,4 +105,92 @@ export function checkStoneCanPutOnEquip(equip: EPlace, id: number, stone: number let dicEquipQualityExtra = gameData.equipQualityExtra.get(equip.quality); if(!dicEquipQualityExtra || dicEquipQualityExtra.stoneCnt < id) return false; return true; -} \ No newline at end of file +} + +export async function checkTaskInComposeEquip(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number) { + await checkTask(roleId, sid, TASK_TYPE.EQUIP_COMPOSE, newEplace.length - oldEplace.length, true, {}); + await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_COMPOSE_CNT, oldEplace, newEplace, [ePlaceId]); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_COMPOSE, newEplace.length - oldEplace.length); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_COMPOSE_CNT, 1, { oldEplace, newEplace }); +} + +export async function checkTaskInEquipLvUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceIds: number[]) { + await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_LV_TO, oldEplace, newEplace, ePlaceIds); + await checkTask(roleId, sid, TASK_TYPE.EQUIP_LV_UP, ePlaceIds.length, true, {}); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_LV_TO, 1, { oldEplace, newEplace, ePlaceIds }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_LV_UP, ePlaceIds.length, true); +} + +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); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL, oldEquip, newEquip, { jewels: [originJewel, curJewel ] }); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, oldEquip, newEquip); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEquip, newEquip, { jewels: [originJewel, curJewel ] }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_JEWEL, 1, { oldEquip, newEquip, jewels: [originJewel, curJewel ] }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, 1, { oldEquip, newEquip }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, 1, { oldEquip, newEquip, jewels: [originJewel, curJewel ] }); +} + +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); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE, oldEquip, newEquip); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE_CNT, oldEquip, newEquip); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT, oldEquip, newEquip); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT_LV, oldEquip, newEquip); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEquip, newEquip, { jewels: [ jewel ] }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_STONE, 1, { oldEquip, newEquip }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_STONE_CNT, 1, { oldEquip, newEquip }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STONE_CNT, 1, { oldEquip, newEquip }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STONE_CNT_LV, 1, { oldEquip, newEquip }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, 1, { oldEquip, newEquip, jewels: [ jewel ] }); +} + +export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean) { + if(isUpStar) { + let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_TO, oldEquip, newEquip); + await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_SUIT_SEID_NUM, oldEplace, newEplace, [ePlaceId], { hid }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STAR_UP_TO, 1, { oldEquip, newEquip }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUIT_SEID_NUM, 1, { oldEplace, newEplace, ePlaceId, hid }); + } + await checkTask(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, true, {}); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, {}); +} + +export async function checkTaskInEquipQualityUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpQuality: boolean) { + if(isUpQuality) { + let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP, oldEquip, newEquip, { hid }); + await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_TO, oldEquip, newEquip); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP, 1, { ePlaceId, hid }); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP_TO, 1, { oldEquip, newEquip, hid }); + } + await checkTask(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1, true, {}); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1); +} + +export async function checkTaskInEquipReset(serverId: number, roleId: string, sid: string) { + await checkTask(roleId, sid, TASK_TYPE.JEWEL_RESET, 1, true, {}); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_RESET, 1); +} + +export async function checkTaskInEquipQuench(serverId: number, roleId: string, sid: string, isSuccess: boolean) { + await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH, 1, true, {}); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_QUENCH, 1); + if(isSuccess) { + await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1, true, {}); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1); + } +} + +export async function checkTaskInComposeStone(serverId: number, roleId: string, sid: string, count: number) { + await checkTask(roleId, sid, TASK_TYPE.STONE_COMPOSE, count, true, {}); + await checkActivityTask(serverId, sid, roleId, TASK_TYPE.STONE_COMPOSE, count); +} + + +function getEquipById(oldEplace: EPlace[], newEplace: EPlace[], eplaceId: number) { + let oldEquip = oldEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); + let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); + return { oldEquip, newEquip } +} diff --git a/game-server/app/services/taskService.ts b/game-server/app/services/taskService.ts index d7c8d3468..da11a5607 100644 --- a/game-server/app/services/taskService.ts +++ b/game-server/app/services/taskService.ts @@ -40,10 +40,10 @@ export async function checkTaskWithEplaces(roleId: string, sid: string, taskType pushTaskUpdate(roleId, sid, pushMessage); } -// export async function checkTaskWithEquip(roleId: string, sid: string, taskType: number, equip: EquipType, args?: number[]) { -// let pushMessage = await taskUtil.checkTaskWithEquip(roleId, taskType, equip, args); -// pushTaskUpdate(roleId, sid, pushMessage); -// } +export async function checkTaskWithEplace(roleId: string, sid: string, taskType: number, oldEquip: EPlace, newEplace: EPlace, params?: any) { + let pushMessage = await taskUtil.checkTaskWithEplace(roleId, taskType, oldEquip, newEplace, params); + pushTaskUpdate(roleId, sid, pushMessage); +} export async function checkTaskWithArgs(roleId: string, sid: string, taskType: number, args: number[]) { let pushMessage = await taskUtil.checkTaskWithArgs(roleId, taskType, args); @@ -300,12 +300,6 @@ export async function getPvpTask(roleId: string) { return { taskList } } -export async function checkTaskInPutJewel(roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, originJewel: JewelType, curJewel: JewelType) { - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL, oldEplace, newEplace, [ePlaceId], { jewels: [originJewel, curJewel ] }); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, oldEplace, newEplace, [ePlaceId]); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEplace, newEplace, [ePlaceId], { jewels: [originJewel, curJewel ] }); -} - // 刷新每日任务 export async function refDailyTask(roleId: string, sid: string) { let userTask = await UserTaskModel.findByRole(roleId); diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index 1a0a48ede..161c78923 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -871,7 +871,6 @@ function treatTaskGroup() { let taskByGroup = new Map(); // taskType => obj for(let [taskType, tasks] of gameData.taskType) { for(let obj of tasks) { - console.log('#####', taskType, obj.type, obj.id) let dicTaskType = taskType2Desc.get(taskType); let index = dicTaskType.param.split('&').indexOf(dicTaskType.condition); let params = obj.taskParam.filter((_, i) => index != i); diff --git a/shared/pubUtils/playerCe.ts b/shared/pubUtils/playerCe.ts index 5142ecb7a..6e69c54a6 100644 --- a/shared/pubUtils/playerCe.ts +++ b/shared/pubUtils/playerCe.ts @@ -822,7 +822,6 @@ function addSeidEffect(heroAttrs: CeAttrData[], addSeidList: Array, remo // 获取dic_zyz_se内容 function addSeid(effectList: Array, seidId: number, rand: number, seidValue = new Array()) { - console.log('##### addSeid', effectList, seidId, rand, seidValue) let curSeid: DicSe | DicRandomEffectPool = gameData.se.get(seidId); if (!curSeid) curSeid = gameData.randomEffectPool.get(seidId); if (!curSeid) { console.log("seidId not found:" + seidId); return; } @@ -835,7 +834,6 @@ function addSeid(effectList: Array, seidId: number, rand: number, seidValue return; } let seid: DicSe | DicRandomEffectPool = deepCopy(curSeid); - console.log('#####', seid) if (curSeid.index > 0) { seid.gainValueArr[curSeid.index - 1] = rand; } diff --git a/shared/pubUtils/taskUtil.ts b/shared/pubUtils/taskUtil.ts index fdf747f5f..345b64b71 100644 --- a/shared/pubUtils/taskUtil.ts +++ b/shared/pubUtils/taskUtil.ts @@ -152,11 +152,11 @@ export async function checkTaskWithEplaces(roleId: string, taskType: number, old pushMessage = await checkTask(roleId, taskType, 1, true, { oldCount, count }); } else if (taskType == TASK_TYPE.EQUIP_COMPOSE_CNT) { - pushMessage = await checkTask(roleId, taskType, newEplace.length - oldEplace.length, true, {}); + pushMessage = await checkTask(roleId, taskType, 1, true, { oldCount: oldEplace.length, count: newEplace.length }); + } else { for(let eplaceId of eplaceIds) { - let oldEquip = oldEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); - let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); + let { oldEquip, newEquip } = getEquipById({ oldEplace, newEplace, eplaceId }); let result = await checkTaskWithEplace(roleId, taskType, oldEquip, newEquip, params); pushMessage.push(...result); } @@ -176,10 +176,8 @@ export async function checkTaskWithEplace(roleId: string, taskType: number, oldE pushMessage = await checkTask(roleId, taskType, 1, true, { oldLv: oldEquip.lv, lv: newEquip.lv }) } else if (taskType == TASK_TYPE.EQUIP_PUT_JEWEL) { - let jewels: JewelType[] = params.jewels; - let oldJewel = jewels.find(cur => cur && cur.seqId == oldEquip.jewel); + let { oldJewel, newJewel } = getJewelByEquip(oldEquip, newEquip, { jewels: params.jewels }); let oldLv = gameData.jewel.get(oldJewel?.id)?.lv || 0; - let newJewel = jewels.find(cur => cur && cur.seqId == newEquip.jewel); let lv = gameData.jewel.get(newJewel?.id)?.lv || 0; pushMessage = await checkTask(roleId, taskType, 1, true, { oldLv, lv }); } @@ -230,14 +228,13 @@ export async function checkTaskWithEplace(roleId: string, taskType: number, oldE pushMessage = await checkTask(roleId, taskType, 1, true, { oldStoneLvs, newStoneLvs }); } else if (taskType == TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT) { - let jewels: JewelType[] = params.jewels; - let oldJewel = jewels.find(cur => cur && cur.seqId == oldEquip.jewel); + let { oldJewel, newJewel } = getJewelByEquip(oldEquip, newEquip, { jewels: params.jewels }); + let oldRandSe = oldJewel.randSe||[]; let oldUnlockSeCnt = oldRandSe.filter(se => { return isRandSeUnLock(oldJewel.id, se.id, oldEquip.stones); }).length; - let newJewel = jewels.find(cur => cur && cur.seqId == newEquip.jewel); let newRandSe = newJewel.randSe||[]; let newUnlockSeCnt = newRandSe.filter(se => { return isRandSeUnLock(newJewel.id, se.id, newEquip.stones); @@ -250,6 +247,22 @@ export async function checkTaskWithEplace(roleId: string, taskType: number, oldE return pushMessage } + + +function getEquipById(paramObj: {oldEplace: EPlace[], newEplace: EPlace[], eplaceId: number}) { + let { oldEplace, newEplace, eplaceId } = paramObj; + let oldEquip = oldEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); + let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); + return { oldEquip, newEquip } +} + +function getJewelByEquip(oldEquip: EPlace, newEquip: EPlace, paramObj: { jewels: JewelType[] }) { + let jewels: JewelType[] = paramObj.jewels; + let oldJewel = jewels.find(cur => cur && cur.seqId == oldEquip.jewel); + let newJewel = jewels.find(cur => cur && cur.seqId == newEquip.jewel); + return { oldJewel, newJewel } +} + // export async function checkTaskWithEquip(roleId: string, taskType: number, equip: EquipType, args: number[] = []) { // let pushMessage = new Array(); // if (taskType == TASK_TYPE.EQUIP_QUALITY) { @@ -557,6 +570,9 @@ export async function checkTaskRec(roleId: string, type: number, group: string, count = -1; } break; + case TASK_TYPE.EQUIP_COMPOSE_CNT: + isMatch = param.oldCount < taskParam[1] && param.count >= taskParam[1]; + break; } // console.log('****isMatch', isMatch, checkHistory, type, taskType, group, count) @@ -1316,6 +1332,204 @@ export function isComplete(_roleId: string, taskType: TASK_TYPE, taskParam: stri case TASK_TYPE.ROLE_SCROLL_ACTIVE: addCount = count; break; + case TASK_TYPE.EQUIP_LV_TO: + { + for(let eplaceId of paramObj.eplaceIds) { + let { oldEquip, newEquip } = getEquipById({ ...paramObj, eplaceId }); + if(oldEquip.lv < param[1] && newEquip.lv >= param[1]) { + addCount += 1; + } else if (oldEquip.lv >= param[1] && newEquip.lv < param[1]) { + addCount -= 1; + } + } + break; + } + case TASK_TYPE.EQUIP_PUT_JEWEL: + { + let { oldEquip, newEquip } = paramObj; + let { oldJewel, newJewel } = getJewelByEquip(oldEquip, newEquip, paramObj); + let oldLv = gameData.jewel.get(oldJewel?.id)?.lv || 0; + let lv = gameData.jewel.get(newJewel?.id)?.lv || 0; + + if(lv >= param[1] && oldLv < param[1]) { + addCount = count; + } else if (lv < param[1] && oldLv >= param[1]) { + addCount = -count; + } + break; + } + case TASK_TYPE.EQUIP_PUT_STONE: + { + let { oldEquip, newEquip } = paramObj; + 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]) { + addCount = count; + } else if (oldStoneCnt >= param[1] && newStoneCnt < param[1]) { + addCount = -count; + } + break; + } + case TASK_TYPE.EQUIP_STAR_UP_TO: + { + let { oldEquip, newEquip } = paramObj; + let oldStar = oldEquip?.star||0; + let star = newEquip?.star||0 + if(oldStar < param[1] && star >= param[1]) addCount = count; + break; + } + case TASK_TYPE.EQUIP_STAR_UP_CNT: + addCount = count; + break; + case TASK_TYPE.EQUIP_SUIT_SEID_NUM: + { + let dicEquipSuit = getEquipSuitByHero(paramObj.hid); + let oldSuitStars: number[] = [], newSuitStars: number[] = []; + for(let equipId of dicEquipSuit.equips) { + let oldEquip = paramObj.oldEplace.find(cur => cur.equipId == equipId); + oldSuitStars.push(oldEquip? oldEquip.star: 0); + let newEquip = paramObj.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]) { + addCount = count; + } + break; + } + case TASK_TYPE.EQUIP_QUALITY_UP: + { + let r = `${paramObj.hid}_${paramObj.eplaceId}`; + if (recordData) { + record = recordData; + if (recordData.indexOf(r) != -1) { + break; + } + } else { + record = []; + } + + addCount = count; + record.push(r) + break; + } + case TASK_TYPE.EQUIP_QUALITY_UP_CNT: + addCount = count; + break; + case TASK_TYPE.EQUIP_QUALITY_UP_TO: + { + let { oldEquip, newEquip } = paramObj; + let oldQuality = oldEquip?.quality||0; + let quality = newEquip?.quality||0; + if(oldQuality < param[1] && quality >= param[1]) { + addCount = count; + } + break; + } + case TASK_TYPE.EQUIP_COMPOSE: + addCount = count; + break; + case TASK_TYPE.EQUIP_COMPOSE_CNT: + { + if(paramObj.oldEplace.length < param[1] && paramObj.newEplace.length >= param[1]) { + addCount = count; + } + break; + } + case TASK_TYPE.EQUIP_LV_UP: + addCount = count; + break; + case TASK_TYPE.EQUIP_PUT_JEWEL_CNT: + { + let { oldEquip, newEquip } = paramObj; + if(oldEquip.jewel && !newEquip.jewel) { + addCount = -count; + } else if (!oldEquip.jewel && newEquip.jewel) { + addCount = count; + } + break; + } + case TASK_TYPE.EQUIP_PUT_STONE_CNT: + { + let { oldEquip, newEquip } = paramObj; + 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) { + addCount = -count; + } else if (oldStoneCnt == 0 && newStoneCnt > 0) { + addCount = count; + } + break; + } + case TASK_TYPE.EQUIP_STONE_CNT: + { + let { oldEquip, newEquip } = paramObj; + let oldStoneCnt = oldEquip.stones.filter(cur => cur.stone != 0).length; + let newStoneCnt = newEquip.stones.filter(cur => cur.stone != 0).length; + addCount = newStoneCnt - oldStoneCnt; + break; + } + case TASK_TYPE.EQUIP_STONE_CNT_LV: + { + let { oldEquip, newEquip } = paramObj; + 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]) { + addCount = count; + } else if (oldCount >= param[1] && newCount < param[1]) { + addCount = -count; + } + break; + } + case TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT: + { + let { oldEquip, newEquip } = paramObj; + let { oldJewel, newJewel } = getJewelByEquip(oldEquip, newEquip, { jewels: paramObj.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]) { + addCount = count; + } else if (oldUnlockSeCnt >= param[1] && newUnlockSeCnt < param[1]) { + addCount = -count; + } + break; + } + case TASK_TYPE.STONE_COMPOSE: + addCount = count; + break; + case TASK_TYPE.JEWEL_RESET: + addCount = count; + break; + case TASK_TYPE.JEWEL_QUENCH: + addCount = count; + break; + case TASK_TYPE.JEWEL_QUENCH_SUCCESS: + addCount = count; + break; default: addCount = 0; break;