This commit is contained in:
mamengke01
2020-12-16 17:12:32 +08:00
parent aef1ad9403
commit 228f6d7eaf
2 changed files with 10 additions and 12 deletions
+9 -11
View File
@@ -198,9 +198,8 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
equipInfos.push(equipInfo); equipInfos.push(equipInfo);
} }
//装备推送 //装备推送
if (!!equipInfos.length) { if (!!equipInfos.length)
pinus.app.get('channelService').pushMessageByUids('onEquipAdd', resResult(STATUS.SUCCESS, {equipInfos}), uids); pinus.app.get('channelService').pushMessageByUids('onEquipAdd', resResult(STATUS.SUCCESS, equipInfos), uids);
}
let data = {}; let data = {};
for (let currency of currencys) { for (let currency of currencys) {
@@ -209,9 +208,8 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
} }
//货币推送 //货币推送
if (!!Object.keys(data).length) { if (!!Object.keys(data).length)
pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, data), uids); pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, data), uids);
}
let bagInfos = []; let bagInfos = [];
for (let item of bags) { for (let item of bags) {
@@ -221,9 +219,8 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
} }
//背包除去装备推送 //背包除去装备推送
if (!!bagInfos.length) { if (!!bagInfos.length)
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, {goods: bagInfos}), uids); pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, {goods: bagInfos}), uids);
}
let skinInfos = []; let skinInfos = [];
for (let skinId of skins) {//皮肤推送 for (let skinId of skins) {//皮肤推送
@@ -232,8 +229,9 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
showItems.push({id: skinId, count: 1}); showItems.push({id: skinId, count: 1});
skinInfos.push(result); skinInfos.push(result);
} }
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, {skinInfos}), uids);
} }
if (!!skinInfos.length)
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, skinInfos), uids);
return showItems; return showItems;
} }
@@ -253,7 +251,7 @@ function sortItems (goods: Array<Item>, bags: Array<Bag>, skins: Array<number>,
} else { } else {
currencys.push(good); currencys.push(good);
} }
} else if (goodInfo.itid == CONSUME_TYPE.SKIN) { } else if (type == CONSUME_TYPE.SKIN) {
let index = _.indexOf(skins, good.id); let index = _.indexOf(skins, good.id);
if (index == -1) { if (index == -1) {
skins.push(good.id); skins.push(good.id);
@@ -279,7 +277,7 @@ async function addSkins(roleId: string, id: number) {
return false; return false;
if (!!_.findWhere(hero.skins, {id})) if (!!_.findWhere(hero.skins, {id}))
return false; return false;
hero.skins.push({id: id, enable: false}); hero.skins.push({id, enable: false});
await HeroModel.updateHeroInfo(roleId, hero.hid, hero); await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
return {skins: hero.skins, hid: hero.hid}; return {skins: hero.skins, hid: hero.hid};
} }
@@ -287,7 +285,7 @@ async function addSkins(roleId: string, id: number) {
async function addBags(roleId: string, roleName: string, data:Bag) { async function addBags(roleId: string, roleName: string, data:Bag) {
let {id, count, itemName, type, hid} = data; let {id, count, itemName, type, hid} = data;
let item = await ItemModel.increaseItem(roleId, id, count, {roleId, roleName, itemName, id, type, hid}); let item = await ItemModel.increaseItem(roleId, id, count, {roleId, roleName, itemName, id, type, hid});
return item; return {id:item.id, count: item.count};
} }
async function addEquips (roleId: string, roleName: string, weapon: Equip) { async function addEquips (roleId: string, roleName: string, weapon: Equip) {
+1 -1
View File
@@ -92,7 +92,7 @@ export default class Hero extends BaseModel {
favourLv: number; // 好感等级 favourLv: number; // 好感等级
@prop({ required: true, type:Connect, default: [] }) @prop({ required: true, type:Connect, default: [] })
connections: Connect[]; // 羁绊 connections: Connect[]; // 羁绊
@prop({ required: true, default: [] }) @prop({ required: true, type: Skin, default: [] })
skins: Skin[]; // 皮肤 skins: Skin[]; // 皮肤
@prop({ ref: Equip, type: mongoose.Schema.Types.ObjectId }) @prop({ ref: Equip, type: mongoose.Schema.Types.ObjectId })