任务:修复装备穿戴bug

This commit is contained in:
luying
2022-01-04 14:22:47 +08:00
parent 6ce57740cf
commit 59f3f5c07d
4 changed files with 14 additions and 8 deletions

View File

@@ -619,6 +619,8 @@ export class EquipHandler {
// 原武将heroA原武将穿戴着的装备a将要穿戴的装备b装备b被装备着的武将B
let heroA = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
if (!heroA) return resResult(STATUS.HERO_NOT_FIND);
let oldCountA = heroA.ePlace.filter(cur => cur.equip).length;
let oldCountB = 0;
let equip = await EquipModel.getEquip(eid); // 装备1-equipB 2-equipA
if(!equip) return resResult(STATUS.EQUIP_NOT_FIND);
@@ -643,6 +645,7 @@ export class EquipHandler {
if(equipB.hid > 0) {
heroB = await HeroModel.findByHidAndRoleWithEquip(equipB.hid, roleId);
argsB = calEquipSeids(heroB);
oldCountB = heroB.ePlace.filter(cur => cur.equip).length;
}
if(equipA) {
@@ -680,12 +683,12 @@ export class EquipHandler {
if(heroA) {
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, heroA, {}, argsA);
if(heroAPutNum != 0) {
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, heroA, [heroAPutNum]);
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, heroA, [heroAPutNum, oldCountA]);
}
}
if(heroB) {
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, heroB, {}, argsB);
if(heroBPutTNum != 0) await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, heroA, [heroBPutTNum]);
if(heroBPutTNum != 0) await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, heroA, [heroBPutTNum, oldCountB]);
}
if(heroAPutNum + heroBPutTNum != 0) {
await checkTask(roleId, sid, TASK_TYPE.EQUIP_SUM, heroAPutNum + heroBPutTNum, true, {});
@@ -742,6 +745,7 @@ export class EquipHandler {
return { id, quality, ce, equip, goodsAbility, lvLimited, ePlaceId }
});
let { ePlace, lv } = hero;
let oldCount = ePlace.filter(cur => cur.equip).length;
let curEquips: Array<{ seqId: number, hid: number }> = [];
let equips: EquipType[] = [];
@@ -775,7 +779,7 @@ export class EquipHandler {
}
if (curEquips.length > 0) {
//任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [1]);
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [1, oldCount]);
await checkTask(roleId, sid, TASK_TYPE.EQUIP_SUM, curEquips.length, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUM, curEquips.length);
for(let equip of equips) {

View File

@@ -569,6 +569,7 @@ export class HeroHandler {
if (!dicSkin) return resResult(STATUS.HERO_SKIN_NOT_FIND);
let hero = await HeroModel.findByHidAndRoleWithEquip(dicSkin.actorId, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldCount = hero.ePlace.filter(cur => cur.equip).length;
let newHeroSkins: HeroSkin[] = [];
let result = false;
@@ -613,7 +614,7 @@ export class HeroHandler {
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, oldEquipSeids);
await checkTask(roleId, sid, TASK_TYPE.EQUIP_SUM, heroPutNum, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUM, heroPutNum);
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [heroPutNum]);
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [heroPutNum, oldCount]);
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.SKIN, sid, roleId, hero, { skins: newHeroSkins, skinId: dicSkin.heroId, job: dicNewJob.jobid, ePlace: newEplace });

View File

@@ -137,13 +137,14 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
}
}
for(let [_hid, {hero, equips} ] of heroMap) {
let oldCount = hero.ePlace.filter(cur => cur.equip).length;
let args = calEquipSeids(hero);
for(let equip of equips) {
hero = await HeroModel.removeEquip(roleId, hero.hid, equip.ePlaceId, equip._id);
}
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, args);
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [-1]);
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [-1, oldCount]);
}

View File

@@ -133,7 +133,7 @@ export async function checkTaskWithHero(roleId: string, taskType: number, hero:
// arg[0] 1穿上 -1脱下
let { ePlace } = hero;
let count = ePlace.filter(cur => cur.equip).length;
pushMessage = await checkTask(roleId, taskType, args[0], true, { count, isPutOn: args[0] });
pushMessage = await checkTask(roleId, taskType, args[0], true, { count, isPutOn: args[0], oldCount: args[1] });
}
else if (taskType == TASK_TYPE.EQUIP_STRENGTHEN) {
// args: 依次为原先的装备的强化等级
@@ -372,9 +372,9 @@ export async function checkTaskRec(roleId: string, type: number, group: string,
break;
case TASK_TYPE.EQUIP_BY_HERO:
isMatch = false;
if (param.isPutOn == 1 && param.count == taskParam[1]) { // 装上之后达到 +1
if (param.isPutOn == 1 && param.count >= taskParam[1] && param.oldCount < taskParam[1] ) { // 装上之后达到 +1
isMatch = true;
} else if (param.isPutOn == -1 && param.count < taskParam[1]) { // 脱下后不能达到 -1
} else if (param.isPutOn == -1 && param.count < taskParam[1] && param.oldCount >= taskParam[1]) { // 脱下后不能达到 -1
isMatch = true;
}
break;