diff --git a/shared/consts/consts.ts b/shared/consts/consts.ts index 00552695a..81e3ad84b 100644 --- a/shared/consts/consts.ts +++ b/shared/consts/consts.ts @@ -101,4 +101,6 @@ export const WAR_JSON_ATTRIBUTE_TYPE = { "17": "ap" // 怒气 }; -export const EVENT_QUIZ_NUM = 3; \ No newline at end of file +export const EVENT_QUIZ_NUM = 3; + +export const DEFAULT_HEROES = [19, 312, 314, 311, 309, 315]; \ No newline at end of file diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index 898dd3714..d47a51817 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -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);