pvp创建获取
This commit is contained in:
@@ -2,32 +2,35 @@ import { BackendSession, FrontendSession, pinus } from "pinus";
|
||||
import { getGamedata } from "../pubUtils/gamedata";
|
||||
import { RoleModel } from "../db/Role";
|
||||
import { resResult } from "../pubUtils/util";
|
||||
import { STATUS } from "../consts";
|
||||
|
||||
import { STATUS, FUNC_OPT_TYPE } from "../consts";
|
||||
import { eventOnPlayerLvUp } from '../services/playerEventService';
|
||||
// 开启功能
|
||||
export async function switchOnFunc(roleId: string, type: number, param: number, session: (BackendSession|FrontendSession)) {
|
||||
|
||||
const dataFuncs = session.get('funcs');
|
||||
const sid = session.get('sid');
|
||||
const dicFuncSwitch = getGamedata('dic_func_switch');
|
||||
|
||||
let funcs = new Array<{id: number, desc: string, script: string}>(), addFuncs = new Array<number>();
|
||||
for(let obj of dicFuncSwitch) {
|
||||
if(obj.conditionType == type && !dataFuncs.includes(obj.id) && obj.param <= param) {
|
||||
funcs.push({id: obj.id, desc: obj.desc, script: obj.script});
|
||||
addFuncs.push(obj.id);
|
||||
}
|
||||
let addFuncs = new Array<number>();
|
||||
switch (type) {
|
||||
case FUNC_OPT_TYPE.LEVEL_UP:
|
||||
await eventOnPlayerLvUp(roleId, param, addFuncs, dataFuncs);
|
||||
break;
|
||||
case FUNC_OPT_TYPE.BATTLE_END:
|
||||
//开启奇遇
|
||||
break;
|
||||
}
|
||||
|
||||
if(funcs.length > 0) {
|
||||
|
||||
pinus.app.get('channelService').pushMessageByUids('onFuncSwitchOn', resResult(STATUS.SUCCESS, {funcs}), [{
|
||||
if (addFuncs.length) {
|
||||
pinus.app.get('channelService').pushMessageByUids('onFuncSwitchOn', resResult(STATUS.SUCCESS, {addFuncs}), [{
|
||||
uid: roleId,
|
||||
sid: sid
|
||||
}]);
|
||||
const recs = await RoleModel.pushFuncs(roleId, addFuncs);
|
||||
session.set('funcs', recs.funcs||[]);
|
||||
session.push('funcs', () => {});
|
||||
return recs;
|
||||
}
|
||||
const recs = await RoleModel.pushFuncs(roleId, addFuncs);
|
||||
session.set('funcs', recs.funcs||[]);
|
||||
session.push('funcs', () => {});
|
||||
return recs
|
||||
}
|
||||
|
||||
export async function chackFunOpenWhenLogin(role: any, dataFuncs:Array<number>) {
|
||||
await eventOnPlayerLvUp(role.roleId, role.lv, [], dataFuncs);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 体力系统
|
||||
*/
|
||||
import { fromCallback } from 'bluebird';
|
||||
import { checkPvp } from '../pubUtils/pvpUtil'
|
||||
import { getFuncsSwitch } from '../pubUtils/data';
|
||||
import { FUNCS_ID, FUNC_OPT_TYPE } from '../consts/constModules/sysConst';
|
||||
import { RoleModel } from '../db/Role'
|
||||
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);
|
||||
await checkPvp(role);
|
||||
addFuncs.push(FUNCS_ID.PVP);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 体力系统
|
||||
*/
|
||||
|
||||
import { scheduleJob, cancelJob } from 'pinus-scheduler';
|
||||
|
||||
export async function init() {
|
||||
scheduleJob("0 31 23 * * *", setPvpSeasonResult, {name:'setPvpSeasonResult'})
|
||||
}
|
||||
|
||||
export async function setPvpSeasonResult() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user