装备:装备逻辑变化
This commit is contained in:
@@ -182,25 +182,19 @@ export default class Hero extends BaseModel {
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async addEquip(roleId: string, hid: number, ePlaceId: number, equipId: string, equipOffId: string) {
|
||||
public static async addEquip(roleId: string, hid: number, ePlaceId: number, equipId: string) {
|
||||
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
||||
{ roleId, hid, 'ePlace.id': ePlaceId },
|
||||
{ $set: { 'ePlace.$.equip': equipId } },
|
||||
{ new: true }).populate('ePlace.equip').lean();
|
||||
await Equip.putOnOrOff(equipId, hero.hid);
|
||||
if(equipOffId) await Equip.putOnOrOff(equipOffId, 0);
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async removeEquip(roleId: string, hid: number, ePlaceId: number, equipId: string, lean = true) {
|
||||
public static async removeEquip(roleId: string, hid: number, ePlaceId: number, lean = true) {
|
||||
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
||||
{ roleId, hid, 'ePlace.id': ePlaceId },
|
||||
{ $set: { 'ePlace.$.equip': null } },
|
||||
{ new: true }).populate('ePlace.equip').lean(lean);
|
||||
|
||||
if (hero) {
|
||||
await Equip.putOnOrOff(equipId, 0);
|
||||
}
|
||||
return hero;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user