皮肤:修改皮肤推送逻辑
This commit is contained in:
@@ -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 { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK } from '../../../consts';
|
||||||
import { getAp } from '../../../services/actionPointService';
|
import { getAp } from '../../../services/actionPointService';
|
||||||
import { ItemModel } from '../../../db/Item';
|
import { ItemModel } from '../../../db/Item';
|
||||||
|
import { SkinModel } from '../../../db/Skin';
|
||||||
import { chackFunOpenWhenLogin } from '../../../services/funcSwitchService';
|
import { chackFunOpenWhenLogin } from '../../../services/funcSwitchService';
|
||||||
import { loginRefresh } from '../../../services/playerEventService';
|
import { loginRefresh } from '../../../services/playerEventService';
|
||||||
import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil';
|
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 heros = await HeroModel.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true);
|
||||||
let equips = await EquipModel.findbyRole(role.roleId);
|
let equips = await EquipModel.findbyRole(role.roleId);
|
||||||
let items = await ItemModel.findbyRole(role.roleId);
|
let items = await ItemModel.findbyRole(role.roleId);
|
||||||
|
let skins = await SkinModel.findbyRole(role.roleId);
|
||||||
await chackFunOpenWhenLogin(role, session);
|
await chackFunOpenWhenLogin(role, session);
|
||||||
if (role.hasInit) await loginRefresh(role.roleId);
|
if (role.hasInit) await loginRefresh(role.roleId);
|
||||||
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), user.pkgName);
|
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), user.pkgName);
|
||||||
@@ -93,6 +95,7 @@ export class EntryHandler {
|
|||||||
role['heros'] = heros;
|
role['heros'] = heros;
|
||||||
role['equips'] = equips;
|
role['equips'] = equips;
|
||||||
role['consumeGoods'] = items;
|
role['consumeGoods'] = items;
|
||||||
|
role['skins'] = skins;
|
||||||
let apJson = await getAp(role.roleId, role.lv);
|
let apJson = await getAp(role.roleId, role.lv);
|
||||||
role['apJson'] = apJson;
|
role['apJson'] = apJson;
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
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 figureInfos:{ heads: Figure[], frames: Figure[], spines: Figure[] }[] = []; // 头像变化推送信息
|
||||||
let calAllHeroResult = undefined; // 全局战力变化推送
|
let calAllHeroResult = undefined; // 全局战力变化推送
|
||||||
|
|
||||||
@@ -164,13 +165,14 @@ export async function addItems(roleId: string, roleName: string, sid: string, go
|
|||||||
showItems.push({ id: skinId, count: 1 });
|
showItems.push({ id: skinId, count: 1 });
|
||||||
figureInfos.push(result.figureInfo);
|
figureInfos.push(result.figureInfo);
|
||||||
if(result.hero) {
|
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;
|
if(result.calAllHeroResult) calAllHeroResult = result.calAllHeroResult;
|
||||||
}
|
}
|
||||||
|
skinInfos.push({ id: skinId, hid: result.hero?.hid||0 })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!!skinInfos.length) {
|
if (!!skinInfos.length) {
|
||||||
pushHeroSkinMsg(skinInfos, uids); // 推送onHeroSkinChange
|
pushHeroSkinMsg(heroskins, skinInfos, uids); // 推送onHeroSkinChange
|
||||||
}
|
}
|
||||||
// 推送全局加成信息
|
// 推送全局加成信息
|
||||||
if(calAllHeroResult) await pushCalAllHeroCe(roleId, sid, calAllHeroResult);
|
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 玩家
|
* @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}[] = []; // 可能会有重复的
|
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);
|
let index = pushSkinInfos.findIndex(cur => cur.hid == hid);
|
||||||
if(index == -1) {
|
if(index == -1) {
|
||||||
pushSkinInfos.push({skins, hid});
|
pushSkinInfos.push({skins, hid});
|
||||||
@@ -393,7 +395,7 @@ function pushHeroSkinMsg(skinInfos: {skins: HeroSkin[], hid: number}[], uids: {u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pushSkinInfos.length > 0) {
|
if(pushSkinInfos.length > 0 || skinInfos.length > 0) {
|
||||||
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, { skinInfos }), uids);
|
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, { heros: heroskins, skins: skinInfos }), uids);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,4 +49,4 @@ export enum FRIEND_SHIP_SELECT {
|
|||||||
GET_FRIEND_VALUE = 'friendValue friendLv'
|
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'];
|
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'];
|
||||||
+1
-1
@@ -17,7 +17,7 @@ export default class Skin extends BaseModel {
|
|||||||
hid: number;
|
hid: number;
|
||||||
|
|
||||||
public static async findbyRole(roleId: string) {
|
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;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user