皮肤:武将、时装表修改

This commit is contained in:
luying
2021-10-19 14:26:17 +08:00
parent b6a904b091
commit da5a43abba
13 changed files with 3205 additions and 2754 deletions
@@ -3,7 +3,7 @@ import { handleCost, addItems, unlockFigure, createHeroes, createHero, CheckMete
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
import { resResult, deepCopy } from '../../../pubUtils/util';
import { STATUS } from '../../../consts/statusCode';
import { HeroModel, Connect, HeroSkin, HeroUpdate } from '../../../db/Hero';
import { HeroModel, Connect, HeroSkin, HeroUpdate, EPlace } from '../../../db/Hero';
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 } from '../../../consts';
import { RoleModel } from '../../../db/Role';
import { ItemModel } from '../../../db/Item';
@@ -11,11 +11,14 @@ import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, g
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst'
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
import { calculatetopLineup } from '../../../pubUtils/playerCe';
import { calculatetopLineup, calEquipSeids } from '../../../pubUtils/playerCe';
import { PvpDefenseModel } from '../../../db/PvpDefense';
import { checkTaskWithHero, checkTask, checkActivityTask } from '../../../services/taskService';
import { addSkin } from '../../../pubUtils/itemUtils';
import Skin from '../../../db/Skin';
import { EquipModel, EquipType } from '../../../db/Equip';
import { checkEquipCanPut } from '../../../services/equipService';
import { pick } from 'underscore';
export default function (app: Application) {
new HandlerService(app, {});
@@ -550,11 +553,13 @@ export class HeroHandler {
async heroWearSkin(msg: { id: number }, session: BackendSession) {
let roleId: string = session.get('roleId');
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let { id } = msg;
let skinInfo = gameData.fashion.get(id);
// console.log('*****', id, skinInfo)
if (!skinInfo) return resResult(STATUS.HERO_SKIN_NOT_FIND);
let hero = await HeroModel.findByHidAndRole(skinInfo.actorId, roleId);
let dicSkin = gameData.fashion.get(id);
// console.log('*****', id, dicSkin)
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 newHeroSkins: HeroSkin[] = [];
@@ -569,17 +574,42 @@ export class HeroHandler {
result = true;
} else {
if (!!skin.enable) {
lastSkinId = skin.id;
lastSkinId = skin.skinId;
}
newHeroSkins.push({ ...skin, enable: false });
}
}
if (!result) {
return resResult(STATUS.HERO_SKIN_NOT_FIND);
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.SKIN, sid, roleId, hero, { skins: newHeroSkins }, [id, lastSkinId]);
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, skins: hero.skins } });
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, 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) {
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]);
}
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 });
}
// ! debug接口 一键全武将