优化:减少初始以及合成武将时返回的数据
This commit is contained in:
@@ -103,7 +103,7 @@ export class GachaHandler {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
gachaId, activityId,
|
||||
freeCount, refFreeTime: userGacha.refFreeTime, count: userGacha.count, point: userGacha.point, floor, hope,
|
||||
heroes: resultHeroes,
|
||||
// heroes: resultHeroes,
|
||||
addHeros: heroes,
|
||||
result: resultList
|
||||
});
|
||||
@@ -223,7 +223,7 @@ export class GachaHandler {
|
||||
turntable: userGacha.turntable,
|
||||
result: resultList,
|
||||
addHeros: heroes,
|
||||
heroes: resultHeroes
|
||||
// heroes: resultHeroes
|
||||
});
|
||||
}
|
||||
|
||||
@@ -468,7 +468,7 @@ export class GachaHandler {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
hasInit: !!role.gachaHasGuide,
|
||||
gachaId,
|
||||
heroes: resultHeroes,
|
||||
// heroes: resultHeroes,
|
||||
addHeros: heroes,
|
||||
result: resultList
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ export class NewHeroGachaHandler {
|
||||
let commonResult = await addReward(roleId, roleName, sid, serverId, newRewardParamArr, ITEM_CHANGE_REASON.NEW_HERO_GACHA_PULL)
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
hid, activityId, count, randomReward: { heroes: resultHeroes, result: resultList }, commonReward: commonResult
|
||||
hid, activityId, count, randomReward: { heroes: resultHeroes.map(cur => ({hid: cur.hid})), result: resultList }, commonReward: commonResult
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Application, HandlerService, pinus, } from 'pinus';
|
||||
import { FrontendSession } from 'pinus';
|
||||
import { HeroModel } from './../../../db/Hero';
|
||||
import { genCode, generateStr, resResult } from '../../../pubUtils/util';
|
||||
import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK, COUNTER, DEFAULT_LV, TA_USERSET_TYPE, LOG_TYPE } from '../../../consts';
|
||||
import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK, COUNTER, DEFAULT_LV, TA_USERSET_TYPE, LOG_TYPE, JEWEL_SELECT, ITEM_SELECT, SKIN_SELECT } from '../../../consts';
|
||||
// import { loginRefresh } from '../../../services/playerEventService';
|
||||
import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil';
|
||||
import { rmRoleFromQueue, roleLeave, getRoleOnlineInfo, roleLogin } from '../../../services/redisService';
|
||||
@@ -308,9 +308,9 @@ export class EntryHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, '-_id', true, true);
|
||||
let heros = await HeroModel.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true);
|
||||
let jewels = await JewelModel.findbyRole(role.roleId);
|
||||
let items = await ItemModel.findbyRole(role.roleId);
|
||||
let skins = await SkinModel.findbyRole(role.roleId);
|
||||
let jewels = await JewelModel.findbyRole(role.roleId, JEWEL_SELECT.ENTRY);
|
||||
let items = await ItemModel.findbyRole(role.roleId, ITEM_SELECT.ENTRY);
|
||||
let skins = await SkinModel.findbyRole(role.roleId, SKIN_SELECT.ENTRY);
|
||||
|
||||
role['heros'] = heros.map(hero => new HeroParam(hero));
|
||||
role['jewels'] = jewels;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { resResult, getRandEelm, getResStr, shouldRefresh, sortArrRandom, checkRoleIsRobot, getRobotSysType, makeRobotId, parseNumberList } from "../../../pubUtils/util";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, EQUIP_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON } from "../../../consts";
|
||||
import { RoleModel, RoleType } from "../../../db/Role";
|
||||
import { getTimeFun, getZeroPointD } from "../../../pubUtils/timeUtil";
|
||||
import { FriendApplyModel } from "../../../db/FriendApply";
|
||||
|
||||
@@ -56,7 +56,7 @@ export class HeroHandler {
|
||||
let { heroes, resultHeroes } = await createHero(roleId, roleName, sid, serverId, { hid, count: 1 });
|
||||
|
||||
pushComposeOrangeHero(roleId, roleName, serverId, resultHeroes[0]);
|
||||
return resResult(STATUS.SUCCESS, { curHero: new HeroParam(resultHeroes[0]), addHeros: heroes });
|
||||
return resResult(STATUS.SUCCESS, { curHero: {hid}, addHeros: heroes });
|
||||
}
|
||||
|
||||
// 武将升级
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getCurTask, getPvpTask } from './task/taskService';
|
||||
import { RoleType } from '../db/Role';
|
||||
import { Application, FrontendOrBackendSession, pinus, RpcClient } from 'pinus';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { STATUS, PUSH_BATCH, PUSH_INTERVAL, CONSUME_TYPE, HERO_SELECT, ENTERY_ROLE_PICK } from '../consts';
|
||||
import { STATUS, PUSH_BATCH, PUSH_INTERVAL, CONSUME_TYPE, HERO_SELECT, ENTERY_ROLE_PICK, JEWEL_SELECT, ITEM_SELECT, SKIN_SELECT } from '../consts';
|
||||
import { getAllShopList } from './shopService';
|
||||
import { getGeneralRank, getRankFirstReward } from './rankService';
|
||||
import { getFriendList, getApplyList } from './friendService';
|
||||
@@ -109,9 +109,9 @@ async function getModuleData(type: string, data: { role: RoleType, session: Fron
|
||||
switch (type) {
|
||||
case 'role':
|
||||
let heros = await HeroModel.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true);
|
||||
let jewels = await JewelModel.findbyRole(role.roleId);
|
||||
let items = await ItemModel.findbyRole(role.roleId);
|
||||
let skins = await SkinModel.findbyRole(role.roleId);
|
||||
let jewels = await JewelModel.findbyRole(role.roleId, JEWEL_SELECT.ENTRY);
|
||||
let items = await ItemModel.findbyRole(role.roleId, ITEM_SELECT.ENTRY);
|
||||
let skins = await SkinModel.findbyRole(role.roleId, SKIN_SELECT.ENTRY);
|
||||
|
||||
role['heros'] = heros.map(hero => new HeroParam(hero));
|
||||
role['jewels'] = jewels;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { gameData } from '../../pubUtils/data';
|
||||
import { uniq } from 'underscore';
|
||||
import { EPlace, HeroModel, HeroType, HeroUpdate } from '../../db/Hero';
|
||||
import { Figure } from '../../domain/dbGeneral';
|
||||
import { CreateHeroParam, HeroShowParam } from '../../domain/roleField/hero';
|
||||
import { CreateHeroParam, HeroShowParam, JewelParam } from '../../domain/roleField/hero';
|
||||
import { HeroSkin } from '../../db/Hero';
|
||||
import { errlogger } from '../../util/logger';
|
||||
import { BAG } from '../../pubUtils/dicParam';
|
||||
@@ -399,9 +399,7 @@ export async function addJewels(roleId: string, roleName: string, jewels: { id:
|
||||
}
|
||||
|
||||
const jewelResult = await JewelModel.createJewels(roleId, jewelInfo);
|
||||
return { jewels: jewelResult.map(jewel => {
|
||||
return { ...jewel, count: 1, inc: 1, reason }
|
||||
})}
|
||||
return { jewels: jewelResult.map(jewel => new JewelParam(jewel, true, reason))}
|
||||
}
|
||||
|
||||
export async function getAddJewelInfo(roleId: string, roleName: string, jewel: { id: number, }) {
|
||||
|
||||
@@ -18,14 +18,22 @@ export enum ROLE_SELECT {
|
||||
};
|
||||
|
||||
export enum HERO_SELECT {
|
||||
ENTRY = '-_id -attr',
|
||||
ENTRY = '-_id -attr -__v',
|
||||
HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins attr ePlace skinId',
|
||||
// 排行榜中lineup字段
|
||||
RANK_LINEUP = 'seqId roleId hid star colorStar lv quality job ce updatedAt skinId'
|
||||
}
|
||||
|
||||
export enum EQUIP_SELECT {
|
||||
HERO_DETAIL = 'id name ePlaceId quality holes randSe randRange randMain'
|
||||
export enum JEWEL_SELECT {
|
||||
ENTRY = '-_id -__v -roleId -roleName -name -previewRandSe -createdAt -updatedAt'
|
||||
}
|
||||
|
||||
export enum ITEM_SELECT {
|
||||
ENTRY = '-_id -__v -roleId -roleName -itemName -createdAt -updatedAt'
|
||||
}
|
||||
|
||||
export enum SKIN_SELECT {
|
||||
ENTRY = '-_id -__v -roleId -roleName -skinName -createdAt -updatedAt'
|
||||
}
|
||||
|
||||
export enum FRIEND_SELECT {
|
||||
@@ -33,7 +41,7 @@ export enum FRIEND_SELECT {
|
||||
}
|
||||
|
||||
export enum USER_GUILD_SELECT {
|
||||
ENTRY = 'guildCode auth'
|
||||
ENTRY = '-_id -_v guildCode auth'
|
||||
}
|
||||
|
||||
export enum GUILD_SELECT {
|
||||
|
||||
@@ -25,8 +25,8 @@ export default class Item extends BaseModel {
|
||||
count: number; // 道具数量
|
||||
|
||||
|
||||
public static async findbyRole(roleId: string, lean = true) {
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, count: {$gte: 0} }).select('id count type').lean(lean);
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const items: ItemType[] = await ItemModel.find({ roleId, count: {$gte: 0} }).select(select).lean();
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ export default class Jewel extends BaseModel {
|
||||
@prop({ required: false, type: RandSe, default: [], _id: false })
|
||||
previewRandSe: RandSe[]; // 强化随机属性预览
|
||||
|
||||
public static async findbyRole(roleId: string, lean = true) {
|
||||
const jewels: JewelType[] = await JewelModel.find({ roleId }).lean(lean);
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const jewels: JewelType[] = await JewelModel.find({ roleId }).select(select).lean();
|
||||
return jewels;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ export default class Skin extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
hid: number; // 原始武将id
|
||||
|
||||
public static async findbyRole(roleId: string) {
|
||||
const rec: SkinType[] = await SkinModel.find({ roleId }, {_id: 0}).select('id skinId skinName hid').lean();
|
||||
public static async findbyRole(roleId: string, select = '') {
|
||||
const rec: SkinType[] = await SkinModel.find({ roleId }).select(select).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
|
||||
interface QuenchAddParam {
|
||||
id: number; // 属性id
|
||||
value: number; // 增加的值
|
||||
}
|
||||
|
||||
export class QuenchLogParam {
|
||||
times: number; // 第几次
|
||||
isCriticle: boolean; // 是否暴击
|
||||
add: QuenchAddParam[];
|
||||
|
||||
constructor(isCriticle: boolean, add: Map<number, number>) {
|
||||
this.isCriticle = isCriticle;
|
||||
|
||||
let arr: QuenchAddParam[] = [];
|
||||
for(let [id, value] of add) {
|
||||
arr.push({ id, value });
|
||||
}
|
||||
this.add = arr;
|
||||
}
|
||||
|
||||
setTimes(times: number) {
|
||||
this.times = times;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Talent } from '../../db/Hero';
|
||||
import { JewelType, RandSe } from '../../db/Jewel';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
export interface CreateHeroParam extends HeroUpdate {
|
||||
hid: number;
|
||||
@@ -34,7 +35,6 @@ class HeroSKinParam {
|
||||
// 传给客户端的武将数据
|
||||
export class HeroParam {
|
||||
hid: number; // 武将 id
|
||||
hName: string; // 武将名
|
||||
seqId: number; // 武将表自增 id
|
||||
|
||||
exp: number; // 经验值
|
||||
@@ -69,7 +69,6 @@ export class HeroParam {
|
||||
constructor(hero: HeroType) {
|
||||
this.seqId = hero.seqId;
|
||||
this.hid = hero.hid;
|
||||
this.hName = hero.hName;
|
||||
this.exp = hero.exp;
|
||||
this.lv = hero.lv;
|
||||
this.ce = hero.ce;
|
||||
@@ -99,4 +98,31 @@ export class HeroParam {
|
||||
}
|
||||
this.ePlace = hero.ePlace;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class JewelParam {
|
||||
seqId: number; // 唯一id
|
||||
id: number; // 装备id
|
||||
name: string; // 装备名
|
||||
hid: number; // 装备此装备的武将
|
||||
ePlaceId: number; // 装备在哪个位置
|
||||
|
||||
randSe: RandSe[];
|
||||
count: number;
|
||||
inc: number;
|
||||
reason: number;
|
||||
|
||||
constructor(jewel: JewelType, isPush?: boolean, reason?: number) {
|
||||
this.seqId = jewel.seqId;
|
||||
this.id = jewel.id;
|
||||
this.name = jewel.name;
|
||||
this.hid = jewel.hid;
|
||||
this.ePlaceId = jewel.ePlaceId;
|
||||
this.randSe = jewel.randSe;
|
||||
if(isPush) {
|
||||
this.count = 1;
|
||||
this.inc = 1;
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user