装备:切换皮肤带来的职业变化对装备

This commit is contained in:
luying
2022-02-26 15:55:49 +08:00
parent eadef9ba12
commit 3056b7fa3d
3 changed files with 31 additions and 28 deletions
@@ -7,7 +7,7 @@ import { HeroModel, Connect, HeroSkin, HeroUpdate, EPlace } from '../../../db/He
import { CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ABI_STAGE, DEBUG_MAGIC_WORD, HERO_INITIAL_QUALITY, REDIS_KEY, TASK_TYPE, ITEM_CHANGE_REASON } from '../../../consts'; import { CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ABI_STAGE, DEBUG_MAGIC_WORD, HERO_INITIAL_QUALITY, REDIS_KEY, TASK_TYPE, ITEM_CHANGE_REASON } from '../../../consts';
import { RoleModel } from '../../../db/Role'; import { RoleModel } from '../../../db/Role';
import { ItemModel } from '../../../db/Item'; import { ItemModel } from '../../../db/Item';
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById, getFavourLvByExp, reloadDicParam } from '../../../pubUtils/data'; import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById, getFavourLvByExp, reloadDicParam, getEquipByJobClassAndEPlace } from '../../../pubUtils/data';
import { ItemInter, RewardInter } from '../../../pubUtils/interface'; import { ItemInter, RewardInter } from '../../../pubUtils/interface';
import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst' import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst'
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService'; import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
@@ -15,6 +15,7 @@ import { calculatetopLineup } from '../../../pubUtils/playerCe';
import { PvpDefenseModel } from '../../../db/PvpDefense'; import { PvpDefenseModel } from '../../../db/PvpDefense';
import { checkTaskWithHero, checkTask, checkActivityTask } from '../../../services/taskService'; import { checkTaskWithHero, checkTask, checkActivityTask } from '../../../services/taskService';
import { pick } from 'underscore'; import { pick } from 'underscore';
import { updateEplaces } from '../../../services/equipService';
export default function (app: Application) { export default function (app: Application) {
new HandlerService(app, {}); new HandlerService(app, {});
@@ -593,29 +594,18 @@ export class HeroHandler {
let dicMyJob = gameData.job.get(hero.job); let dicMyJob = gameData.job.get(hero.job);
let dicNewJob = getJobByGradeAndClass(dicHero.jobClass, dicMyJob.grade); let dicNewJob = getJobByGradeAndClass(dicHero.jobClass, dicMyJob.grade);
// let newEplace: EPlace[] = [], heroPutNum = 0, curEquips: {seqId: number, id: number, hid: number, ePlaceId: number}[] = []; let oldEplace = hero.ePlace||[];
// for(let { id, equip, lv, refineLv } of hero.ePlace) { let eplaceIds = new Map<number, { equipId: number }>(); // 更新了的装备栏id
// let e = <EquipType>equip; for(let { id } of oldEplace) {
// if(equip && !checkEquipCanPut({...hero, skinId: dicSkin.heroId}, e.id)) { let dicEquip = getEquipByJobClassAndEPlace(dicHero?.jobClass, id);
// await EquipModel.putOnOrOff(e._id, 0); eplaceIds.set(id, { equipId: dicEquip.id });
// heroPutNum -= 1; }
// newEplace.push({ id, equip: null, lv, refineLv}); console.log('*****', eplaceIds)
// 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 } = updateEplaces(oldEplace, eplaceIds);
// if(heroPutNum < 0) { hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.SKIN, sid, roleId, hero, { skins: newHeroSkins, skinId: dicSkin.heroId, job: dicNewJob.jobid, ePlace: newEplace });
// hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, oldEquipSeids); return resResult(STATUS.SUCCESS, { curHero: {...pick(hero, ['hid', 'skins', 'skinId', 'job']), ePlace: newEplace }});
// 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 });
return resResult(STATUS.SUCCESS, { curHero: pick(hero, ['hid', 'skins', 'skinId', 'job']) });
} }
// ! debug接口 一键全武将 // ! debug接口 一键全武将
+17 -4
View File
@@ -523,7 +523,7 @@ export function calHeroJobAttr(originHero: HeroType, hero: HeroUpdate, addSeidLi
*/ */
export function calHeroWearSkinIncAttr(originHero: HeroType, update: HeroUpdate, addSeidList: number[], removeSeidList: number[]) { export function calHeroWearSkinIncAttr(originHero: HeroType, update: HeroUpdate, addSeidList: number[], removeSeidList: number[]) {
let { attr: heroAttrs, skinId: originSkinId } = originHero; let { attr: heroAttrs, skinId: originSkinId } = originHero;
let { skinId = originSkinId } = update; let { skinId = originSkinId, ePlace: newEplace } = update;
calHeroStarIncAttr(originHero, update, HERO_SYSTEM_TYPE.SKIN, addSeidList, removeSeidList); calHeroStarIncAttr(originHero, update, HERO_SYSTEM_TYPE.SKIN, addSeidList, removeSeidList);
let addSkin = gameData.fashionBySkinId.get(skinId); let addSkin = gameData.fashionBySkinId.get(skinId);
@@ -540,6 +540,12 @@ export function calHeroWearSkinIncAttr(originHero: HeroType, update: HeroUpdate,
updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp } }); updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp } });
} }
originHero.attr = heroAttrs; originHero.attr = heroAttrs;
let eplaceIds = newEplace.map(cur => cur.id);
calEquipStrengthIncAttr(originHero, update, eplaceIds);
calEquipQualityIncAttr(originHero, update, eplaceIds);
calEquipStarIncAttr(originHero, update, eplaceIds, addSeidList, removeSeidList);
return heroAttrs; return heroAttrs;
} }
@@ -628,12 +634,17 @@ export function calEquipStrengthIncAttr(hero: HeroType, update: HeroUpdate, epla
let oldEquip = oldEplace.find(cur => cur.id == eplaceId); let oldEquip = oldEplace.find(cur => cur.id == eplaceId);
let newEquip = newEplace.find(cur => cur.id == eplaceId); let newEquip = newEplace.find(cur => cur.id == eplaceId);
if(newEquip && oldEquip) { if(newEquip && oldEquip) {
let dicEquip = gameData.equipById.get(oldEquip.equipId); let dicOldEquip = gameData.equipById.get(oldEquip.equipId);
for(let attr of dicEquip.attributeUp) { let dicNewEquip = gameData.equipById.get(newEquip.equipId);
updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: attr.num * (newEquip.lv - oldEquip.lv) * HERO_CE_RATIO } }); for(let attr of dicOldEquip.attributeUp) {
updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: -1 * attr.num * oldEquip.lv * HERO_CE_RATIO } });
}
for(let attr of dicNewEquip.attributeUp) {
updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: attr.num * newEquip.lv * HERO_CE_RATIO } });
} }
} }
} }
hero.attr = heroAttrs;
return heroAttrs return heroAttrs
} }
@@ -654,6 +665,7 @@ export function calEquipQualityIncAttr(hero: HeroType, update: HeroUpdate, eplac
} }
} }
} }
hero.attr = heroAttrs;
return heroAttrs return heroAttrs
} }
@@ -686,6 +698,7 @@ export function calEquipStarIncAttr(hero: HeroType, update: HeroUpdate, eplaceId
// 套装属性 // 套装属性
calEquipSuitIncAttr(hid, oldEplace, newEplace, addSeidList, removeSeidList); calEquipSuitIncAttr(hid, oldEplace, newEplace, addSeidList, removeSeidList);
hero.attr = heroAttrs;
return heroAttrs; return heroAttrs;
} }
+2 -2
View File
@@ -18012,8 +18012,8 @@
"camp": 2, "camp": 2,
"area": 0, "area": 0,
"cost": 0, "cost": 0,
"jobid": 200, "jobid": 300,
"jobClass": 2, "jobClass": 3,
"skill": 19, "skill": 19,
"pieceId": 21019, "pieceId": 21019,
"hp": 124, "hp": 124,