From 228f6d7eafd8ceb0aec153d53c311a28750093a7 Mon Sep 17 00:00:00 2001 From: mamengke01 <794347210@qq.com> Date: Wed, 16 Dec 2020 17:12:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=89=E8=90=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/rewardService.ts | 20 +++++++++----------- shared/db/Hero.ts | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/game-server/app/services/rewardService.ts b/game-server/app/services/rewardService.ts index c6e1503c1..0067d72d2 100644 --- a/game-server/app/services/rewardService.ts +++ b/game-server/app/services/rewardService.ts @@ -198,9 +198,8 @@ export async function addItems(roleId: string, roleName: string, sid: string, go equipInfos.push(equipInfo); } //装备推送 - if (!!equipInfos.length) { - pinus.app.get('channelService').pushMessageByUids('onEquipAdd', resResult(STATUS.SUCCESS, {equipInfos}), uids); - } + if (!!equipInfos.length) + pinus.app.get('channelService').pushMessageByUids('onEquipAdd', resResult(STATUS.SUCCESS, equipInfos), uids); let data = {}; 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); - } let bagInfos = []; 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); - } let skinInfos = []; 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}); 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; } @@ -253,7 +251,7 @@ function sortItems (goods: Array, bags: Array, skins: Array, } else { currencys.push(good); } - } else if (goodInfo.itid == CONSUME_TYPE.SKIN) { + } else if (type == CONSUME_TYPE.SKIN) { let index = _.indexOf(skins, good.id); if (index == -1) { skins.push(good.id); @@ -279,7 +277,7 @@ async function addSkins(roleId: string, id: number) { return false; if (!!_.findWhere(hero.skins, {id})) return false; - hero.skins.push({id: id, enable: false}); + hero.skins.push({id, enable: false}); await HeroModel.updateHeroInfo(roleId, hero.hid, hero); 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) { let {id, count, itemName, type, hid} = data; 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) { diff --git a/shared/db/Hero.ts b/shared/db/Hero.ts index fa8e510ab..cecdbf834 100644 --- a/shared/db/Hero.ts +++ b/shared/db/Hero.ts @@ -92,7 +92,7 @@ export default class Hero extends BaseModel { favourLv: number; // 好感等级 @prop({ required: true, type:Connect, default: [] }) connections: Connect[]; // 羁绊 - @prop({ required: true, default: [] }) + @prop({ required: true, type: Skin, default: [] }) skins: Skin[]; // 皮肤 @prop({ ref: Equip, type: mongoose.Schema.Types.ObjectId })