满足条件开启功能推送,详细功能校验暂缺

This commit is contained in:
luying
2020-11-26 19:29:28 +08:00
parent f2e288f25d
commit 1f05043b4b
14 changed files with 158 additions and 44 deletions
@@ -3,8 +3,11 @@ import { HeroModel } from '../db/Hero';
import Role, { RoleModel } from '../db/Role'
import { getLvByExp, getExpByLv } from '../pubUtils/gamedata';
import { redisUserInfoUpdate } from './redisService';
import { switchOnFunc } from './funcSwitchService';
import { FUNC_OPT_TYPE } from '../consts/consts';
import { Application, BackendSession } from 'pinus';
export async function roleLevelup(roleId: string, kingExp: number) {
export async function roleLevelup(roleId: string, kingExp: number, app: Application, session: BackendSession) {
let role = await RoleModel.findByRoleId(roleId);
let {lv = 1, exp = 0} = role;
let newExp = exp + kingExp;
@@ -15,8 +18,9 @@ export async function roleLevelup(roleId: string, kingExp: number) {
newExp = curExpObj.sum;
}
await RoleModel.levelup(roleId, newLv, newExp);
role = await RoleModel.levelup(roleId, newLv, newExp);
if(newLv > lv) { // 升级
await switchOnFunc(roleId, FUNC_OPT_TYPE.LEVEL_UP, newLv, app, session);
await redisUserInfoUpdate(roleId, [{field: 'lv', value: newLv}])
}
let actordata = [];