修改数据库,姑且跑起来

This commit is contained in:
luying
2022-02-15 18:46:56 +08:00
parent a43c61cb5a
commit ecc55b3063
11 changed files with 1242 additions and 1166 deletions
+24 -24
View File
@@ -125,33 +125,33 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
}
//删除装备
if (resEquips.length > 0) {
let heroMap = new Map<number, { hero: HeroType, equips: EquipType[]}>();
for(let equip of resEquips) {
if(equip.hid > 0) {
if(!heroMap.has(equip.hid)) {
let hero = await HeroModel.findByHidAndRoleWithEquip(equip.hid, roleId);
heroMap.set(equip.hid, { hero, equips: [] });
}
heroMap.get(equip.hid).equips.push(equip);
}
}
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);
}
// if (resEquips.length > 0) {
// let heroMap = new Map<number, { hero: HeroType, equips: EquipType[]}>();
// for(let equip of resEquips) {
// if(equip.hid > 0) {
// if(!heroMap.has(equip.hid)) {
// let hero = await HeroModel.findByHidAndRoleWithEquip(equip.hid, roleId);
// heroMap.set(equip.hid, { hero, equips: [] });
// }
// heroMap.get(equip.hid).equips.push(equip);
// }
// }
// 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, oldCount]);
}
// await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, args);
// await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [-1, oldCount]);
// }
let equips = await EquipModel.deleteEquips(roleId, equipSeqIds);
saveItemChangeLog(roleId, equips.map(equip => ({ id: equip.id, count: equip.count, inc: -1 })), reason);
pinus.app.get('channelService').pushMessageByUids('onEquipDel', resResult(STATUS.SUCCESS, { equipInfos: equips.map(equip => ({ seqId: equip.seqId, id: equip.id, inc: -1, reason })) }), uids);
}
// let equips = await EquipModel.deleteEquips(roleId, equipSeqIds);
// saveItemChangeLog(roleId, equips.map(equip => ({ id: equip.id, count: equip.count, inc: -1 })), reason);
// pinus.app.get('channelService').pushMessageByUids('onEquipDel', resResult(STATUS.SUCCESS, { equipInfos: equips.map(equip => ({ seqId: equip.seqId, id: equip.id, inc: -1, reason })) }), uids);
// }
//消耗玩家货币
if (gold.length > 0 || coin.length > 0) {