任务:按条件开启任务
This commit is contained in:
@@ -54,7 +54,7 @@ export function checkMaterialEnough(consumes:Array<{id: number, count: number}>,
|
||||
* @param id 装备类型
|
||||
* @param seqId 要装上的装备的唯一id 装备B
|
||||
*/
|
||||
export async function changeEquip(roleId: string, sid: string, equipA: EquipType, hid: number, id: number, equipB: EquipType) {
|
||||
export async function changeEquip(roleId: string, sid: string, equipA: EquipType, hid: number, id: number, equipB: EquipType, funcs: number[]) {
|
||||
let heroB: HeroType;
|
||||
if (!!hid) //需要卸下或者替换的武将
|
||||
heroB = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);//需要替换的武将
|
||||
@@ -63,24 +63,24 @@ export async function changeEquip(roleId: string, sid: string, equipA: EquipType
|
||||
if (!!heroB) {
|
||||
let goodInfo = getGoodById(equipA.id);
|
||||
if (goodInfo.lvLimited > heroB.lv) {
|
||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id);//卸下装备并重算战力
|
||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
||||
return res;
|
||||
}
|
||||
let { jobid } = gameData.hero.get(hid);
|
||||
let { job_class } = getHeroJob(jobid);
|
||||
let { classId } = getHeroEquipByClassId(goodInfo.itid);
|
||||
if (indexOf(classId, job_class) < 0) {
|
||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id);//卸下装备并重算战力
|
||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
||||
return res;
|
||||
}
|
||||
let res = await dressEquip(roleId, sid, heroB, equipA);//替换给武将,并计算战力
|
||||
let res = await dressEquip(roleId, sid, heroB, equipA, funcs);//替换给武将,并计算战力
|
||||
return res;
|
||||
} else {
|
||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id);//卸下装备并重算战力
|
||||
let res = await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
||||
return res;
|
||||
}
|
||||
} else if (!!heroB) {//从穿戴装备的武将上卸下装备
|
||||
await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id);//卸下装备并重算战力
|
||||
await takeOffEquipAndCalPlayerCe(roleId, sid, heroB, equipB, id, funcs);//卸下装备并重算战力
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -91,16 +91,16 @@ export async function changeEquip(roleId: string, sid: string, equipA: EquipType
|
||||
* @param hero
|
||||
* @param id
|
||||
*/
|
||||
export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, hero:HeroType, equip: EquipType, id: number ) {
|
||||
export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, hero:HeroType, equip: EquipType, id: number, funcs: number[] ) {
|
||||
let args = calEquipSeids(hero);
|
||||
hero = await HeroModel.removeEquip(roleId, hero.hid, id, equip._id);
|
||||
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, args);
|
||||
|
||||
// 任务
|
||||
await checkTask(roleId, sid, TASK_TYPE.EQUIP_SUM, 1, true, {});
|
||||
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [1]);
|
||||
await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_QUALITY, equip, [1]);
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.EQUIP_SUM, 1, true, {});
|
||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [1]);
|
||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [1]);
|
||||
|
||||
return { seqId: equip.seqId, hid: 0};
|
||||
}
|
||||
@@ -111,16 +111,16 @@ export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, he
|
||||
* @param hero
|
||||
* @param equip
|
||||
*/
|
||||
export async function dressEquip(roleId: string, sid: string, hero:HeroType, equip: EquipType) {
|
||||
export async function dressEquip(roleId: string, sid: string, hero:HeroType, equip: EquipType, funcs: number[]) {
|
||||
let args = calEquipSeids(hero);
|
||||
|
||||
hero = await HeroModel.addEquip(roleId, hero.hid, equip.ePlaceId, equip._id);
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, args);
|
||||
|
||||
// 任务
|
||||
await checkTask(roleId, sid, TASK_TYPE.EQUIP_SUM, -1, true, {});
|
||||
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [-1]);
|
||||
await checkTaskWithEquip(roleId, sid, TASK_TYPE.EQUIP_QUALITY, equip, [-1]);
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.EQUIP_SUM, -1, true, {});
|
||||
await checkTaskWithHero(roleId, sid, funcs, TASK_TYPE.EQUIP_BY_HERO, hero, [-1]);
|
||||
await checkTaskWithEquip(roleId, sid, funcs, TASK_TYPE.EQUIP_QUALITY, equip, [-1]);
|
||||
|
||||
return { seqId: equip.seqId, hid: hero.hid };
|
||||
}
|
||||
Reference in New Issue
Block a user