装备替换

This commit is contained in:
mamengke01
2020-12-30 15:02:37 +08:00
parent 552534b585
commit ac2fc62f69
4 changed files with 6 additions and 9 deletions
@@ -422,7 +422,7 @@ export class EquipHandler {
let obj = ITID.get(goodInfo.itid); let obj = ITID.get(goodInfo.itid);
let id = obj.type; let id = obj.type;
let curEquips: Array<{ seqId: number, hid: number}> = []; let curEquips: Array<{ seqId: number, hid: number}> = [];
let hero = await HeroModel.getHeroEquip(roleId, hid); let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
if (!hero) if (!hero)
return resResult(STATUS.HERO_NOT_FIND); return resResult(STATUS.HERO_NOT_FIND);
if (type == 1) { if (type == 1) {
+1 -1
View File
@@ -42,7 +42,7 @@ export function checkMaterialEnough(consumes:Array<{id: number, count: number}>,
export async function changeEquip(roleId: string, sid: string, equip: EquipType, hid: number, id: number, seqId: number) { export async function changeEquip(roleId: string, sid: string, equip: EquipType, hid: number, id: number, seqId: number) {
let hero; let hero;
if (!!hid) //需要卸下或者替换的武将 if (!!hid) //需要卸下或者替换的武将
hero = await HeroModel.findByHidAndRole(hid, roleId); hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
if (!!equip) {//需要卸下的装备 if (!!equip) {//需要卸下的装备
if (!!hero) {//判断是否替换装备 if (!!hero) {//判断是否替换装备
let goodInfo = getGoodById(equip.id); let goodInfo = getGoodById(equip.id);
-5
View File
@@ -226,11 +226,6 @@ export default class Hero extends BaseModel {
let result: HeroType = await HeroModel.findOneAndUpdate({roleId, hid}, {$set:heroUpdate}, {new: true}).select(select).lean(lean); let result: HeroType = await HeroModel.findOneAndUpdate({roleId, hid}, {$set:heroUpdate}, {new: true}).select(select).lean(lean);
return result; return result;
} }
public static async getHeroEquip(roleId: string, hid: number, lean = true) {
let result: HeroType = await HeroModel.findOne({ roleId, hid }).populate('ePlace.equip').lean(lean);
return result;
}
public static async unloadHeroAndEquip(roleId: string, hid: number, id: number, lean = true) { public static async unloadHeroAndEquip(roleId: string, hid: number, id: number, lean = true) {
const hero: HeroType = await HeroModel.findOneAndUpdate( const hero: HeroType = await HeroModel.findOneAndUpdate(
+4 -2
View File
@@ -465,8 +465,10 @@ export function calEquipSeids(hero: HeroType) {
for (let { equip } of ePlace) { for (let { equip } of ePlace) {
if (equip) { if (equip) {
let e = <EquipType>equip; let e = <EquipType>equip;
for (let { seid, rand } of e.randSe) { if (!!e.randSe) {
seids.push(seid, rand); for (let { seid, rand } of e.randSe) {
seids.push(seid, rand);
}
} }
if (e.suitId > 0) { if (e.suitId > 0) {
if (suits.has(e.suitId)) { if (suits.has(e.suitId)) {