修改数据库,姑且跑起来
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -731,22 +731,22 @@ export class FriendHandler {
|
||||
if (heroList.length <= 0) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let list = new Array();
|
||||
for (let { roleId, roleName, hid, hName, ce, lv, star, colorStar, quality, job, skinId, attr: heroAttrs, ePlace } of heroList) {
|
||||
// for (let { roleId, roleName, hid, hName, ce, lv, star, colorStar, quality, job, skinId, attr: heroAttrs, ePlace } of heroList) {
|
||||
|
||||
let equips = await EquipModel.findListByHidAndRole(hisRoleId, hid, EQUIP_SELECT.HERO_DETAIL);
|
||||
// let equips = await EquipModel.findListByHidAndRole(hisRoleId, hid, EQUIP_SELECT.HERO_DETAIL);
|
||||
|
||||
let attributes = getPlayerMainAttribute(heroAttrs, role.attr);
|
||||
// let attributes = getPlayerMainAttribute(heroAttrs, role.attr);
|
||||
|
||||
list.push({
|
||||
roleId, roleName, hid, hName, ce, lv, star, colorStar, quality, job, skinId,
|
||||
equips: equips.map(cur => {
|
||||
let curEplace = ePlace.find(ccur => cur.ePlaceId == ccur.id) || new EPlace();
|
||||
let { lv = 0, refineLv = 0 } = curEplace;
|
||||
return { ...cur, lv, refineLv }
|
||||
}), attributes
|
||||
});
|
||||
// list.push({
|
||||
// roleId, roleName, hid, hName, ce, lv, star, colorStar, quality, job, skinId,
|
||||
// equips: equips.map(cur => {
|
||||
// let curEplace = ePlace.find(ccur => cur.ePlaceId == ccur.id) || new EPlace();
|
||||
// let { lv = 0, refineLv = 0 } = curEplace;
|
||||
// return { ...cur, lv, refineLv }
|
||||
// }), attributes
|
||||
// });
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
return resResult(STATUS.SUCCESS, { list });
|
||||
|
||||
@@ -569,7 +569,6 @@ 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;
|
||||
@@ -591,34 +590,34 @@ export class HeroHandler {
|
||||
if (!result) {
|
||||
return resResult(STATUS.HERO_SKIN_NOT_FIND);
|
||||
}
|
||||
let oldEquipSeids = calEquipSeids(hero);
|
||||
|
||||
let dicHero = gameData.hero.get(dicSkin.heroId);
|
||||
let dicMyJob = gameData.job.get(hero.job);
|
||||
let dicNewJob = getJobByGradeAndClass(dicHero.jobClass, dicMyJob.grade);
|
||||
|
||||
let newEplace: EPlace[] = [], heroPutNum = 0, curEquips: {seqId: number, id: number, hid: number, ePlaceId: number}[] = [];
|
||||
for(let { id, equip, lv, refineLv } of hero.ePlace) {
|
||||
let e = <EquipType>equip;
|
||||
if(equip && !checkEquipCanPut({...hero, skinId: dicSkin.heroId}, e.id)) {
|
||||
await EquipModel.putOnOrOff(e._id, 0);
|
||||
heroPutNum -= 1;
|
||||
newEplace.push({ id, equip: null, lv, refineLv});
|
||||
curEquips.push({ seqId: e.seqId, id: e.id, hid: 0, ePlaceId: id });
|
||||
} else {
|
||||
newEplace.push({ id, equip: e?e._id: null, lv, refineLv});
|
||||
}
|
||||
}
|
||||
// let newEplace: EPlace[] = [], heroPutNum = 0, curEquips: {seqId: number, id: number, hid: number, ePlaceId: number}[] = [];
|
||||
// for(let { id, equip, lv, refineLv } of hero.ePlace) {
|
||||
// let e = <EquipType>equip;
|
||||
// if(equip && !checkEquipCanPut({...hero, skinId: dicSkin.heroId}, e.id)) {
|
||||
// await EquipModel.putOnOrOff(e._id, 0);
|
||||
// heroPutNum -= 1;
|
||||
// newEplace.push({ id, equip: null, lv, refineLv});
|
||||
// curEquips.push({ seqId: e.seqId, id: e.id, hid: 0, ePlaceId: id });
|
||||
// } else {
|
||||
// newEplace.push({ id, equip: e?e._id: null, lv, refineLv});
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
if(heroPutNum < 0) {
|
||||
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, oldCount]);
|
||||
}
|
||||
// if(heroPutNum < 0) {
|
||||
// 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, oldCount]);
|
||||
// }
|
||||
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.SKIN, sid, roleId, hero, { skins: newHeroSkins, skinId: dicSkin.heroId, job: dicNewJob.jobid, ePlace: newEplace });
|
||||
return resResult(STATUS.SUCCESS, { curHero: pick(hero, ['hid', 'skins', 'skinId', 'job']), curEquips });
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.SKIN, sid, roleId, hero, { skins: newHeroSkins, skinId: dicSkin.heroId, job: dicNewJob.jobid });
|
||||
return resResult(STATUS.SUCCESS, { curHero: pick(hero, ['hid', 'skins', 'skinId', 'job']) });
|
||||
}
|
||||
|
||||
// ! debug接口 一键全武将
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
Reference in New Issue
Block a user