装备查询

This commit is contained in:
mamengke01
2020-12-18 18:06:07 +08:00
parent 2a3cb06927
commit f568dd613e
4 changed files with 39 additions and 9 deletions

View File

@@ -31,6 +31,7 @@ interface equipUpdate {
_id?:number;
holes?:Array<Holes>;
randSe?: Array<RandSe>;
ePlaceId?:number;
}
@index({ roleId: 1, hid: 1, id: 1 })

View File

@@ -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);

View File

@@ -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<DicGoods> = {
suitId: true,
specialAttr: true,
value: true,
pieceId: true
pieceId: true,
count: true,
nextJewelId: true,
}
export const dicGoods = new Map<number, DicGoods>();
export const blueprt = new Map<number, Array<number>>();
export const jewels = new Map<number, Array<number>>();
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<number>();
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<number, number>();
if(str) {

View File

@@ -152,7 +152,7 @@ export function calHeroJobStageUpIncAttr(hero: HeroType, args: Array<number>, 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 {