Merge branch 'bugfix' of http://git.legu.cc/qixin/HJ_Server into bugfix

This commit is contained in:
ciniao 2024-01-03 14:32:40 +08:00
commit 38dca3a653
4 changed files with 81 additions and 28 deletions

View File

@ -44,6 +44,7 @@ export default async function (call: ApiCall<ReqOnekeyReceive, ResOnekeyReceive>
if (star < taskConf.needStar) return call.error(globalThis.lng.xstask_8);
change[receive._id] = { time: G.time, heros: receive.heroIds };
XstaskFun.receiveNum(call.uid)
}
Object.entries(change).forEach(([k, v]) => {

View File

@ -18,5 +18,55 @@
"key":"use_attr_rmbmoney",
"limit":100000,
"tips":"钻石消耗达到10万"
},
{
"key":"tanxian/FastGuaJi",
"limit":40,
"tips":"快速探险达到40次"
},
{
"key":"xstask/Receive/Num",
"limit":8,
"tips":"接取悬赏任务超过8个"
},
{
"key":"dixiaqianzhuang/Qf",
"limit":500,
"tips":"地下钱庄使用次数超过500次"
},
{
"key":"shop/Buy/2",
"limit":50,
"tips":"势力商店购买某一商品超过50次"
},
{
"key":"shop/Buy/1",
"limit":10,
"tips":"杂货商店购买某一商品超过10次"
},
{
"key":"peijiancangku/Jump",
"limit":500,
"tips":"指定高级仓库超过50次"
},
{
"key":"meirishilian/Fight",
"limit":30,
"tips":"物资缴获挑战和扫荡累计超过30次"
},
{
"key":"pata/SaoDang",
"limit":5,
"tips":"黑暗塔扫荡次数超过5次"
},
{
"key":"lingzhulaixi/PkBoss",
"limit":15,
"tips":"讨伐海盗挑战次数超过15次"
},
{
"key":"gonghui/FbFight",
"limit":5,
"tips":"势力战斗boss超过5次"
}
]

View File

@ -1,8 +1,8 @@
import { resolve } from "path";
import { PublicShared } from "../../shared/public/public";
import {resolve} from "path";
import {PublicShared} from "../../shared/public/public";
import {Scheduler, schedulerType} from "./scheduler";
import { existsSync, readFileSync } from "fs";
import { addWatchDogLog, errorLogDB } from "../../gameLog";
import {existsSync, readFileSync} from "fs";
import {addWatchDogLog, errorLogDB} from "../../gameLog";
export class WatchDog extends Scheduler {
id: schedulerType = "watch_dog";
@ -24,28 +24,28 @@ export class WatchDog extends Scheduler {
return;
}
let conf;
try{
try {
conf = await JSON.parse(readFileSync(confFile, 'utf-8'));
}catch(e){
} catch (e) {
//配置文件不是json
await this.ctorStartTime()
return;
}
//获取今天0点之后在线的玩家
let users = await G.mongodb.collection("user").find({
lv : {$gt:10},
newonlinetime:{$gt: PublicShared.getToDayZeroTime() }
},{
projection:{
uid:1,
name:1,
lv:1,
vip:1,
sid:1
lv: {$gt: 10},
newonlinetime: {$gte: G.time - 3600, $lte: G.time + 30}
}, {
projection: {
uid: 1,
name: 1,
lv: 1,
vip: 1,
sid: 1
}
}).toArray();
if(!users.length){
if (!users.length) {
//没有符合的玩家
await this.ctorStartTime()
return;
@ -56,25 +56,25 @@ export class WatchDog extends Scheduler {
users.map(i => uinfo[i.uid] = i);
let actionLogs = await G.mongodb.collection("actionLog").find({
type:'day',
type: 'day',
uid: {$in: uids},
},{
projection:{
uid:1,
log:1
}, {
projection: {
uid: 1,
log: 1
}
}).toArray();
let warns = [];
for(let j=0;j<conf.length;j++){
for(let i=0;i<actionLogs.length;i++){
for (let j = 0; j < conf.length; j++) {
for (let i = 0; i < actionLogs.length; i++) {
let key = conf[j].key;
let myval = actionLogs[i]?.log?.[ key ] || 0
let myval = actionLogs[i]?.log?.[key] || 0
let uid = actionLogs[i].uid
if( myval >= conf[j].limit ){
if (myval > conf[j].limit) {
//触发了警报
warns.push({
type:'watchDog',
type: 'watchDog',
uid: uid,
name: uinfo[uid]?.name,
lv: uinfo[uid]?.lv,
@ -87,10 +87,10 @@ export class WatchDog extends Scheduler {
}
}
if(warns.length>0){
if (warns.length > 0) {
addWatchDogLog(warns);
}
await this.ctorStartTime()
}

View File

@ -3,6 +3,7 @@ import {ApiCall} from 'tsrpc';
import {playerInfoType} from '../module/collection_palyerInfo';
import {CollectionXstask} from '../module/collection_xstask';
import {PublicShared} from '../shared/public/public';
import {ActionLog} from "./actionLog/actionLog";
export class XstaskFun {
@ -166,6 +167,7 @@ export class XstaskFun {
G.mongodb.cEvent('xstask').updateOne({uid: uid, type: 'xstask'},
{$set: {refreshTime: G.time, receiveNum: 0}}, {upsert: true});
} else {
ActionLog.addDayLog(uid, { key: "xstask/Receive/Num", val: 1 });
G.mongodb.cEvent('xstask').updateOne({uid: uid, type: 'xstask'},
{$inc: {receiveNum: 1}}, {upsert: true});
}