pvp创建获取

This commit is contained in:
mamengke01
2021-01-06 16:06:31 +08:00
parent d2f76c9198
commit a785a4733a
17 changed files with 189 additions and 71 deletions
@@ -1,6 +1,13 @@
import {Application, BackendSession} from 'pinus';
const _ = require('underscore');
import { gameData } from '../../../pubUtils/data';
import { checkPvp } from '../../../pubUtils/pvpUtil';
import { RoleModel } from '../../../db/Role';
import { STATUS } from '../../../consts/statusCode';
import { resResult } from '../../../pubUtils/util';
import { SystemConfigModel } from '../../../db/SystemConfig'
import { PvpDefenseModel } from '../../../db/PvpDefense';
export default function(app: Application) {
return new PvpHandler(app);
}
@@ -9,5 +16,14 @@ export class PvpHandler {
constructor(private app: Application) {
}
async getData (msg: {}, session: BackendSession) {
let roleId = session.get('roleId');
let roleName = session.get('roleName');
let sid = session.get('sid');
let serverId = session.get('serverId');
let result = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
let system = await SystemConfigModel.findSystemConfig();
return resResult(STATUS.SUCCESS, { data: result });
}
}
@@ -10,8 +10,8 @@ import { resResult, returnHeroCeRatio, reduceCe } from '../../../pubUtils/util';
import { FUNC_OPT_TYPE } from '../../../consts';
import { getAp } from '../../../services/actionPointService';
import { ItemModel } from '../../../db/Item';
import { switchOnFunc } from '../../../services/funcSwitchService';
import { chackFunOpenWhenLogin } from '../../../services/funcSwitchService';
import { eventOnPlayerLvUp } from '../../../services/playerEventService';
export default function (app: Application) {
return new EntryHandler(app);
}
@@ -78,7 +78,7 @@ export class EntryHandler {
let equips = await EquipModel.findbyRole(role.roleId);
let items = await ItemModel.findbyRole(role.roleId);
await chackFunOpenWhenLogin(role, session.get('funcs'));
role['heros'] = heros.map(cur => returnHeroCeRatio(cur));
role['equips'] = equips;
role['consumeGoods'] = items;
@@ -86,7 +86,6 @@ export class EntryHandler {
role['apJson'] = apJson;
role['ce'] = reduceCe(role.ce);
await switchOnFunc(role.roleId, FUNC_OPT_TYPE.LEVEL_UP, role.lv, session);
return resResult(STATUS.SUCCESS, { role });
}
+20 -17
View File
@@ -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() {
}
+3
View File
@@ -16,5 +16,8 @@ module.exports = [{
}, {
'type': 'role',
'token': 'agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn'
}, {
'type': 'systimer',
'token': 'agarxhqb98rpajloaxn34ga8xrunpagkjwlaw3ruxnpaagl29w4rxn'
}
];
+29 -17
View File
@@ -12,16 +12,16 @@ module.exports = {
}
],
'chat': [
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050}
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050, "args": " --inspect=9237"}
],
'role': [
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053}
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053, "args": " --inspect=9229"}
],
'battle': [
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054}
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054, "args": " --inspect=9238"}
],
'gm': [
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055,"args": " --inspect=9234"}
],
'gate': [
{
@@ -29,14 +29,16 @@ module.exports = {
'host': '127.0.0.1',
'clientHost': '127.0.0.1',
'clientPort': 3014,
'frontend': true
'frontend': true,
"args": " --inspect=9235"
},
{
'id': 'gate-server-2',
'host': '127.0.0.1',
'clientHost': '127.0.0.1',
'clientPort': 3015,
'frontend': true
'frontend': true,
"args": " --inspect=9236"
}
]
},
@@ -69,6 +71,9 @@ module.exports = {
],
'gm': [
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
],
'systimer': [
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056}
]
},
'alpha': {
@@ -100,37 +105,44 @@ module.exports = {
],
'gm': [
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
],
'systimer': [
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056}
]
},
'dev': {
'connector': [
{'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true},
{'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true},
{'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true}
{'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true, "args": " --inspect=9237"},
{'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true, "args": " --inspect=9229"},
{'id': 'connector-server-3', 'port': 4052, 'clientHost': 'zyzdev.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true, "args": " --inspect=9238"}
],
'chat': [
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050},
{'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051},
{'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052}
{'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050,"args": " --inspect=9234"},
{'id': 'chat-server-2', 'host': '127.0.0.1', 'port': 6051,"args": " --inspect=9235"},
{'id': 'chat-server-3', 'host': '127.0.0.1', 'port': 6052,"args": " --inspect=9236"}
],
'role': [
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053}
{'id': 'role-server-1', 'host': '127.0.0.1', 'port': 6053,"args": " --inspect=9231"}
],
'battle': [
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054}
{'id': 'battle-server-1', 'host': '127.0.0.1', 'port': 6054,"args": " --inspect=9230"}
],
'gate': [
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyzdev.trgame.cn', 'clientPort': 3014, 'frontend': true},
{'id': 'gate-server-1', 'host': '127.0.0.1', 'clientHost': 'zyzdev.trgame.cn', 'clientPort': 3014, 'frontend': true,"args": " --inspect=9227"},
{
'id': 'gate-server-2',
'host': '127.0.0.1',
'clientHost': 'zyzdev.trgame.cn',
'clientPort': 3015,
'frontend': true
'frontend': true,
"args": " --inspect=9228"
}
],
'gm': [
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055}
{'id': 'gm-server-1', 'host': '127.0.0.1', 'port': 6055,"args": " --inspect=9232"}
],
'systimer': [
{'id': 'systimer-server-1', 'host': '127.0.0.1', 'port': 6056, "args": " --inspect=9233"}
]
}
};