34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
|
|
import { checkPvp, findPvpDefByRoleId } from '../services/pvpService'
|
|
import { getFuncsSwitch } from '../pubUtils/data';
|
|
import { FUNCS_ID, FUNC_OPT_TYPE } from '../consts/constModules/sysConst';
|
|
import { RoleModel } from '../db/Role';
|
|
/**
|
|
* 等级提升触发事件
|
|
* @param roleId
|
|
* @param lv
|
|
* @param addFuncs
|
|
* @param dataFuncs
|
|
*/
|
|
export async function eventOnPlayerLvUp(roleId: string, lv: number, addFuncs: Array<number>, dataFuncs: Array<number>) {
|
|
|
|
if (!dataFuncs.includes(FUNCS_ID.PVP)) {//开启pvp
|
|
let res = getFuncsSwitch(FUNCS_ID.PVP);
|
|
if (!res || lv >= res.param) {
|
|
let role = await RoleModel.findByRoleId(roleId, null, true);
|
|
await checkPvp(role);
|
|
addFuncs.push(FUNCS_ID.PVP);
|
|
}
|
|
}
|
|
|
|
if (!dataFuncs.includes(FUNCS_ID.EVENT)) {//开启奇遇
|
|
let res = getFuncsSwitch(FUNCS_ID.EVENT);
|
|
if (res && lv >= res.param) {
|
|
addFuncs.push(FUNCS_ID.EVENT);
|
|
}
|
|
}
|
|
}
|
|
|
|
export async function loginRefresh(roleId: string) {
|
|
await findPvpDefByRoleId(roleId);
|
|
} |