任务:提取创建武将方法

This commit is contained in:
luying
2021-04-14 10:55:15 +08:00
parent d37d7cbb58
commit 93309f84f0
12 changed files with 117 additions and 91 deletions
+22 -3
View File
@@ -1,18 +1,20 @@
import { ITID, CONSUME_TYPE, getCurNameById, ITEM_TABLE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, FIGURE_UNLOCK_CONDITION } from './../consts';
import { ITID, CONSUME_TYPE, getCurNameById, ITEM_TABLE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, FIGURE_UNLOCK_CONDITION, REDIS_KEY } from './../consts';
import { EquipModel } from './../db/Equip';
import { resResult, parseGoodStr } from '../pubUtils/util';
import { getGoodById } from '../pubUtils/gamedata';
import { RoleModel, RoleType } from '../db/Role';
import { setAp } from './actionPointService';
import { calAllHeroCe } from './playerCeService';
import { calAllHeroCe, pushCalPlayerCe, pushCalAllHeroCe } from './playerCeService';
import { ItemModel } from '../db/Item';
import { STATUS } from '../consts/statusCode';
import { pinus } from 'pinus';
import { addEquips, addBags, addSkins, addFigure, unlockFigure as pubUnlockFigure } from '../pubUtils/itemUtils';
import { addEquips, addBags, addSkins, addFigure, unlockFigure as pubUnlockFigure, createHero as pubCreateHero } from '../pubUtils/itemUtils';
import { EquipInter, ItemInter, BagInter } from '../pubUtils/interface';
import { gameData } from '../pubUtils/data';
import { uniq, indexOf, findIndex } from 'underscore';
import { HeroModel } from '../db/Hero';
import { Figure } from '../domain/dbGeneral';
import { Rank } from './rankService';
export async function handleFixedReward(roleId: string, roleName: string, sid: string, rewardStr: string, multi: number) {
let reward = parseGoodStr(rewardStr);
@@ -288,9 +290,26 @@ export async function checkGoods(roleId: string, goodIds: Array<number>) {
export async function unlockFigure(sid: string, roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }[], role?: RoleType) {
let figureInfo = await pubUnlockFigure(roleId, conditions, role);
await pushFigureUpdate(roleId, sid, figureInfo);
}
export async function pushFigureUpdate(roleId: string, sid: string, figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) {
if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) {
let uids = [{uid: roleId, sid}];
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
}
}
export async function createHero(roleId: string, sid: string, serverId: number, heroInfo) {
let { hero, role, figureInfo, calHeroResult, calAllHeroResult } = await pubCreateHero(roleId, heroInfo);
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
await pushFigureUpdate(roleId, sid, figureInfo);
hero = await pushCalPlayerCe(roleId, sid, calHeroResult);
await pushCalAllHeroCe(roleId, sid, calAllHeroResult);
return hero;
}