任务:提取创建武将方法
This commit is contained in:
@@ -2,7 +2,7 @@ import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType, Ref } from '@typegoose/typegoose';
|
||||
import Role, { RoleType } from './Role';
|
||||
import { genCode } from '../pubUtils/util';
|
||||
import { GUILD_STRUCTURE, GUILD_STATUS, GUILD_PER_PAGE, GUILD_SELECT, RANK_TYPE, REDIS_KEY } from '../consts';
|
||||
import { GUILD_STRUCTURE, GUILD_STATUS, GUILD_PER_PAGE, GUILD_SELECT, REDIS_KEY } from '../consts';
|
||||
import { getCurWeekTime, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { reduceCe } from '../pubUtils/util';
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import Equip, { } from './Equip';
|
||||
import { CounterModel } from './Counter';
|
||||
import { COUNTER, EQUIP_TYPE } from '../consts';
|
||||
import { reduceCe } from '../pubUtils/util';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
|
||||
class CeAttrData {
|
||||
@prop({ required: true })
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import { ABI_TYPE, ABI_STAGE, COM_BTL_LV_RANGE } from '../consts';
|
||||
import { ABI_TYPE, COM_BTL_LV_RANGE } from '../consts';
|
||||
import { decodeIdCntArrayStr, getRandEelm } from './util';
|
||||
import { IT_TYPE } from '../consts';
|
||||
|
||||
@@ -26,22 +26,6 @@ const blueprtCompose = new Map<number, any>();
|
||||
const fiendShips = new Map<string, any>();
|
||||
const comBtlLvRange = new Map<number, Array<number>>();
|
||||
|
||||
interface dicStar {
|
||||
id: number;
|
||||
quality: number;
|
||||
star: number;
|
||||
advanceUpFragmentNum: number;
|
||||
ceAttr: Map<number, number>
|
||||
}
|
||||
interface dicWake {
|
||||
id: number;
|
||||
quality: number;
|
||||
star: number;
|
||||
fragmentNum: number;
|
||||
consume: string;
|
||||
ceAttr: Map<number, number>
|
||||
}
|
||||
|
||||
function parseWarData() {
|
||||
let result = null;
|
||||
for (let filename of wars) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
import { HeroModel, HeroUpdate, HeroType } from '../db/Hero';
|
||||
import { HeroModel, HeroUpdate } from '../db/Hero';
|
||||
import { ItemModel } from '../db/Item';
|
||||
import { EquipModel, RandSe, Holes } from './../db/Equip';
|
||||
import { BagInter, EquipInter } from './interface';
|
||||
@@ -11,8 +11,8 @@ import { getRandValueByMinMax, getRandEelm } from './util';
|
||||
import { findWhere } from 'underscore';
|
||||
import { RoleModel, RoleType } from '../db/Role';
|
||||
import { Figure } from '../domain/dbGeneral';
|
||||
import { getBeforeDaySeconds } from './timeUtil';
|
||||
import { calPlayerCeAndSave } from './playerCe';
|
||||
import { getBeforeDaySeconds, nowSeconds } from './timeUtil';
|
||||
import { calPlayerCeAndSave, reCalAllHeroCe } from './playerCe';
|
||||
|
||||
export async function addSkins(roleId: string, id: number) {
|
||||
let skinInfo = gameData.fashion.get(id);
|
||||
@@ -98,7 +98,7 @@ export async function unlockFigure(roleId: string, conditions: { type: number, p
|
||||
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
||||
}
|
||||
let { heads, frames, spines } = role;
|
||||
let figureInfo = { heads: [], frames: [], spines: [] };
|
||||
let figureInfo = { heads: new Array<Figure>(), frames: new Array<Figure>(), spines: new Array<Figure>() };
|
||||
for(let {type, paramHid, paramFavourLv, paramSkinId } of conditions) {
|
||||
let canUnLockList = gameData.figureCondition.get(type);
|
||||
if(canUnLockList) {
|
||||
@@ -214,4 +214,34 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = fals
|
||||
}
|
||||
|
||||
return figure
|
||||
}
|
||||
|
||||
export async function createHero(roleId: string, heroInfo: HeroUpdate) {
|
||||
let { role, figureInfo, heroes, calHeroResults, calAllHeroResults } = await createHeroes(roleId, [heroInfo])
|
||||
return { hero: heroes[0], role, figureInfo, calHeroResult: calHeroResults[0], calAllHeroResult: calAllHeroResults[0] }
|
||||
}
|
||||
|
||||
export async function createHeroes(roleId: string, heroInfos: HeroUpdate[]) {
|
||||
|
||||
let heroNum = 0;
|
||||
let skinIds = new Array<number>();
|
||||
let conditions = new Array<{type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>();
|
||||
let heroes = [], calHeroResults = [], calAllHeroResults = [];
|
||||
|
||||
for(let heroInfo of heroInfos) {
|
||||
let curHero = await HeroModel.createHero(heroInfo); heroes.push(curHero);
|
||||
let calHeroResult = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, roleId, curHero, {}); calHeroResults.push(calHeroResult);
|
||||
let calAllHeroResult = await reCalAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, {}, skinIds); calAllHeroResults.push(calAllHeroResult);
|
||||
|
||||
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid });
|
||||
heroInfo.skins.forEach(cur => {
|
||||
skinIds.push(cur.id);
|
||||
conditions.push({type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: cur.id});
|
||||
});
|
||||
heroNum ++;
|
||||
}
|
||||
let figureInfo = await unlockFigure(roleId, conditions); // 解锁头像
|
||||
|
||||
let role = await RoleModel.incRoleInfo(roleId, { heroNum }, { heroNumUpdatedAt: nowSeconds() });
|
||||
return { role, figureInfo, heroes, calHeroResults, calAllHeroResults }
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU
|
||||
let heros = await HeroModel.findByRole(roleId);
|
||||
|
||||
let roleAttrs = await reCalRoleAttr(type, heros, role, update, args);
|
||||
if(!roleAttrs) return {pushHeros: [], ce: role.ce, topLineupCe: role.topLineupCe}; // 无加成
|
||||
if(!roleAttrs) return {role, pushHeros: [], ce: role.ce, topLineupCe: role.topLineupCe, serverId: role.serverId}; // 无加成
|
||||
|
||||
let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user