任务:提取创建武将方法
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import {Application, BackendSession, ChannelService} from 'pinus';
|
import {Application, BackendSession, ChannelService} from 'pinus';
|
||||||
import { handleCost, addItems, unlockFigure } from '../../../services/rewardService';
|
import { handleCost, addItems, unlockFigure, createHero } from '../../../services/rewardService';
|
||||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
||||||
import { resResult, returnHeroCeRatio, deepCopy } from '../../../pubUtils/util';
|
import { resResult, returnHeroCeRatio, deepCopy } from '../../../pubUtils/util';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
@@ -138,16 +138,10 @@ export class HeroHandler {
|
|||||||
let costResult = await handleCost(roleId, sid, [{id: pieceId, count: pieceCount}]);
|
let costResult = await handleCost(roleId, sid, [{id: pieceId, count: pieceCount}]);
|
||||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
// createHero
|
// createHero
|
||||||
let curHero = await HeroModel.createHero({
|
let hero = await createHero(roleId, sid, serverId, {
|
||||||
roleId, serverId, roleName, hid, hName, star, quality, job, skins:[{id: initialSkin, enable: true}]
|
roleId, serverId, roleName, hid, hName, star, quality, job, skins:[{id: initialSkin, enable: true}]
|
||||||
});
|
});
|
||||||
let role = await RoleModel.incRoleInfo(roleId, { heroNum: 1 }, { heroNumUpdatedAt: nowSeconds() });
|
|
||||||
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
|
|
||||||
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
|
|
||||||
|
|
||||||
await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: hid }]); // 解锁头像
|
|
||||||
let hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, sid, roleId, curHero, {});
|
|
||||||
await calAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, sid, roleId, {}, [initialSkin])
|
|
||||||
pushComposeOrangeHero(roleId, roleName, serverId, hero);
|
pushComposeOrangeHero(roleId, roleName, serverId, hero);
|
||||||
return resResult(STATUS.SUCCESS, {curHero: returnHeroCeRatio(hero)});
|
return resResult(STATUS.SUCCESS, {curHero: returnHeroCeRatio(hero)});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,18 +7,33 @@ import { STATUS } from '../consts/statusCode';
|
|||||||
|
|
||||||
import { resResult, reduceCe } from '../pubUtils/util';
|
import { resResult, reduceCe } from '../pubUtils/util';
|
||||||
import { calPlayerCeAndSave as pubCalPlayerCeAndSave, reCalAllHeroCe } from '../pubUtils/playerCe';
|
import { calPlayerCeAndSave as pubCalPlayerCeAndSave, reCalAllHeroCe } from '../pubUtils/playerCe';
|
||||||
import Hero, { HeroType, HeroUpdate } from '../db/Hero';
|
import { HeroType, HeroUpdate } from '../db/Hero';
|
||||||
import { defaultHeroes } from './pvpService';
|
import { defaultHeroes } from './pvpService';
|
||||||
|
|
||||||
import { RoleUpdate, RoleType } from '../db/Role';
|
import { RoleUpdate, RoleType } from '../db/Role';
|
||||||
import { Rank } from './rankService';
|
import { Rank } from './rankService';
|
||||||
import { REDIS_KEY } from '../consts';
|
import { REDIS_KEY } from '../consts';
|
||||||
import { updateUserInfo } from './redisService';
|
import { updateUserInfo } from './redisService';
|
||||||
|
import { GuildType } from '../db/Guild';
|
||||||
|
|
||||||
|
interface calPlayerReturn {
|
||||||
|
serverId: number;
|
||||||
|
role: RoleType;
|
||||||
|
guild?: GuildType;
|
||||||
|
hero?: HeroType;
|
||||||
|
pushHeros: {hid: number, ce: number, incHeroCe: number}[];
|
||||||
|
topLineupCe: number
|
||||||
|
}
|
||||||
|
|
||||||
//修改并下发战力
|
//修改并下发战力
|
||||||
export async function calPlayerCeAndSave(type: number, sid: string, roleId: string, originHero: HeroType, update: HeroUpdate, args?: Array<number>) {
|
export async function calPlayerCeAndSave(type: number, sid: string, roleId: string, originHero: HeroType, update: HeroUpdate, args?: Array<number>) {
|
||||||
let {role, pushHeros, topLineupCe, hero, guild, serverId} = await pubCalPlayerCeAndSave(type, roleId, originHero, update, args);
|
let result = await pubCalPlayerCeAndSave(type, roleId, originHero, update, args);
|
||||||
|
return await pushCalPlayerCe(roleId, sid, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改后战力的推送
|
||||||
|
export async function pushCalPlayerCe(roleId: string, sid: string, calResult: calPlayerReturn) {
|
||||||
|
let {role, pushHeros, topLineupCe, hero, guild, serverId} = calResult;
|
||||||
// console.log(JSON.stringify(pushHeros))
|
// console.log(JSON.stringify(pushHeros))
|
||||||
//下发战力
|
//下发战力
|
||||||
let uids = [{ uid: roleId, sid }];
|
let uids = [{ uid: roleId, sid }];
|
||||||
@@ -32,18 +47,27 @@ export async function calPlayerCeAndSave(type: number, sid: string, roleId: stri
|
|||||||
return hero;
|
return hero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 修改全局战力并下发
|
||||||
export async function calAllHeroCe(type:number, sid: string, roleId: string, update: RoleUpdate, args?:Array<number>) {
|
export async function calAllHeroCe(type:number, sid: string, roleId: string, update: RoleUpdate, args?:Array<number>) {
|
||||||
let {role, ce, pushHeros, topLineupCe, guild, serverId } = await reCalAllHeroCe(type, roleId, update, args);
|
let result = await reCalAllHeroCe(type, roleId, update, args);
|
||||||
|
if(result.pushHeros.length > 0) {
|
||||||
if(pushHeros.length > 0) {
|
return await pushCalAllHeroCe(roleId, sid, result);
|
||||||
let uids = [{ uid: roleId, sid }];
|
} else {
|
||||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHeros, topLineupCe: reduceCe(topLineupCe) }), uids);
|
return result.role;
|
||||||
|
|
||||||
if(guild) {
|
|
||||||
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }]);
|
|
||||||
}
|
|
||||||
updateRank(roleId, serverId, topLineupCe, role, pushHeros);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改全局战力的推送
|
||||||
|
export async function pushCalAllHeroCe(roleId: string, sid: string, calResult: calPlayerReturn) {
|
||||||
|
let {role, pushHeros, topLineupCe, guild, serverId } = calResult;
|
||||||
|
let uids = [{ uid: roleId, sid }];
|
||||||
|
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce), heros: pushHeros, topLineupCe: reduceCe(topLineupCe) }), uids);
|
||||||
|
|
||||||
|
if(guild) {
|
||||||
|
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }]);
|
||||||
|
}
|
||||||
|
updateRank(roleId, serverId, topLineupCe, role, pushHeros);
|
||||||
|
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 { EquipModel } from './../db/Equip';
|
||||||
import { resResult, parseGoodStr } from '../pubUtils/util';
|
import { resResult, parseGoodStr } from '../pubUtils/util';
|
||||||
import { getGoodById } from '../pubUtils/gamedata';
|
import { getGoodById } from '../pubUtils/gamedata';
|
||||||
import { RoleModel, RoleType } from '../db/Role';
|
import { RoleModel, RoleType } from '../db/Role';
|
||||||
import { setAp } from './actionPointService';
|
import { setAp } from './actionPointService';
|
||||||
import { calAllHeroCe } from './playerCeService';
|
import { calAllHeroCe, pushCalPlayerCe, pushCalAllHeroCe } from './playerCeService';
|
||||||
import { ItemModel } from '../db/Item';
|
import { ItemModel } from '../db/Item';
|
||||||
import { STATUS } from '../consts/statusCode';
|
import { STATUS } from '../consts/statusCode';
|
||||||
import { pinus } from 'pinus';
|
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 { EquipInter, ItemInter, BagInter } from '../pubUtils/interface';
|
||||||
import { gameData } from '../pubUtils/data';
|
import { gameData } from '../pubUtils/data';
|
||||||
import { uniq, indexOf, findIndex } from 'underscore';
|
import { uniq, indexOf, findIndex } from 'underscore';
|
||||||
import { HeroModel } from '../db/Hero';
|
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) {
|
export async function handleFixedReward(roleId: string, roleName: string, sid: string, rewardStr: string, multi: number) {
|
||||||
let reward = parseGoodStr(rewardStr);
|
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) {
|
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);
|
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)) {
|
if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) {
|
||||||
let uids = [{uid: roleId, sid}];
|
let uids = [{uid: roleId, sid}];
|
||||||
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
|
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;
|
||||||
}
|
}
|
||||||
@@ -4,11 +4,8 @@ import { getRandNum, getRandomArr } from '../pubUtils/util';
|
|||||||
import { TERAPH_RANDOM } from "../consts/consts";
|
import { TERAPH_RANDOM } from "../consts/consts";
|
||||||
import { indexOf } from 'underscore';
|
import { indexOf } from 'underscore';
|
||||||
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
|
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
|
||||||
import { Teraph, RoleType, RoleModel } from '../db/Role';
|
import { Teraph, RoleModel } from '../db/Role';
|
||||||
import { ROLE_SELECT, FIGURE_UNLOCK_CONDITION, ITID, CONSUME_TYPE } from '../consts';
|
import { ROLE_SELECT } from '../consts';
|
||||||
import { gameData } from '../pubUtils/data';
|
|
||||||
import { Figure } from '../domain/dbGeneral';
|
|
||||||
import { getBeforeDaySeconds } from '../pubUtils/timeUtil';
|
|
||||||
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
/**
|
/**
|
||||||
* 计算强化次数和消耗
|
* 计算强化次数和消耗
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { PvpDefenseModel } from '@db/PvpDefense';
|
|||||||
|
|
||||||
import { Service } from 'egg';
|
import { Service } from 'egg';
|
||||||
import Counter from '@db/Counter';
|
import Counter from '@db/Counter';
|
||||||
import { STATUS, HERO_SYSTEM_TYPE, FIGURE_UNLOCK_CONDITION } from '@consts';
|
import { STATUS, HERO_SYSTEM_TYPE } from '@consts';
|
||||||
import { ITID, COUNTER } from '@consts';
|
import { ITID, COUNTER } from '@consts';
|
||||||
import { ItemModel } from '@db/Item';
|
import { ItemModel } from '@db/Item';
|
||||||
import { gameData, getHeroExpByLv } from '@pubUtils/data';
|
import { gameData, getHeroExpByLv } from '@pubUtils/data';
|
||||||
@@ -32,8 +32,7 @@ import { isString } from 'underscore';
|
|||||||
import { FriendShipModel } from '@db/FriendShip';
|
import { FriendShipModel } from '@db/FriendShip';
|
||||||
import { FriendApplyModel } from '@db/FriendApply';
|
import { FriendApplyModel } from '@db/FriendApply';
|
||||||
import { FriendRelationModel } from '@db/FriendRelation';
|
import { FriendRelationModel } from '@db/FriendRelation';
|
||||||
import { unlockFigure } from '@pubUtils/itemUtils';
|
import { createHero as pubCreateHero } from '@pubUtils/itemUtils';
|
||||||
import { nowSeconds } from '@pubUtils/timeUtil';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Service
|
* Test Service
|
||||||
@@ -268,10 +267,7 @@ export default class GMUsers extends Service {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for(let heroInfo of heroInfos) {
|
for(let heroInfo of heroInfos) {
|
||||||
let hero = await HeroModel.createHero(heroInfo);
|
await pubCreateHero(heroInfo.roleId, heroInfo);
|
||||||
await RoleModel.incRoleInfo(heroInfo.roleId, { heroNum: 1 }, { heroNumUpdatedAt: nowSeconds() });
|
|
||||||
await unlockFigure(heroInfo.roleId, [{ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid }]); // 解锁头像
|
|
||||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, heroInfo.roleId, hero, {});
|
|
||||||
}
|
}
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import BaseModel from './BaseModel';
|
|||||||
import { index, getModelForClass, prop, DocumentType, Ref } from '@typegoose/typegoose';
|
import { index, getModelForClass, prop, DocumentType, Ref } from '@typegoose/typegoose';
|
||||||
import Role, { RoleType } from './Role';
|
import Role, { RoleType } from './Role';
|
||||||
import { genCode } from '../pubUtils/util';
|
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 { getCurWeekTime, nowSeconds } from '../pubUtils/timeUtil';
|
||||||
import { reduceCe } from '../pubUtils/util';
|
import { reduceCe } from '../pubUtils/util';
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Equip, { } from './Equip';
|
|||||||
import { CounterModel } from './Counter';
|
import { CounterModel } from './Counter';
|
||||||
import { COUNTER, EQUIP_TYPE } from '../consts';
|
import { COUNTER, EQUIP_TYPE } from '../consts';
|
||||||
import { reduceCe } from '../pubUtils/util';
|
import { reduceCe } from '../pubUtils/util';
|
||||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
|
||||||
|
|
||||||
class CeAttrData {
|
class CeAttrData {
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
import path = require('path');
|
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 { decodeIdCntArrayStr, getRandEelm } from './util';
|
||||||
import { IT_TYPE } from '../consts';
|
import { IT_TYPE } from '../consts';
|
||||||
|
|
||||||
@@ -26,22 +26,6 @@ const blueprtCompose = new Map<number, any>();
|
|||||||
const fiendShips = new Map<string, any>();
|
const fiendShips = new Map<string, any>();
|
||||||
const comBtlLvRange = new Map<number, Array<number>>();
|
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() {
|
function parseWarData() {
|
||||||
let result = null;
|
let result = null;
|
||||||
for (let filename of wars) {
|
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 { ItemModel } from '../db/Item';
|
||||||
import { EquipModel, RandSe, Holes } from './../db/Equip';
|
import { EquipModel, RandSe, Holes } from './../db/Equip';
|
||||||
import { BagInter, EquipInter } from './interface';
|
import { BagInter, EquipInter } from './interface';
|
||||||
@@ -11,8 +11,8 @@ import { getRandValueByMinMax, getRandEelm } from './util';
|
|||||||
import { findWhere } from 'underscore';
|
import { findWhere } from 'underscore';
|
||||||
import { RoleModel, RoleType } from '../db/Role';
|
import { RoleModel, RoleType } from '../db/Role';
|
||||||
import { Figure } from '../domain/dbGeneral';
|
import { Figure } from '../domain/dbGeneral';
|
||||||
import { getBeforeDaySeconds } from './timeUtil';
|
import { getBeforeDaySeconds, nowSeconds } from './timeUtil';
|
||||||
import { calPlayerCeAndSave } from './playerCe';
|
import { calPlayerCeAndSave, reCalAllHeroCe } from './playerCe';
|
||||||
|
|
||||||
export async function addSkins(roleId: string, id: number) {
|
export async function addSkins(roleId: string, id: number) {
|
||||||
let skinInfo = gameData.fashion.get(id);
|
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);
|
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
|
||||||
}
|
}
|
||||||
let { heads, frames, spines } = role;
|
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) {
|
for(let {type, paramHid, paramFavourLv, paramSkinId } of conditions) {
|
||||||
let canUnLockList = gameData.figureCondition.get(type);
|
let canUnLockList = gameData.figureCondition.get(type);
|
||||||
if(canUnLockList) {
|
if(canUnLockList) {
|
||||||
@@ -214,4 +214,34 @@ function unlockSingleFigure(dbFigures: Figure[], id: number, unlockDirect = fals
|
|||||||
}
|
}
|
||||||
|
|
||||||
return figure
|
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 heros = await HeroModel.findByRole(roleId);
|
||||||
|
|
||||||
let roleAttrs = await reCalRoleAttr(type, heros, role, update, args);
|
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 }>();
|
let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
import { COUNTER, HERO_SYSTEM_TYPE, DEFAULT_LV, DEFAULT_ITEMS, ITID, DEFAULT_GOLD, DEFAULT_HERO_LV, DEFAULT_EQUIPS, DEFAULT_COIN, ADULT_AGE, GUEST_MAX_TIME, FIGURE_UNLOCK_CONDITION } from '@consts';
|
import { COUNTER, DEFAULT_LV, DEFAULT_ITEMS, ITID, DEFAULT_GOLD, DEFAULT_HERO_LV, DEFAULT_EQUIPS, DEFAULT_COIN, ADULT_AGE, GUEST_MAX_TIME } from '@consts';
|
||||||
import { DEFAULT_HEROES } from '@consts';
|
import { DEFAULT_HEROES } from '@consts';
|
||||||
import { HeroModel } from '@db/Hero';
|
import { HeroModel } from '@db/Hero';
|
||||||
import { RoleModel } from '@db/Role';
|
import { RoleModel } from '@db/Role';
|
||||||
@@ -8,13 +8,13 @@ import { STATUS, GET_SMS_TYPE, ADDICTION_PREVENTION_CODE } from '@consts';
|
|||||||
import { smsModel } from '@db/Sms';
|
import { smsModel } from '@db/Sms';
|
||||||
import { Service } from 'egg';
|
import { Service } from 'egg';
|
||||||
import Counter from '@db/Counter';
|
import Counter from '@db/Counter';
|
||||||
import { getHeroInfoById } from 'app/pubUtils/gamedata';
|
import { getHeroInfoById } from '../pubUtils/gamedata';
|
||||||
import { calPlayerCeAndSave, reCalAllHeroCe } from 'app/pubUtils/playerCe';
|
import { getExpByLv, getHeroExpByLv, gameData } from '../pubUtils/data';
|
||||||
import { getExpByLv, getHeroExpByLv, gameData } from 'app/pubUtils/data';
|
|
||||||
import { isString } from 'underscore';
|
import { isString } from 'underscore';
|
||||||
import { getAge, nowSeconds } from 'app/pubUtils/timeUtil';
|
import { getAge } from '../pubUtils/timeUtil';
|
||||||
import { shouldRefresh, resResult } from 'app/pubUtils/util';
|
import { shouldRefresh, resResult } from '../pubUtils/util';
|
||||||
import { authenticate } from 'app/pubUtils/httpUtil';
|
import { authenticate } from '../pubUtils/httpUtil';
|
||||||
|
import { createHeroes } from '../pubUtils/itemUtils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Service
|
* Test Service
|
||||||
@@ -301,40 +301,23 @@ export default class Auth extends Service {
|
|||||||
|
|
||||||
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 });
|
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 });
|
||||||
if (role) {
|
if (role) {
|
||||||
let skinIds = new Array<number>();
|
let heroInfos = [];
|
||||||
let conditions = new Array<{type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>()
|
|
||||||
|
|
||||||
let heroNum = 0;
|
|
||||||
for (let hid of DEFAULT_HEROES) {
|
for (let hid of DEFAULT_HEROES) {
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||||
if (hero) {
|
if (hero) continue
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let dicHero = getHeroInfoById(hid);
|
let dicHero = getHeroInfoById(hid);
|
||||||
if (!dicHero) {
|
if (!dicHero) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = dicHero;
|
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = dicHero;
|
||||||
|
|
||||||
hero = await HeroModel.createHero({
|
heroInfos.push({
|
||||||
roleId, roleName: role.roleName, hid, hName, star, quality, job, serverId: role.serverId,
|
roleId, roleName: role.roleName, hid, hName, star, quality, job, serverId: role.serverId,
|
||||||
skins: [{ id: initialSkin, enable: true }], lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0
|
skins: [{ id: initialSkin, enable: true }], lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0
|
||||||
});
|
});
|
||||||
skinIds.push(initialSkin);
|
|
||||||
conditions.push({type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: hid});
|
|
||||||
conditions.push({type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: initialSkin});
|
|
||||||
|
|
||||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, roleId, hero, {});
|
|
||||||
heroNum ++;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
await RoleModel.incRoleInfo(role.roleId, { heroNum }, { heroNumUpdatedAt: nowSeconds() });
|
await createHeroes(roleId, heroInfos);
|
||||||
// 解锁形象
|
|
||||||
await ctx.service.utils.unlockFigure(roleId, conditions, role);
|
|
||||||
|
|
||||||
await reCalAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, {}, skinIds)
|
|
||||||
|
|
||||||
for (let { id, count } of DEFAULT_ITEMS) {
|
for (let { id, count } of DEFAULT_ITEMS) {
|
||||||
let dicGoods = gameData.goods.get(id);
|
let dicGoods = gameData.goods.get(id);
|
||||||
if (!dicGoods) continue;
|
if (!dicGoods) continue;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export default (appInfo: EggAppInfo) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
config.decodeParm = true;
|
config.decodeParm = false;
|
||||||
|
|
||||||
config.static = {
|
config.static = {
|
||||||
prefix: '/',
|
prefix: '/',
|
||||||
|
|||||||
Reference in New Issue
Block a user