fix:jjc战斗日志添加_id倒序
This commit is contained in:
parent
b0a3c17927
commit
0d736e4854
119
src/fix_patch/patch_20240109-1.ts
Normal file
119
src/fix_patch/patch_20240109-1.ts
Normal file
@ -0,0 +1,119 @@
|
||||
import { patchFun, patchInit } from "../patch";
|
||||
import { PublicShared } from "../shared/public/public";
|
||||
import { JJCFun } from "../public/jjc";
|
||||
|
||||
function getRankPrize(rank: number, conf?: typeof G.gc.jjc_ph['']) {
|
||||
if (!conf) {
|
||||
conf = Object.values(G.gc.jjc_ph).filter(v => rank >= v.ph[0] && rank <= v.ph[1])[0];
|
||||
}
|
||||
if (conf) {
|
||||
return [...conf.prize, { a: 'item', t: '11', n: typeof conf.rongyuprize == 'number' ? conf.rongyuprize : PublicShared.eval(conf.rongyuprize, { a: rank }) }];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
class Path {
|
||||
|
||||
async addEmail(email, isCross = false) {
|
||||
let { prize, uid, ...e } = email;
|
||||
let lng = await G.redis.rawGet(`user:lng:${uid}`);
|
||||
let sendEmail = {
|
||||
_id: null,
|
||||
uid: uid,
|
||||
type: e.type,
|
||||
title: e.lngTitle ? (e.lngTitle[lng] || e.lngTitle['ja']) : e.title,
|
||||
content: e.lngContent ? (e.lngContent[lng] || e.lngContent['ja']) : e.content,
|
||||
createTime: e.createTime || G.time,
|
||||
contentInsertArr: e.contentInsertArr || []
|
||||
} as any;
|
||||
|
||||
/**跨服邮件给sid标识*/
|
||||
// if (isCross) {
|
||||
// sendEmail.sid = uid.split('_')[0];
|
||||
// }
|
||||
if ((prize === null || prize === void 0 ? void 0 : prize.length) > 0) {
|
||||
sendEmail.prizeData = {
|
||||
prize: email.prize,
|
||||
isGet: false
|
||||
};
|
||||
}
|
||||
if (email.g123log && Object.keys(email.g123log).length > 0)
|
||||
sendEmail.g123log = email.g123log;
|
||||
|
||||
if (email.lngTitle) {
|
||||
sendEmail.lngTitle = email.lngTitle;
|
||||
sendEmail.lngContent = email.lngContent;
|
||||
}
|
||||
//太亏了!换其他清理机制,getAllEmail是性能消耗大户
|
||||
//todo.. 换其他清理机制
|
||||
// if (!isCross) {
|
||||
// let emailList = await this.getAllEmail(uid);
|
||||
// if (emailList.length >= 50) {
|
||||
// emailList.sort((a, b) => {
|
||||
// let noPrizeA = a.prizeData == undefined ? 0 : 1;
|
||||
// let noPrizeB = b.prizeData == undefined ? 0 : 1;
|
||||
// let getA = a.prizeData?.isGet == true ? 0 : 1;
|
||||
// let getB = b.prizeData?.isGet == true ? 0 : 1;
|
||||
// if (noPrizeA != noPrizeB) {
|
||||
// return noPrizeA - noPrizeB;
|
||||
// } else if (getA != getB) {
|
||||
// return getA - getB;
|
||||
// }
|
||||
// return a.createTime - b.createTime;
|
||||
// });
|
||||
// this.removeEmail(uid, emailList[0]._id);
|
||||
// G.server.sendMsgByUid(uid, 'msg_s2c/EmailDel', emailList[0]._id);
|
||||
// }
|
||||
// }
|
||||
//@ts-ignore
|
||||
await G.mongodb.collection('email').insertOne({
|
||||
ttl: new Date(), ...G.mongodb.conversionIdObj(sendEmail)
|
||||
})
|
||||
}
|
||||
|
||||
async sendEmail(uid: string, rank: number, prize: atn[]) {
|
||||
|
||||
if (uid.indexOf('npc_') != -1) return;
|
||||
|
||||
await this.addEmail({
|
||||
uid: uid,
|
||||
type: 'system',
|
||||
title: G.gc.jjc_com.email.titel,
|
||||
content: G.gc.jjc_com.email.content,
|
||||
prize: prize,
|
||||
contentInsertArr: [rank]
|
||||
});
|
||||
}
|
||||
async fun1(a: any) {
|
||||
for (let conf of Object.values(G.gc.jjc_ph)) {
|
||||
let players = await JJCFun.getRankListUid(conf.ph[0] - 1, conf.ph[1]);
|
||||
|
||||
for (let index = 0; index < players.length; index++) {
|
||||
let uid = players[index];
|
||||
await this.sendEmail(uid, conf.ph[0] + index, getRankPrize(conf.ph[0] + index, conf));
|
||||
console.log("sendEmail", uid, conf.ph[0] + index)
|
||||
}
|
||||
}
|
||||
|
||||
return "sucess!!!"
|
||||
}
|
||||
|
||||
|
||||
|
||||
async run() {
|
||||
await this.fun1(1);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await patchInit()
|
||||
let patch = new Path();
|
||||
await patch.run();
|
||||
console.log("逻辑执行完成,等待退出");
|
||||
setTimeout(function () {
|
||||
console.log('结束程序');
|
||||
process.exit();
|
||||
}, 3000);
|
||||
}
|
||||
main();
|
File diff suppressed because it is too large
Load Diff
@ -1,43 +1,43 @@
|
||||
import {ApiCall, TsrpcError} from 'tsrpc';
|
||||
import {FightControl} from '../shared/fightControl/fightCntrol';
|
||||
import {formatNpcData} from '../shared/fightControl/fightFun';
|
||||
import {fightResult, joinFightData, roleDataType} from '../shared/fightControl/fightType';
|
||||
import {rankInfo} from '../shared/protocols/type';
|
||||
import {HeroShared} from '../shared/public/hero';
|
||||
import {PlayerShared} from '../shared/public/player';
|
||||
import {HeroFun} from './hero';
|
||||
import {UserFun} from './user';
|
||||
import {re, string} from "mathjs";
|
||||
import {getGud} from './gud';
|
||||
import {PushGiftFun} from "./pushgift";
|
||||
import { ApiCall, TsrpcError } from 'tsrpc';
|
||||
import { FightControl } from '../shared/fightControl/fightCntrol';
|
||||
import { formatNpcData } from '../shared/fightControl/fightFun';
|
||||
import { fightResult, joinFightData, roleDataType } from '../shared/fightControl/fightType';
|
||||
import { rankInfo } from '../shared/protocols/type';
|
||||
import { HeroShared } from '../shared/public/hero';
|
||||
import { PlayerShared } from '../shared/public/player';
|
||||
import { HeroFun } from './hero';
|
||||
import { UserFun } from './user';
|
||||
import { re, string } from "mathjs";
|
||||
import { getGud } from './gud';
|
||||
import { PushGiftFun } from "./pushgift";
|
||||
|
||||
type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross';
|
||||
|
||||
|
||||
let fights:{[key:string]:FightControl} = {
|
||||
|
||||
let fights: { [key: string]: FightControl } = {
|
||||
|
||||
};
|
||||
function clearFights (){
|
||||
function clearFights() {
|
||||
//定时清理战斗
|
||||
setInterval(()=>{
|
||||
setInterval(() => {
|
||||
let now = Date.now();
|
||||
for (let key in fights){
|
||||
if (now - fights[key].startTime > 30000){
|
||||
console.log("清理战斗",key);
|
||||
try{
|
||||
for (let key in fights) {
|
||||
if (now - fights[key].startTime > 30000) {
|
||||
console.log("清理战斗", key);
|
||||
try {
|
||||
fights[key].release();
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
delete fights[key];
|
||||
}
|
||||
}
|
||||
},5000);
|
||||
}, 5000);
|
||||
}
|
||||
clearFights();
|
||||
|
||||
export class FightFun {
|
||||
static fightIndex:number = 0;
|
||||
static fightIndex: number = 0;
|
||||
|
||||
static fight(data: joinFightData[], maxRoundNums = 30, fightType: "pvp" | "pve" = 'pvp') {
|
||||
this.fightIndex++;
|
||||
@ -80,16 +80,20 @@ export class FightFun {
|
||||
});
|
||||
|
||||
return {
|
||||
player: {...player, buff: PlayerShared.getBuff(player)},
|
||||
player: { ...player, buff: PlayerShared.getBuff(player) },
|
||||
roles: roles
|
||||
};
|
||||
}
|
||||
|
||||
/**挑战竞技场 */
|
||||
static async fightJJc(call: ApiCall, rankInfo: rankInfo) {
|
||||
if (rankInfo.player.uid.indexOf('npc_') != -1) return await this.fightNpc(call, G.gc.jjc_npc[rankInfo.player.uid].npcId, 'jjc', await this.getPlayerFightData(call.conn.uid));
|
||||
let result;
|
||||
|
||||
let result = this.fight([await this.getPlayerFightData(call.conn.uid), await this.getPlayerFightData(rankInfo.player.uid)]);
|
||||
if (rankInfo.player.uid.indexOf('npc_') != -1) {
|
||||
result = await this.fightNpc(call, G.gc.jjc_npc[rankInfo.player.uid].npcId, 'jjc', await this.getPlayerFightData(call.conn.uid));
|
||||
} else {
|
||||
result = this.fight([await this.getPlayerFightData(call.conn.uid), await this.getPlayerFightData(rankInfo.player.uid)]);
|
||||
}
|
||||
|
||||
// 竞技场 战败触发推送礼包
|
||||
if (result.winSide != 0) {
|
||||
@ -130,14 +134,14 @@ export class FightFun {
|
||||
* @param result
|
||||
*/
|
||||
static async saveLog(uid: string, type: string, result: fightResult) {
|
||||
let writeList = ['ganhai', 'jjc', 'hbzbJfs', 'hbzbZbs', 'slzd', 'clsl']
|
||||
let writeList = ['ganhai', 'jjc', 'hbzbJfs', 'hbzbZbs', 'slzd', 'clsl']
|
||||
if (uid.indexOf('npc') != -1 || !writeList.includes(type)) return;
|
||||
|
||||
G.mongodb.collection('fightLog').insertOne({uid, type, ...result})
|
||||
G.mongodb.collection('fightLog').insertOne({ uid, type, ...result })
|
||||
|
||||
}
|
||||
|
||||
static async readLog(uid: string, type: string, len = 20) {
|
||||
return await G.mongodb.collection('fightLog').find({uid, type}).limit(len).toArray() || []
|
||||
return await G.mongodb.collection('fightLog').find({ uid, type }).limit(len).sort({ _id: -1 }).toArray() || []
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user