Compare commits
19 Commits
08c59b522b
...
d3f272f1e4
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d3f272f1e4 | ||
![]() |
89ea1a47af | ||
![]() |
8d9ecf30b6 | ||
![]() |
ec85961633 | ||
d490550abf | |||
38dca3a653 | |||
7e589e23b3 | |||
![]() |
22b577036f | ||
6e9d65241e | |||
43aeef2501 | |||
![]() |
1a9f942297 | ||
![]() |
8f0c24bc87 | ||
![]() |
1fcedaff59 | ||
![]() |
a1c7f2e4d0 | ||
78c306ce5e | |||
ad15cf73bf | |||
3c380f1e55 | |||
![]() |
953303d9a4 | ||
![]() |
d2ddc62752 |
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"ms-ceintl.vscode-language-pack-zh-hans"
|
||||
]
|
||||
}
|
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"editor.suggest.snippetsPreventQuickSuggestions": false,
|
||||
"aiXcoder.showTrayIcon": true
|
||||
}
|
@ -32,7 +32,7 @@ export default async function (call: ApiCall<Reqdetails, Resdetails>) {
|
||||
let _tmp = {
|
||||
ranking: index,
|
||||
participantId: elementUser.uid,
|
||||
value: await (await PayFun.getPayDaysAllPayNum(elementUser.uid, element.stime, element.rtime)).toString()
|
||||
value: await (await PayFun.getPayDaysAllPayNum(elementUser.uid, element.stime, element.etime)).toString()
|
||||
}
|
||||
accountingData.push(_tmp)
|
||||
}
|
||||
|
@ -23,10 +23,10 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
{upsert: true}
|
||||
);
|
||||
}
|
||||
db = await checkNextRound(call, db, _hdinfo.data.tasks)
|
||||
db = await checkNextRound(call, db, _hdinfo)
|
||||
|
||||
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10
|
||||
payNum = payNum - (db.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total
|
||||
payNum = payNum - (db?.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total
|
||||
|
||||
call.succ({
|
||||
sTime: sTime,
|
||||
|
@ -20,7 +20,7 @@ export default async function (call: ApiCall<ReqRec, ResRec>) {
|
||||
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
||||
if (db.recIndex.includes(call.req.index)) return call.error('', {code: -2});
|
||||
|
||||
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10;
|
||||
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.etime)) * 10;
|
||||
payNum = payNum - (db.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total
|
||||
if (payNum < conf.total) return call.error('', {code: -3});
|
||||
|
||||
@ -31,7 +31,7 @@ export default async function (call: ApiCall<ReqRec, ResRec>) {
|
||||
{$push: {recIndex: call.req.index}}
|
||||
);
|
||||
|
||||
await checkNextRound(call, db, _hdinfo.data.tasks)
|
||||
await checkNextRound(call, db, _hdinfo)
|
||||
|
||||
HongDianChange.sendChangeKey(call.uid, ['huodonghd'])
|
||||
call.succ({
|
||||
@ -39,9 +39,13 @@ export default async function (call: ApiCall<ReqRec, ResRec>) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function checkNextRound(call: ApiCall, event, tasks) {
|
||||
export async function checkNextRound(call: ApiCall, event, _hdinfo) {
|
||||
if ((event?.recIndex?.length || 0) < _hdinfo.data.tasks.length) return event
|
||||
let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.etime)) * 10
|
||||
payNum = payNum - (event?.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total
|
||||
if (payNum < 0) return event
|
||||
|
||||
let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}`
|
||||
if ((event?.recIndex?.length || 0) < tasks.length) return event
|
||||
return (await G.mongodb.cEvent(_dbType).findOneAndUpdate(
|
||||
{uid: call.uid, type: _dbType},
|
||||
{$set: {recIndex: []}, $inc: {round: 1}}, {returnDocument: 'after'}
|
||||
|
@ -656,7 +656,7 @@ export class HuoDongHongDianFun {
|
||||
let _con = hdCon.data.tasks;
|
||||
let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType});
|
||||
let _mydata = db || {sTime: PublicShared.getToDayZeroTime(G.time), recIndex: []};
|
||||
let payNum = await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.rtime);
|
||||
let payNum = await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.etime);
|
||||
for (let index = 0; index < _con.length; index++) {
|
||||
const element = _con[index];
|
||||
if (_mydata.recIndex.includes(index)) continue;
|
||||
|
@ -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]) => {
|
||||
|
@ -256,7 +256,7 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection<Ser
|
||||
this.sendMsg('msg_s2c/PlayerChange', dbUpdate);
|
||||
|
||||
let rankKfjs = RankKfjs(7)
|
||||
rankKfjs.setDataAndCheck({
|
||||
rankKfjs?.setDataAndCheck({
|
||||
player: this.gud,
|
||||
valArr: [power]
|
||||
});
|
||||
@ -338,7 +338,7 @@ ApiCall.prototype.addEventMsg = function (this: ApiCall) {
|
||||
if (Object.keys(this.otherBuff).intersection(Object.keys(msg)).length > 0) this.conn.refreshPower();
|
||||
break;
|
||||
case 'msg_s2c/LshdChange':
|
||||
this.conn.lshd[msgKey] && PublicShared.mergeProperty(this.conn.lshd[msgKey], msg);
|
||||
this.conn?.lshd?.[msgKey] && PublicShared.mergeProperty(this.conn.lshd[msgKey], msg);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Db, MongoClient } from "mongodb";
|
||||
import { Logger } from "tsrpc";
|
||||
|
||||
let logDB:Db;
|
||||
let errorLogDB:Db;
|
||||
export let logDB:Db;
|
||||
export let errorLogDB:Db;
|
||||
|
||||
/**
|
||||
* 是否是G123的测试服
|
||||
@ -11,7 +11,7 @@ function isG123stg(){
|
||||
return G.config.mongodbUrl.indexOf('.stg.')!=-1;
|
||||
}
|
||||
|
||||
async function connGameLogDB() {
|
||||
export async function connGameLogDB() {
|
||||
console.log('connect gamelog mongodb ......');
|
||||
let logDBUrl:string;
|
||||
if(G.config.isG123){
|
||||
@ -73,6 +73,28 @@ async function addErrorLog(errData:any){
|
||||
}
|
||||
}
|
||||
|
||||
export async function addWatchDogLog(data:object[]){
|
||||
try{
|
||||
//g123测试版连接不上db,不抓取
|
||||
if(!data)return;
|
||||
if(isG123stg())return;
|
||||
let log = {
|
||||
serverId : G.config.serverId,
|
||||
pid : process.pid,
|
||||
cTime : Math.floor(Date.now()/1000)
|
||||
}
|
||||
data.map(item=>{
|
||||
Object.assign(item,log)
|
||||
})
|
||||
if(!errorLogDB){
|
||||
await connGameLogDB();
|
||||
}
|
||||
errorLogDB.collection('nodeJsErrorLog').insertMany(data);
|
||||
}catch(e){
|
||||
console.error('addWatchDogLog',e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加游戏日志
|
||||
* @param uid 玩家uid
|
||||
|
@ -7,17 +7,17 @@ export default {
|
||||
/**消息服socket端口*/
|
||||
msgPort: 7778,
|
||||
/**http端口 msg服专用*/
|
||||
// httpPort: 7779,
|
||||
httpPort: 7779,
|
||||
/**跨服socket端口 */
|
||||
crossPort: 7780,
|
||||
/**跨服 ws url */
|
||||
corssWsUrl: "ws://10.0.1.20:10003",
|
||||
corssWsUrl: "ws://localhost:7780",
|
||||
/**服务器id */
|
||||
serverId: 1001,
|
||||
serverId: 15,
|
||||
/**redis url */
|
||||
redisUrl: 'redis://:lyMaple525458@10.0.1.20:6379/0',
|
||||
/**mongodb url */
|
||||
mongodbUrl: 'mongodb://root:lyMaple525458@10.0.1.20:27017/heijiao?authSource=admin',
|
||||
mongodbUrl: 'mongodb://root:lyMaple525458@10.0.1.20:27017/heijiao_cl?authSource=admin',
|
||||
/**cross redis url */
|
||||
crossRedisUrl: 'redis://:lyMaple525458@10.0.1.20:6379/1',
|
||||
/**cross mongodb url */
|
||||
@ -27,11 +27,13 @@ export default {
|
||||
/**服务器时间 */
|
||||
time: '',
|
||||
/**开服时间 */
|
||||
openTime: '2023-12-11 1:0:0',
|
||||
openTime: '2023-12-05 01:00:00',
|
||||
/**项目名称 */
|
||||
projectName: 'heijiao',
|
||||
/**加密key */
|
||||
APIKEY: 'uutown123456',
|
||||
/**是否已经开区 */
|
||||
opened:true,
|
||||
/**wss */
|
||||
wss: {
|
||||
key: '',
|
||||
|
72
src/oss/watchdog.json
Normal file
72
src/oss/watchdog.json
Normal file
@ -0,0 +1,72 @@
|
||||
[
|
||||
{
|
||||
"key":"jiuba/Lottery",
|
||||
"limit":300,
|
||||
"tips":"酒馆抽取次数达到300次"
|
||||
},
|
||||
{
|
||||
"key":"got_jinbi",
|
||||
"limit":200000000,
|
||||
"tips":"jinbi获取达到20亿"
|
||||
},
|
||||
{
|
||||
"key":"got_rmbmoney",
|
||||
"limit":30000,
|
||||
"tips":"钻石获取达到3万"
|
||||
},
|
||||
{
|
||||
"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次"
|
||||
}
|
||||
]
|
@ -18,6 +18,7 @@ import {getItemByItemId, getItemNum} from './item';
|
||||
import {getGud, setGud} from './gud';
|
||||
import {addGameLog} from "../gameLog";
|
||||
import {PushGiftFun} from "./pushgift";
|
||||
import { ActionLog } from './actionLog/actionLog';
|
||||
|
||||
|
||||
export type call = {
|
||||
@ -178,6 +179,12 @@ export class PlayerFun {
|
||||
G.emit("Class_task_156", 'Class_task_156', call, -atn.n, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if( (atn.t == 'rmbmoney' || atn.t == 'jinbi') && atn.n > 0 ){
|
||||
//统计今日获取的金币和钻石
|
||||
ActionLog.addDayLog(call.conn.uid, { key: 'got_'+atn.t, val: atn.n });
|
||||
}
|
||||
|
||||
// 增加vip经验的任务监听
|
||||
if (atn.t == "payExp" && atn.n > 0) {
|
||||
G.emit("Class_task_157", 'Class_task_157', call, atn.n, 0);
|
||||
|
@ -38,6 +38,7 @@ export type schedulerType =
|
||||
| 'hbzb_zbs_group'
|
||||
| 'wzry_zuanshi16to8'
|
||||
| "cross_email_pull"
|
||||
| "watch_dog"
|
||||
| "xiaofeijingsai_local_ctor";
|
||||
|
||||
export class SchedulerManage {
|
||||
|
105
src/public/scheduler/scheduler_watchdog.ts
Normal file
105
src/public/scheduler/scheduler_watchdog.ts
Normal file
@ -0,0 +1,105 @@
|
||||
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";
|
||||
|
||||
export class WatchDog extends Scheduler {
|
||||
id: schedulerType = "watch_dog";
|
||||
time = 420; // 监控频率,每x秒一次
|
||||
name = "数据看门狗"
|
||||
type = ""
|
||||
|
||||
async read() {
|
||||
await this.ctorStartTime();
|
||||
this.isReady = false;
|
||||
this.startTime = this.nextTime;
|
||||
}
|
||||
|
||||
async start() {
|
||||
let confFile = resolve(__dirname, '../../oss/watchdog.json');
|
||||
if (!existsSync(confFile)) {
|
||||
//配置文件不存在
|
||||
await this.ctorStartTime()
|
||||
return;
|
||||
}
|
||||
let conf;
|
||||
try {
|
||||
conf = await JSON.parse(readFileSync(confFile, 'utf-8'));
|
||||
} catch (e) {
|
||||
//配置文件不是json
|
||||
await this.ctorStartTime()
|
||||
return;
|
||||
}
|
||||
//获取今天0点之后在线的玩家
|
||||
let users = await G.mongodb.collection("user").find({
|
||||
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) {
|
||||
//没有符合的玩家
|
||||
await this.ctorStartTime()
|
||||
return;
|
||||
}
|
||||
|
||||
let uids = users.map(i => i.uid);
|
||||
let uinfo = {};
|
||||
users.map(i => uinfo[i.uid] = i);
|
||||
|
||||
let actionLogs = await G.mongodb.collection("actionLog").find({
|
||||
type: 'day',
|
||||
uid: {$in: uids},
|
||||
}, {
|
||||
projection: {
|
||||
uid: 1,
|
||||
log: 1
|
||||
}
|
||||
}).toArray();
|
||||
|
||||
let warns = [];
|
||||
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 uid = actionLogs[i].uid
|
||||
if (myval > conf[j].limit) {
|
||||
//触发了警报
|
||||
warns.push({
|
||||
type: 'watchDog',
|
||||
uid: uid,
|
||||
name: uinfo[uid]?.name,
|
||||
lv: uinfo[uid]?.lv,
|
||||
vip: uinfo[uid]?.vip,
|
||||
key: key,
|
||||
value: myval,
|
||||
tips: conf[j].tips
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (warns.length > 0) {
|
||||
addWatchDogLog(warns);
|
||||
}
|
||||
|
||||
await this.ctorStartTime()
|
||||
}
|
||||
|
||||
get nextTime(): number {
|
||||
return G.time + this.time;
|
||||
}
|
||||
|
||||
async ctorStartTime() {
|
||||
this.isStart = false;
|
||||
this.startTime = this.nextTime;
|
||||
}
|
||||
}
|
@ -40,7 +40,7 @@ export class WangZheRongYaofun {
|
||||
/**获取报名人数 */
|
||||
static async getBaoMingNum() {
|
||||
let zkey: string = PublicShared.getToWeek();
|
||||
let _num = G.mongodb.collection('playerInfo', 'wzry').countDocuments({ isbm: 1 });
|
||||
let _num = G.mongodb.collection('playerInfo', 'wzry').countDocuments({ type:'wzry', isbm: 1 });
|
||||
return _num;
|
||||
}
|
||||
|
||||
|
@ -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});
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import { SchedulerManage } from './public/scheduler/scheduler';
|
||||
import {CrossEmailPull} from "./public/scheduler/scheduler_cross_email_pull";
|
||||
import {Scheduler_xfjs_Local_Ctor} from "./public/scheduler/scheduler_xiaofeijingsai";
|
||||
import { RankKfjs_1, RankKfjs_2, RankKfjs_3, RankKfjs_4, RankKfjs_5, RankKfjs_6, RankKfjs_7 } from './public/rank/rank_kfjs';
|
||||
import { WatchDog } from './public/scheduler/scheduler_watchdog';
|
||||
export async function startAfter() {
|
||||
|
||||
//事件监听和定时器初始化
|
||||
@ -93,6 +94,7 @@ export async function startAfter() {
|
||||
// new SchedulerWzrycrossEmail();
|
||||
|
||||
new CrossEmailPull().init()
|
||||
new WatchDog().init();
|
||||
});
|
||||
new SchedulerNewDayLocalCtor().init();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user