diff --git a/game-server/app/servers/connector/handler/entryHandler.ts b/game-server/app/servers/connector/handler/entryHandler.ts index f318b2179..2d2c8c95a 100644 --- a/game-server/app/servers/connector/handler/entryHandler.ts +++ b/game-server/app/servers/connector/handler/entryHandler.ts @@ -10,6 +10,7 @@ import { resResult } from '../../../pubUtils/util'; import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK } from '../../../consts'; import { getAp } from '../../../services/actionPointService'; import { ItemModel } from '../../../db/Item'; +import { SkinModel } from '../../../db/Skin'; import { chackFunOpenWhenLogin } from '../../../services/funcSwitchService'; import { loginRefresh } from '../../../services/playerEventService'; import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil'; @@ -75,6 +76,7 @@ export class EntryHandler { let heros = await HeroModel.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true); let equips = await EquipModel.findbyRole(role.roleId); let items = await ItemModel.findbyRole(role.roleId); + let skins = await SkinModel.findbyRole(role.roleId); await chackFunOpenWhenLogin(role, session); if (role.hasInit) await loginRefresh(role.roleId); reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), user.pkgName); @@ -93,6 +95,7 @@ export class EntryHandler { role['heros'] = heros; role['equips'] = equips; role['consumeGoods'] = items; + role['skins'] = skins; let apJson = await getAp(role.roleId, role.lv); role['apJson'] = apJson; diff --git a/game-server/app/services/rewardService.ts b/game-server/app/services/rewardService.ts index 251ac549e..dca03ab83 100644 --- a/game-server/app/services/rewardService.ts +++ b/game-server/app/services/rewardService.ts @@ -153,7 +153,8 @@ export async function addItems(roleId: string, roleName: string, sid: string, go pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: bagInfos }), uids); - let skinInfos: {skins: HeroSkin[], hid: number}[] = []; // 皮肤推送信息 + let heroskins: {skins: HeroSkin[], hid: number}[] = []; // 皮肤推送信息 + let skinInfos: {id: number, hid: number }[] = []; let figureInfos:{ heads: Figure[], frames: Figure[], spines: Figure[] }[] = []; // 头像变化推送信息 let calAllHeroResult = undefined; // 全局战力变化推送 @@ -164,13 +165,14 @@ export async function addItems(roleId: string, roleName: string, sid: string, go showItems.push({ id: skinId, count: 1 }); figureInfos.push(result.figureInfo); if(result.hero) { - skinInfos.push({ skins: result.hero.skins, hid: result.hero.hid }); + heroskins.push({ skins: result.hero.skins, hid: result.hero.hid }); if(result.calAllHeroResult) calAllHeroResult = result.calAllHeroResult; } + skinInfos.push({ id: skinId, hid: result.hero?.hid||0 }) } } if (!!skinInfos.length) { - pushHeroSkinMsg(skinInfos, uids); // 推送onHeroSkinChange + pushHeroSkinMsg(heroskins, skinInfos, uids); // 推送onHeroSkinChange } // 推送全局加成信息 if(calAllHeroResult) await pushCalAllHeroCe(roleId, sid, calAllHeroResult); @@ -378,12 +380,12 @@ export async function createHero(roleId: string, roleName: string, sid: string, /** * 皮肤数据变化去重、推送 - * @param skinInfos 推送的皮肤 + * @param heroskins 推送的皮肤 * @param uids 玩家 */ -function pushHeroSkinMsg(skinInfos: {skins: HeroSkin[], hid: number}[], uids: {uid: string, sid: string}[]) { +function pushHeroSkinMsg(heroskins: {skins: HeroSkin[], hid: number}[], skinInfos: {id: number, hid: number }[], uids: {uid: string, sid: string}[]) { let pushSkinInfos: {skins: HeroSkin[], hid: number}[] = []; // 可能会有重复的 - for(let { skins, hid } of skinInfos) { + for(let { skins, hid } of heroskins) { let index = pushSkinInfos.findIndex(cur => cur.hid == hid); if(index == -1) { pushSkinInfos.push({skins, hid}); @@ -393,7 +395,7 @@ function pushHeroSkinMsg(skinInfos: {skins: HeroSkin[], hid: number}[], uids: {u } } } - if(pushSkinInfos.length > 0) { - pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, { skinInfos }), uids); + if(pushSkinInfos.length > 0 || skinInfos.length > 0) { + pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, { heros: heroskins, skins: skinInfos }), uids); } } \ No newline at end of file diff --git a/shared/consts/constModules/selectConst.ts b/shared/consts/constModules/selectConst.ts index 20368109f..46ba53d7e 100644 --- a/shared/consts/constModules/selectConst.ts +++ b/shared/consts/constModules/selectConst.ts @@ -49,4 +49,4 @@ export enum FRIEND_SHIP_SELECT { GET_FRIEND_VALUE = 'friendValue friendLv' } -export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'equips', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson']; \ No newline at end of file +export const ENTERY_ROLE_PICK = ['roleId', 'roleName', 'serverId', 'ce', 'topLineupCe', 'coin', 'lv', 'exp', 'vLv', 'gold', 'heros', 'equips', 'consumeGoods', 'title', 'teraphs', 'showLineup', 'heads', 'head', 'frames', 'frame', 'spines', 'spine', 'hasGuild', 'guildCode', 'todayZeroPoint', 'apJson', 'skins']; \ No newline at end of file diff --git a/shared/db/Skin.ts b/shared/db/Skin.ts index f44fadb3d..6741a5354 100644 --- a/shared/db/Skin.ts +++ b/shared/db/Skin.ts @@ -17,7 +17,7 @@ export default class Skin extends BaseModel { hid: number; public static async findbyRole(roleId: string) { - const rec: SkinType[] = await SkinModel.find({ roleId }).select('id').lean(); + const rec: SkinType[] = await SkinModel.find({ roleId }, {_id: 0}).select('id skinName hid').lean(); return rec; }