后台,初始账号时武将lv和exp匹配
This commit is contained in:
@@ -25,6 +25,7 @@ import { STATUS } from '@consts/statusCode';
|
||||
import { ITID, COUNTER } from '@consts/consts';
|
||||
import Actor from '@pubUtils/actor';
|
||||
import { ItemModel } from '@db/Item';
|
||||
import { getHeroExpByLv } from '@pubUtils/gamedata';
|
||||
|
||||
/**
|
||||
* Test Service
|
||||
@@ -187,6 +188,7 @@ export default class GMUsers extends Service {
|
||||
if(isNaN(hid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
|
||||
let exp = getHeroExpByLv(hlv);
|
||||
let heroInfos = new Array();
|
||||
for(let roleId of uids) {
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
@@ -199,7 +201,7 @@ export default class GMUsers extends Service {
|
||||
let {quality, initialStars: star, jobid: job, name: hName} = dicHero;
|
||||
const heroInfo = {
|
||||
roleId, roleName: role.roleName, hid, hName, star, quality, job, serverId: role.serverId,
|
||||
lv: hlv
|
||||
lv: hlv, exp
|
||||
}
|
||||
heroInfos.push(heroInfo);
|
||||
}
|
||||
|
||||
@@ -229,6 +229,7 @@ export const EXPEDITION_CONST = {
|
||||
export const EVENT_QUIZ_NUM = 3;
|
||||
|
||||
export const DEFAULT_HEROES = [ 12, 14, 11, 9, 15];
|
||||
export const DEFAULT_HEROES_LV = 30;
|
||||
export const DEFAULT_ITEMS = [
|
||||
{id: 33106, count: 200},
|
||||
{id: 33107, count: 200},
|
||||
@@ -334,4 +335,8 @@ export const HERO_GROW_MAX = {
|
||||
export const JOB_TYPE = {
|
||||
PHYSIC: 1,
|
||||
MAGIC: 2
|
||||
}
|
||||
|
||||
export const FILENAME = {
|
||||
DIC_HERO: 'dic_zyz_hero'
|
||||
}
|
||||
@@ -123,7 +123,7 @@ export default class Hero extends BaseModel {
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async createHero(heroInfo: {roleId: string, serverId: number, roleName: string, hid: number, hName: string, star: number, quality: number, job: number, lv?: number }, lean = true) {
|
||||
public static async createHero(heroInfo: {roleId: string, serverId: number, roleName: string, hid: number, hName: string, star: number, quality: number, job: number, lv?: number, exp?:number }, lean = true) {
|
||||
const doc = new HeroModel();
|
||||
const seqId = await CounterModel.getNewCounter(COUNTER.HID)||-1;
|
||||
const update = Object.assign(doc.toJSON(), heroInfo, {seqId});
|
||||
|
||||
@@ -171,7 +171,7 @@ export default class Role extends BaseModel {
|
||||
return role;
|
||||
}
|
||||
|
||||
public static async createRole(uid: number, serverId: number, roleInfo: {roleId: string; roleName: string; seqId: number; code: string}, lean = true) {
|
||||
public static async createRole(uid: number, serverId: number, roleInfo: {roleId: string; roleName: string; seqId: number; code: string, lv?:number, exp?:number}, lean = true) {
|
||||
const user = await User.findUserByUid(uid);
|
||||
if (!user) return null;
|
||||
const doc = new RoleModel();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FIX_SMS_CODE_TELS, COUNTER, DEFAULT_ITEMS, ITID, DEFAULT_GOLD, DEFAULT_LV } from '@consts/consts';
|
||||
import { FIX_SMS_CODE_TELS, COUNTER, DEFAULT_ITEMS, ITID, DEFAULT_GOLD, DEFAULT_LV, DEFAULT_HEROES_LV } from '@consts/consts';
|
||||
import { DEFAULT_HEROES } from '@consts/consts';
|
||||
import { HeroModel } from '@db/Hero';
|
||||
import { RoleModel } from '@db/Role';
|
||||
@@ -7,7 +7,7 @@ import { STATUS } from '@consts/statusCode';
|
||||
import { smsModel } from '@db/Sms';
|
||||
import { Service } from 'egg';
|
||||
import Counter from '@db/Counter';
|
||||
import { getHeroInfoById, getGoodById, getExpByLv } from 'app/pubUtils/gamedata';
|
||||
import { getHeroInfoById, getGoodById, getExpByLv, getHeroExpByLv } from 'app/pubUtils/gamedata';
|
||||
import { ItemModel } from '@db/Item';
|
||||
const _ = require('underscore');
|
||||
|
||||
@@ -132,7 +132,7 @@ export default class Auth extends Service {
|
||||
const code = ctx.service.utils.genCode(6);
|
||||
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
|
||||
let lv = DEFAULT_LV;
|
||||
let ge =getExpByLv(lv);
|
||||
let ge = getExpByLv(lv);
|
||||
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId, lv, exp: ge?ge.sum:0 });
|
||||
if (role) {
|
||||
for (let hid of DEFAULT_HEROES) {
|
||||
@@ -146,9 +146,10 @@ export default class Auth extends Service {
|
||||
break;
|
||||
}
|
||||
let {quality, initialStars: star, jobid: job, name: hName} = dicHero;
|
||||
|
||||
let lv = DEFAULT_HEROES_LV;
|
||||
let exp = getHeroExpByLv(lv);
|
||||
hero = await HeroModel.createHero({
|
||||
roleId, roleName: role.roleName, hid, hName, star, quality, job, serverId: role.serverId
|
||||
roleId, roleName: role.roleName, hid, hName, star, quality, job, serverId: role.serverId, lv, exp
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user