创建角色时加入默认武将
This commit is contained in:
@@ -101,4 +101,6 @@ export const WAR_JSON_ATTRIBUTE_TYPE = {
|
||||
"17": "ap" // 怒气
|
||||
};
|
||||
|
||||
export const EVENT_QUIZ_NUM = 3;
|
||||
export const EVENT_QUIZ_NUM = 3;
|
||||
|
||||
export const DEFAULT_HEROES = [19, 312, 314, 311, 309, 315];
|
||||
@@ -1,9 +1,13 @@
|
||||
import { CounterModel } from '@db/Counter';
|
||||
import { DEFAULT_HEROES } from '@consts/consts';
|
||||
import { HeroModel } from '@db/Hero';
|
||||
import { RoleModel } from '@db/Role';
|
||||
import { UserModel } from '@db/User';
|
||||
import { STATUS } from '@consts/statusCode';
|
||||
import { smsModel } from '@db/Sms';
|
||||
import { Service } from 'egg';
|
||||
import Counter from '@db/Counter';
|
||||
import { getHeroInfoById } from 'app/pubUtils/gamedata';
|
||||
const _ = require('underscore');
|
||||
|
||||
/**
|
||||
@@ -121,6 +125,28 @@ export default class Auth extends Service {
|
||||
const seqId = await Counter.getNewCounter('role') || -1;
|
||||
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId });
|
||||
if (role) {
|
||||
for (let hid of DEFAULT_HEROES) {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if(hero) {
|
||||
continue;
|
||||
}
|
||||
const seqId = await CounterModel.getNewCounter('hid')||-1;
|
||||
let dicHero = getHeroInfoById(hid);
|
||||
if(!dicHero) {
|
||||
break;
|
||||
}
|
||||
|
||||
const heroInfo = {
|
||||
roleId,
|
||||
roleName: role.roleName,
|
||||
hid: hid,
|
||||
hName: dicHero.name,
|
||||
seqId,
|
||||
lv: 1,
|
||||
ce: 100
|
||||
}
|
||||
await HeroModel.createHero(heroInfo);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId });
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
|
||||
|
||||
Reference in New Issue
Block a user