Merge branch 'bugfix' into dev
This commit is contained in:
commit
dd60fe3bab
@ -59,7 +59,7 @@ let enemyObject: object = {}
|
||||
async function checkAndRefreshEnemy() {
|
||||
if (lastRefreshTime + 3600 > G.time) return
|
||||
lastRefreshTime = G.time
|
||||
for (let i = 3; i <= 8; i ++) {
|
||||
for (let i = 3; i <= 8; i++) {
|
||||
let users = await G.mongodb.collection('user').aggregate([
|
||||
{
|
||||
$match: {
|
||||
@ -85,7 +85,9 @@ async function checkAndRefreshEnemy() {
|
||||
export async function refreshEnemys(call: ApiCall) {
|
||||
if (!lastRefreshTime) await checkAndRefreshEnemy()
|
||||
|
||||
let dbUser = enemyObject[Math.floor(call.conn.gud.lv / 10)]
|
||||
let lvDw = Math.floor(call.conn.gud.lv / 10 > 8 ? 8 : call.conn.gud.lv / 10)
|
||||
|
||||
let dbUser = enemyObject[lvDw] || []
|
||||
|
||||
let enemys: joinFightData[] = [];
|
||||
|
||||
|
@ -2,13 +2,14 @@ import {RedisClientType, createClient} from "redis";
|
||||
import {redisClient} from "./setRedis";
|
||||
import {ConnectionStatus, WsServer} from "tsrpc";
|
||||
import cluster from 'cluster';
|
||||
import { clusterFun } from "./clusterFunction";
|
||||
import {clusterFun} from "./clusterFunction";
|
||||
|
||||
//维护当前uid和pid的对应关系
|
||||
let uid2processId = {};
|
||||
//订阅redis
|
||||
let subscribeRedis: RedisClientType
|
||||
let firstPid = null;
|
||||
|
||||
//发布和可写redis复用原 setRedis 里的redisClient
|
||||
|
||||
|
||||
@ -20,10 +21,10 @@ let firstPid = null;
|
||||
*/
|
||||
export function clusterSubscribe(key: string, callback: Function) {
|
||||
subscribeRedis.subscribe(G.redis.fromatKey(key), function (msg) {
|
||||
try{
|
||||
try {
|
||||
callback(msg);
|
||||
}catch(e){
|
||||
console.error("clusterSubscribe error",e);
|
||||
} catch (e) {
|
||||
console.error("clusterSubscribe error", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -43,14 +44,19 @@ export function clusterPublish(key: string, data: any) {
|
||||
* 在集群的N个进程中,只运行一次,在业务逻辑中也可使用
|
||||
*/
|
||||
export function clusterRunOnce(fun) {
|
||||
console.log(`${process.pid}环境变量pm_id===>${process.env.pm_id}`);
|
||||
if (process.env.pm_id == null || process.env.pm_id === '0') {
|
||||
//非pm2启动的,或是pm2下启动的第一个进程
|
||||
console.log("run clusterRunOnce1 ===>", process.pid)
|
||||
fun();
|
||||
return;
|
||||
}
|
||||
|
||||
if(firstPid == process.pid){
|
||||
if(G.config.isG123)return;
|
||||
|
||||
if (firstPid == process.pid) {
|
||||
//pm2的其中一个进程
|
||||
console.log("run clusterRunOnce2 ===>", process.pid)
|
||||
fun();
|
||||
return;
|
||||
}
|
||||
@ -60,16 +66,16 @@ export function clusterRunOnce(fun) {
|
||||
* 对外方法:
|
||||
* 在uid所在的进程执行fun方法,如果uid不在任何进程的话,则在当前进程执行
|
||||
*/
|
||||
export function clusterFunctionRunAtUidProcess(uid:string, fun:string, ...arg:any[]) {
|
||||
if(!uid2processId[uid] || uid2processId[uid] == process.pid){
|
||||
clusterFun[ fun ].call(this, ...arg);
|
||||
export function clusterFunctionRunAtUidProcess(uid: string, fun: string, ...arg: any[]) {
|
||||
if (!uid2processId[uid] || uid2processId[uid] == process.pid) {
|
||||
clusterFun[fun].call(this, ...arg);
|
||||
return;
|
||||
}
|
||||
|
||||
clusterPublish("RunclusterFunction", JSON.stringify({
|
||||
"uid": uid,
|
||||
"fun": fun,
|
||||
"arg" : arg
|
||||
"arg": arg
|
||||
}))
|
||||
}
|
||||
|
||||
@ -159,17 +165,17 @@ async function initSubscribeRedis() {
|
||||
clusterSubscribe('broadcastClusterMsg', function (msg) {
|
||||
let data = JSON.parse(msg);
|
||||
|
||||
if(!data.filter){
|
||||
if (!data.filter) {
|
||||
//如果不是有条件发送的话
|
||||
G.server.broadcastMsg(data.msgName, data.msg);
|
||||
}else {
|
||||
} else {
|
||||
//但是如果是有条件发送的话
|
||||
//条件里可能需要进程内的信息,则需要每个进程都分别筛选后执行
|
||||
if (data.filter.ghId != null) {
|
||||
//指定公会
|
||||
let conns = G.server.connections;
|
||||
conns = conns.filter(c => c?.gud?.ghId == data.filter.ghId);
|
||||
conns.length>0 && G.server.broadcastMsg(data.msgName, data.msg, conns);
|
||||
conns.length > 0 && G.server.broadcastMsg(data.msgName, data.msg, conns);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -178,7 +184,7 @@ async function initSubscribeRedis() {
|
||||
clusterSubscribe('RunclusterFunction', function (msg) {
|
||||
let data = JSON.parse(msg);
|
||||
if (uid2processId[data.uid] == process.pid) {
|
||||
clusterFun[ data.fun ].call(this, ...data.arg);
|
||||
clusterFun[data.fun].call(this, ...data.arg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -194,7 +200,7 @@ export async function clusterMain() {
|
||||
//初始化订阅redis
|
||||
await initSubscribeRedis();
|
||||
|
||||
if(process.env.pm_id != null){
|
||||
if (process.env.pm_id != null) {
|
||||
//pm2启动的,设置key为我的pid
|
||||
firstPid = await redisClient.get(G.redis.fromatKey("firstPid"));
|
||||
if (!firstPid) {
|
||||
|
@ -788,7 +788,7 @@ export class TaskAllEmitFun {
|
||||
let _val = node.call.req.num;
|
||||
G.emit("Class_task_136", 'Class_task_136', node.call, _val, 0);
|
||||
// todo 统计藏品修复胶,此处只是临时处理,防止线上任务数据出错,正确做法是,统计修复胶的消耗,走136任务的统计
|
||||
G.emit("Class_task_134", 'Class_task_134', node.call, _val, 0, {});
|
||||
G.emit("Class_task_134", 'Class_task_134', node.call, _val, 0, []);
|
||||
}
|
||||
|
||||
if (node.call.service.name == 'peijian/LvUp' && node.return.isSucc) {
|
||||
|
@ -390,7 +390,10 @@ export module manager {
|
||||
|
||||
async initVal(call: ApiCall, con) {
|
||||
const data = await TanXianFun.getData(call);
|
||||
return data.useFastGuaJiNum || 0
|
||||
if (data?.resetTime > PublicShared.getToDayZeroTime()) {
|
||||
return data.useFastGuaJiNum || 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,7 +404,10 @@ export module manager {
|
||||
|
||||
async initVal(call: ApiCall, con) {
|
||||
let data = await JJCFun.getData(call);
|
||||
return data?.useFightNum || 0
|
||||
if (data?.resetTime >= PublicShared.getToDayZeroTime()) {
|
||||
return data?.useFightNum || 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +424,10 @@ export module manager {
|
||||
|
||||
async initVal(call: ApiCall, con) {
|
||||
let myData = await G.mongodb.cPlayerInfo('meirishilian').findOne({uid: call.uid, type: 'meirishilian'});
|
||||
return R.compose(R.sum(), R.map(i => i[0].useFightNum), R.values())(myData.data.numInfo) || 0
|
||||
if (myData.data.refreshTime > PublicShared.getToDayZeroTime()) {
|
||||
return R.compose(R.sum(), R.map(i => i[0].useFightNum), R.values())(myData.data.numInfo) || 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -435,7 +444,10 @@ export module manager {
|
||||
|
||||
async initVal(call: ApiCall, con) {
|
||||
let myData = await G.mongodb.cPlayerInfo('qjzzd').findOne({uid: call.uid, type: 'qjzzd'});
|
||||
return myData.useFightNum || 0
|
||||
if (myData?.refreFightTime > PublicShared.getToDayZeroTime()) {
|
||||
return myData?.useFightNum || 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,7 +503,10 @@ export module manager {
|
||||
|
||||
async initVal(call: ApiCall, con) {
|
||||
let data: Partial<CollectionWanted> = await G.mongodb.collection('wanted').findOne({uid: call.uid}) || {};
|
||||
return data.toDayUseNum || 0
|
||||
if (data.refreshTime > PublicShared.getToDayZeroTime()) {
|
||||
return data.toDayUseNum || 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -766,6 +781,7 @@ export module manager {
|
||||
return call.conn.gud?.helpHeros?.length || 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 第56个任务 完成圣诞活动小游戏
|
||||
export class Class_task_154 extends BaseClass {
|
||||
stype = 154
|
||||
@ -775,6 +791,7 @@ export module manager {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// 第57个任务 领取每日任务最终宝箱
|
||||
export class Class_task_155 extends BaseClass {
|
||||
stype = 155
|
||||
|
@ -182,6 +182,18 @@ export function getBuffDPS(toRole: FightObj, fromRole: FightObj, extData: { xiao
|
||||
// todo 主角技能还没有限制百分比的最大伤害,以下判断修复技能buff没有伤害
|
||||
if (fromRole.getData('pos') != 7){
|
||||
dps = dps > maxDps ? maxDps : dps;
|
||||
} else {
|
||||
// 主角技能伤害最大值: avg(所有上场干部的maxDps) * 2
|
||||
let sumHeroMaxDps = 0, heroCount = 0;
|
||||
const fromRoleSide = fromRole.getData('side');
|
||||
fromRole.fightControl.fightRolesArr.forEach(role => {
|
||||
if (role.getData('pos') < 7 && role.getData('side') === fromRoleSide) {
|
||||
sumHeroMaxDps += role.getData('maxdps');
|
||||
heroCount++;
|
||||
}
|
||||
});
|
||||
maxDps = sumHeroMaxDps / heroCount * 2;
|
||||
dps = dps > maxDps ? maxDps : dps;
|
||||
}
|
||||
|
||||
return { num: -dps, dps: -dps, miss: miss, baoji: baoji, fromRole: fromRole, toRole: toRole };
|
||||
|
Loading…
Reference in New Issue
Block a user