修改数据库,姑且跑起来

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) {
+7 -7
View File
@@ -91,13 +91,13 @@ export async function pushGuildBossSucMsg(roleId: string, roleName: string, guil
}
export async function pushEquipRefineSucMsg(roleId: string, roleName: string, serverId: number, eplace: Partial<EPlace>, quality: number) {
const { id, lv, refineLv, equip } = eplace;
const { id: equipId } = equip as EquipType;
const data = { id, lv, refineLv, equipId, quality };
const content = JSON.stringify({ roleId, roleName, eplace: data, equip: pick(equip, ['id', 'name', 'eplaceId', 'quality', 'holes', 'randMain', 'randSe', 'grade', 'hid']) });
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_REFINE_SUC, content, null, null);
await pushGroupMsgToRoom(msgData);
return msgData;
// const { id, lv, refineLv, equip } = eplace;
// const { id: equipId } = equip as EquipType;
// const data = { id, lv, refineLv, equipId, quality };
// const content = JSON.stringify({ roleId, roleName, eplace: data, equip: pick(equip, ['id', 'name', 'eplaceId', 'quality', 'holes', 'randMain', 'randSe', 'grade', 'hid']) });
// const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.SYS, `${serverId}`, MSG_TYPE.RICH_TEXT, MSG_SOURCE.EQUIP_REFINE_SUC, content, null, null);
// await pushGroupMsgToRoom(msgData);
// return msgData;
}
export async function pushNormalEquipMsg(roleId: string, roleName: string, serverId: number, source: number, id: number, name: string, quality: number) {
-33
View File
@@ -329,37 +329,4 @@ export async function refDailyTaskBox(roleId: string, sid: string, debug = false
point, weeklyPoint, box
}), uids);
}
}
//任务条件
//英雄满装备且都镶嵌相同阶数的宝石
export async function checkTaskConditionEquipSuitJewelStage(hero: HeroType) {
let isTask = true;//是否满足任务条件
let jewelLevel = -1;//宝石阶数
for (let i = 0; i < hero.ePlace.length; i++) {
let equipObj = <EquipType>hero.ePlace[i].equip;
if (equipObj) {
let equipObjInfo = getGoodById(equipObj.id);
if (equipObj.holes.length == equipObjInfo.hole && equipObjInfo.hole > 0) {
for (let j = 0; j < equipObj.holes.length; j++) {
let jewel = equipObj.holes[j].jewel;
let jewelInfo = getGoodById(jewel);
if (jewelInfo) {
if (jewelLevel == -1) {
jewelLevel = jewelInfo.lvLimited;
} else if (jewelInfo.lvLimited != jewelLevel) {
//宝石阶数不同
isTask = false;
break;
}
}
}
} else {
//宝石没有镶满
isTask = false;
break;
}
}
}
return { isTask, jewelLevel };
}