diff --git a/shared/db/Equip.ts b/shared/db/Equip.ts index 87e85120d..18ea0a2a6 100644 --- a/shared/db/Equip.ts +++ b/shared/db/Equip.ts @@ -31,6 +31,7 @@ interface equipUpdate { _id?:number; holes?:Array; randSe?: Array; + ePlaceId?:number; } @index({ roleId: 1, hid: 1, id: 1 }) diff --git a/shared/db/Hero.ts b/shared/db/Hero.ts index b48a8752d..307cfeca0 100644 --- a/shared/db/Hero.ts +++ b/shared/db/Hero.ts @@ -1,7 +1,7 @@ import BaseModel from './BaseModel'; import { CeAttr } from './generalField'; import { index, getModelForClass, prop, Ref, mongoose, DocumentType } from '@typegoose/typegoose'; -import Equip from './Equip'; +import Equip, { EquipType } from './Equip'; import { CounterModel } from './Counter'; import { COUNTER, EQUIP_TYPE } from '../consts'; @@ -67,6 +67,7 @@ interface heroUpdate { favourLv?:number; skins?: Skin[]; connections?: Connect[]; + ePlace?:EPlace[]; _id?:number; } @@ -146,10 +147,10 @@ export default class Hero extends BaseModel { return hero; } - public static async addEquip(roleId: string, hid: number, equipId: string, lean = true) { + public static async addEquip(roleId: string, hid: number, ePlaceId: number, equipId: string, lean = true) { const hero: HeroType = await HeroModel.findOneAndUpdate( - { roleId, hid, 'ePlace.id': 1 }, - {$set: {'ePlace.$.equip': equipId}}, + { roleId, hid, 'ePlace.id': ePlaceId }, + {$set: {'ePlace.$.equip': equipId, 'ePlace.$.hid':hid, 'ePlace.$.ePlaceId':ePlaceId}}, {new: true}).lean(lean); if (hero) { await Equip.putOn(hero.hid, equipId); @@ -207,10 +208,18 @@ export default class Hero extends BaseModel { return result; } - public static async getHeroAndEquip(roleId: string, hid:number, lean = true) { - let result: HeroType = await HeroModel.findOne({roleId, hid}).select('ePlact').lean(lean); + public static async getHeroEquip(roleId: string, hid: number, lean = true) { + let result: EquipType = await HeroModel.findOne({ roleId, hid }).populate('ePlace.equip').select('ePlace.equip').lean(lean); return result; } + + public static async unloadHeroAndEquip(roleId: string, hid: number, id: number, lean = true) { + const hero: HeroType = await HeroModel.findOneAndUpdate( + { roleId, hid, 'ePlace.id': id }, + {$set: {'ePlace.$.equip': null}}, + {new: true}).lean(lean); + return hero; + } } export const HeroModel = getModelForClass(Hero); diff --git a/shared/pubUtils/dictionary/DicGoods.ts b/shared/pubUtils/dictionary/DicGoods.ts index 9592120e3..5fcf516c9 100644 --- a/shared/pubUtils/dictionary/DicGoods.ts +++ b/shared/pubUtils/dictionary/DicGoods.ts @@ -50,6 +50,10 @@ export interface DicGoods { // 属性外加的值,经验,好感 readonly value: number; + readonly count?: number; + + readonly nextJewelId?: number; + } const str = readJsonFile(FILENAME.DIC_GOODS); @@ -75,12 +79,15 @@ const DicGoodsKeys: KeysEnum = { suitId: true, specialAttr: true, value: true, - pieceId: true + pieceId: true, + count: true, + nextJewelId: true, } export const dicGoods = new Map(); export const blueprt = new Map>(); - +export const jewels = new Map>(); +let jewelsMap = {}; arr.forEach(o => { o.goodsAbility = parseAbility(o); o.goodsAbilityUp = parseAbilityUp(o); @@ -95,9 +102,22 @@ arr.forEach(o => { let arr = blueprt.get(o.quality)||new Array(); arr.push(o.good_id); blueprt.set(o.quality, arr); + } else if (o.itid == IT_TYPE.JEWEL) { + jewelsMap[o.good_id] = o; } }); +// for (let key in jewelsMap) { +// let jewel = jewelsMap[key]; +// let material = jewel.composeMaterial[0]; +// let nextJewel = jewelsMap[material.id]; +// nextJewel.count = material.count; +// nextJewel.nextJewelId = material.id; +// jewels.set(jewel.good_id, _.pick(nextJewel, Object.keys(DicGoodsKeys))); +// } +jewelsMap = undefined; +arr = undefined; + function parseSpecialAttr(str: string) { let specialAttr = new Map(); if(str) { diff --git a/shared/pubUtils/playerCe.ts b/shared/pubUtils/playerCe.ts index 53f496846..f75b38b2e 100644 --- a/shared/pubUtils/playerCe.ts +++ b/shared/pubUtils/playerCe.ts @@ -152,7 +152,7 @@ export function calHeroJobStageUpIncAttr(hero: HeroType, args: Array, ad let currentJob = gameData.job.get(hero.job); addSeidList.concat(deepCopy(currentJob.seid)); for (let seid of lastJob.seid) { - let index = _.indexOf(currentJob.seid, seid); + let index = _.findIndex(currentJob.seid, seid); if (index > 0) { addSeidList.splice(index, 1); } else {