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