初始化角色时就给以下道具
This commit is contained in:
@@ -240,6 +240,16 @@ export const WAR_JSON_ATTRIBUTE_TYPE = {
|
|||||||
export const EVENT_QUIZ_NUM = 3;
|
export const EVENT_QUIZ_NUM = 3;
|
||||||
|
|
||||||
export const DEFAULT_HEROES = [ 312, 314, 311, 309, 315];
|
export const DEFAULT_HEROES = [ 312, 314, 311, 309, 315];
|
||||||
|
export const DEFAULT_ITEMS = [
|
||||||
|
{id: 33106, count: 200},
|
||||||
|
{id: 33107, count: 200},
|
||||||
|
{id: 33108, count: 200},
|
||||||
|
{id: 33109, count: 200},
|
||||||
|
{id: 33110, count: 200},
|
||||||
|
{id: 40002, count: 20000},
|
||||||
|
];
|
||||||
|
export const DEFAULT_GOLD = 20000;
|
||||||
|
export const DEFAULT_LV = 60;
|
||||||
|
|
||||||
export const FIX_SMS_CODE_TELS = ['18855953630', '13911134885', '15167549151', '15618654010', '15167549151', '15000250967','19921300694','13636354764'];
|
export const FIX_SMS_CODE_TELS = ['18855953630', '13911134885', '15167549151', '15618654010', '15167549151', '15000250967','19921300694','13636354764'];
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ export default class Role extends BaseModel {
|
|||||||
return role;
|
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);
|
const user = await User.findUserByUid(uid);
|
||||||
if (!user) return null;
|
if (!user) return null;
|
||||||
const doc = new RoleModel();
|
const doc = new RoleModel();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { FIX_SMS_CODE_TELS, COUNTER } from '@consts/consts';
|
import { FIX_SMS_CODE_TELS, COUNTER, DEFAULT_ITEMS, ITID, DEFAULT_GOLD, DEFAULT_LV } from '@consts/consts';
|
||||||
import { CounterModel } from '@db/Counter';
|
import { CounterModel } from '@db/Counter';
|
||||||
import { DEFAULT_HEROES } from '@consts/consts';
|
import { DEFAULT_HEROES } from '@consts/consts';
|
||||||
import { HeroModel } from '@db/Hero';
|
import { HeroModel } from '@db/Hero';
|
||||||
@@ -8,7 +8,8 @@ import { STATUS } from '@consts/statusCode';
|
|||||||
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, getGoodById, getExpByLv } from 'app/pubUtils/gamedata';
|
||||||
|
import { ItemModel } from '@db/Item';
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,7 +132,9 @@ export default class Auth extends Service {
|
|||||||
const roleId = ctx.service.utils.genCode(10);
|
const roleId = ctx.service.utils.genCode(10);
|
||||||
const code = ctx.service.utils.genCode(6);
|
const code = ctx.service.utils.genCode(6);
|
||||||
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
|
const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;
|
||||||
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId });
|
let lv = DEFAULT_LV;
|
||||||
|
let ge =getExpByLv(lv);
|
||||||
|
const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName, seqId, lv, exp: ge?ge.sum:0 });
|
||||||
if (role) {
|
if (role) {
|
||||||
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);
|
||||||
@@ -156,6 +159,20 @@ export default class Auth extends Service {
|
|||||||
}
|
}
|
||||||
await HeroModel.createHero(heroInfo);
|
await HeroModel.createHero(heroInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(let {id, count} of DEFAULT_ITEMS) {
|
||||||
|
let dicGood = getGoodById(id);
|
||||||
|
if(!dicGood) continue;
|
||||||
|
let dicItid = ITID.get(dicGood.itid);
|
||||||
|
if(!dicItid) continue;
|
||||||
|
let type = dicItid.type||0;
|
||||||
|
|
||||||
|
await ItemModel.increaseItem(roleId, id, count, {
|
||||||
|
roleId, roleName: role.roleName, id, itemName: dicGood.name, type
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await RoleModel.addGoldFree(roleId, DEFAULT_GOLD);
|
||||||
|
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId });
|
||||||
}
|
}
|
||||||
return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
|
return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
|
||||||
|
|||||||
Reference in New Issue
Block a user