Compare commits

..

No commits in common. "3899b9157cf09b69c12c9a4fedbaae0fed57763f" and "428033b26fab22b18242ada1645959db7e2f9ced" have entirely different histories.

31 changed files with 344 additions and 860 deletions

View File

@ -1,49 +1,16 @@
import { ApiCall } from "tsrpc";
import { ReqFindEnemy, ResFindEnemy } from "../../cross/protocols/clsl/PtlFindEnemy";
import { formatNpcData } from '../../shared/fightControl/fightFun';
import { PublicShared } from "../../shared/public/public";
export default async function (call: ApiCall<ReqFindEnemy, ResFindEnemy>) {
let p = PublicShared.randomNum(1, 1000);
let starConf = getStarConf(call.req.myStasr);
let enemy: { allStar: number, info: any };
// 本次随机到npc概率判断
if (p <= starConf.pro * 1000) {
enemy = {
allStar: call.req.myStasr,
info: formatNpcData(starConf.npc)
}
} else {
// 在自定范围内随机一个对手
let others = await G.mongodb.collection("clslCrossUser").aggregate([
{
$match: {
allStar: { $gte: starConf.fighter[0], $lte: starConf.fighter[1] }
}
}, {
$sample: { size: 1 }
}
]).toArray();
if (others.length <= 0) {
enemy = {
allStar: call.req.myStasr,
info: formatNpcData(starConf.npc)
}
} else {
enemy = {
allStar: others[0].allStar,
info: others[0].info,
}
}
}
let my = await G.mongodb.collection('clslCrossUser').findOne({ uid: call.req.uid });
let starConf = getStarConf(my.allStar);
let others = await G.mongodb.collection('clslCrossUser').find({ uid: { $nin: [call.req.uid] } }).toArray();
let enemy = others.random();
call.succ({
allStar: enemy.allStar,
info: enemy.info || formatNpcData(starConf.npc)
allStar: enemy?.allStar || my.allStar,
info: enemy?.info || formatNpcData(starConf.npc)
});
}

View File

@ -4,7 +4,7 @@ import { FightFun } from '../../public/fight';
export default async function (call: ApiCall<ReqLog, ResLog>) {
if (call.req.result) {
FightFun.saveLog(call.req.uid, 'clsl', call.req.result);
// FightFun.saveLog(call.req.uid, 'clsl', call.req.result);
call.succ({});
} else {
call.succ({

View File

@ -1,37 +1,10 @@
import { ApiCall } from "tsrpc";
import { ReqRank, ResRank } from "../../cross/protocols/clsl/PtlRank";
import { Rank } from '../../public/rank/rank';
import { PublicShared } from "../../shared/public/public";
import { RankClslCross } from "../../public/rank/rank_clsl";
export default async function (call: ApiCall<ReqRank, ResRank>) {
let group_time = G.gc.clsl_com.divideTime;
let week_zero_time = PublicShared.getToWeekMondayZeroTime();
if (G.time < week_zero_time + group_time) {
call.succ({ rankList: [], myRank: { rank: -1, player: {}, valArr: [] } })
return
}
let a = await G.mongodb.collection('clslCrossUser').findOne({
uid: call.req.uid
});
if (!a || !a.group){
call.succ({ rankList: [], myRank: { rank: -1, player: {}, valArr: [] } })
return
}
let rank: Rank;
if (Rank.list[`clslCross_${a.group}`]) {
rank = Rank.list[`clslCross_${a.group}`]
}
else {
rank = new RankClslCross(a.group)
}
let page = call.req.page || 0
let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
let { min, max } = Rank.pageToMin(page, offset)
call.succ(await rank.getRankList(call.req.uid, { min, max }));
let {min, max} = Rank.pageToMin(page, offset)
call.succ(await Rank.list.clslCross.getRankList(call.req.gud.uid, { min, max }));
}

View File

@ -0,0 +1,9 @@
import { ApiCall } from "tsrpc";
import { ReqRankUids, ResRankUids } from "../../cross/protocols/clsl/PtlRankUids";
import { Rank } from '../../public/rank/rank';
export default async function (call: ApiCall<ReqRankUids, ResRankUids>) {
// 返回排名的uids, 应用场景是定时器发送奖励,不分页。
let uids = await Rank.list.clslCross.getRankListIdKeyAll()
call.succ({uids});
}

View File

@ -1,49 +1,23 @@
import { ApiCall } from "tsrpc";
import { ReqUpLoad, ResUpLoad } from "../../cross/protocols/clsl/PtlUpLoad";
import { Rank } from '../../public/rank/rank';
import { PublicShared } from "../../shared/public/public";
import { RankClslCross } from "../../public/rank/rank_clsl";
export default async function (call: ApiCall<ReqUpLoad, ResUpLoad>) {
let { allStar, uid, ...ops } = call.req;
let a = (await G.mongodb.collection('clslCrossUser').findOneAndUpdate(
let a = await G.mongodb.collection('clslCrossUser').findOneAndUpdate(
{ uid: uid },
{
$inc: { allStar: allStar || 0 },
$set: ops
},
{ upsert: true, returnDocument: "after" }
)).value;
// 周四 并且没有分组 更新玩家分组
if ((PublicShared.getWeek(G.time) || 7) >= 4 && !a.group) {
// 查询分组数据
let week = PublicShared.getToWeek();
let group = await G.mongodb.collection('clslCrossGroup').findOne({ week: week });
for (let groupid in group.groups) {
let groupinfo = group.groups[groupid];
if (a.info.player.cTime >= groupinfo.st && a.info.player.cTime < groupinfo.et) {
a.group = groupid;
G.mongodb.collection('clslCrossUser').updateOne({ uid: uid }, { $set: { group: a.group } });
break;
}
}
}
{ upsert: true }
);
if (a.group) { // 分完组之后就可以更新排行榜了
if (allStar != undefined && ops.info) {
let rank;
if (Rank.list[`clslCross_${a.group}`]) {
rank = Rank.list[`clslCross_${a.group}`]
}
else {
rank = new RankClslCross(a.group)
}
rank.addNew({
player: a.info.player,
valArr: [a.allStar, a.info.player.power]
});
}
if (allStar != undefined && ops.info) {
Rank.list.clslCross.addNew({
player: a.value.info.player,
valArr: [(await G.mongodb.collection('clslCrossUser').findOne({ uid: uid })).allStar]
});
}
}

View File

@ -1,91 +1,43 @@
import { ApiCall } from "tsrpc";
import { FightFun } from '../../public/fight';
import { PlayerFun } from '../../public/player';
import { ReqFind, ResFind } from "../../shared/protocols/conglinshoulie/PtlFind";
import { PublicShared } from '../../shared/public/public';
import { addStar, clslDb } from './ApiOpen';
import { EmailFun } from "../../public/email";
import {ApiCall} from "tsrpc";
import {FightFun} from '../../public/fight';
import {PlayerFun} from '../../public/player';
import {ReqFind, ResFind} from "../../shared/protocols/conglinshoulie/PtlFind";
import {PublicShared} from '../../shared/public/public';
import {addStar, clslDb} from './ApiOpen';
export default async function (call: ApiCall<ReqFind, ResFind>) {
let weekZeroTime = PublicShared.getToWeekMondayZeroTime();
if (G.time < weekZeroTime + G.gc.clsl_com.fightTime[0] || G.time > weekZeroTime + G.gc.clsl_com.fightTime[1]) return call.errorCode(-1);
// 未到开启时间
if (G.time < weekZeroTime + G.gc.clsl_com.fightTime[0] || G.time > weekZeroTime + G.gc.clsl_com.fightTime[1]) {
return call.errorCode(-1)
};
// 获取自己的数据
let db = await clslDb().findOne({ uid: call.uid, type: 'clsl' });
let db = await clslDb().findOne({uid: call.uid, type: 'clsl'});
let curStar = db?.allStar || 0;
let useNum = db?.useFightNum || 0;
let buyNum = db?.buyFightNum || 0;
let danPrize = db?.danPrize || [];
let curMaxStar = db?.curMaxStar || 0;
// 战斗次数不足
if (useNum >= buyNum + G.gc.clsl_com.fightNum) {
return call.errorCode(-2);
}
// 自己战斗数据
let my = await call.conn.getDefaultFightData();
// 获取一个对手
let other = (await G.clientCross.callApi('clsl/FindEnemy', { uid: call.uid, myStasr: curStar })).res;
let result = FightFun.fight([my, other.info]);
let starConf = G.gc.clsl_dan[curStar] || Object.values(G.gc.clsl_dan).slice(-1)[0];
let updata = { $inc: { useFightNum: 1 } };
if (useNum >= buyNum + G.gc.clsl_com.fightNum) return call.errorCode(-2);
// 更新战斗胜利的次数
if (result.winSide == 0) {
updata.$inc["fightWinNum"] = 1;
let my = await call.conn.getDefaultFightData();
let other = (await G.clientCross.callApi('clsl/FindEnemy', {uid: call.uid})).res;
let result = FightFun.fight([my, other.info]);
// 首次达到某个段位
if (curStar + 1 > curMaxStar) {
curMaxStar += 1;
updata.$inc["curMaxStar"] = 1;
}
if ((result.winSide != 0 && starConf.failCut) || result.winSide == 0) {
addStar(call, result.winSide == 0 ? 1 : -starConf.failCut, my);
}
// 段位奖励邮件
let title = G.gc.clsl_com.email_dan.title;
let content = G.gc.clsl_com.email_dan.content;
G.gc.clsl_com.danPrize.forEach(conf => {
// 段位未达到 或者 奖励已经发放
if (conf.star > curMaxStar || danPrize.includes(conf.star)) {
return
}
result.initData[0].star = curStar
result.initData[1].star = other.allStar
// 发放邮件
EmailFun.addEmail({
uid: call.uid,
type: 'system',
title: title,
content: content,
prize: conf.prize,
contentInsertArr:[conf.title]
})
result.winSide == 0 && clslDb().updateOne({uid: call.uid, type: 'clsl'}, {$inc: {fightWinNum: 1}});
clslDb().updateOne({uid: call.uid, type: 'clsl'}, {$inc: {useFightNum: 1}});
danPrize.push(conf.star);
updata["$set"] = { danPrize: danPrize };
})
// 输了掉星 或者 赢了加星 同时更新排行数据
addStar(call, result.winSide == 0 ? 1 : -starConf.failCut, my, updata);
result.initData[0].star = curStar;
result.initData[1].star = other.allStar;
// 发送战斗奖励
await PlayerFun.sendPrize(call, starConf.fightPrize);
// 记录战斗日志
G.clientCross?.callApi('clsl/Log', { uid: call.uid, result: result });
G.clientCross?.callApi('clsl/Log', { uid: other.info.player.uid, result: result });
G.clientCross?.callApi('clsl/Log', {uid: call.uid, result: result});
G.clientCross?.callApi('clsl/Log', {uid: other.info.player.uid, result: result});
call.succ({ enemy: other, result: result });
call.succ({
enemy: other,
result: result
});
}

View File

@ -9,8 +9,8 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let db = await clslDb().findOne({ uid: call.uid, type: 'clsl' });
let { _id, uid, type, ...ops } = db || {} as WithId<OptionalId<CollectionPlayerInfo<"clsl">>>;
// 刷新 挑战次数、购买挑战次数、胜利次数任务
if (!db || ops?.refreshTime < PublicShared.getToDayZeroTime()) {
let change: Partial<typeof ops> = {
refreshTime: G.time,
useFightNum: 0,
@ -19,13 +19,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
buyFightNum: 0
};
// 隔周刷新星级
if (ops?.refreshTime < PublicShared.getToWeekMondayZeroTime()) {
change.allStar = 0;
change.danPrize = [];
change.curMaxStar = 0;
}
Object.assign(ops, change);
clslDb().updateOne({ uid: call.uid, type: 'clsl' }, { $set: change }, { upsert: true });
@ -36,10 +29,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
}
call.succ({
week: PublicShared.getWeek(G.time) || 7,
allStar: ops?.allStar || 0,
danPrize: ops?.danPrize || [],
curMaxStar: ops?.curMaxStar || 0,
buyFightNum: ops?.buyFightNum || 0,
useFightNum: ops?.useFightNum || 0,
fightWinNum: ops?.fightWinNum || 0,
@ -51,15 +41,7 @@ export function clslDb() {
return G.mongodb.cPlayerInfo('clsl');
}
export async function addStar(call: ApiCall, star: number, info?: joinFightData, update?: any) {
update = update || {};
if (update.$inc) {
update.$inc["allStar"] = star
} else {
update["$inc"] = { allStar: star }
}
clslDb().updateOne({ uid: call.uid, type: 'clsl' }, update, { upsert: true });
export async function addStar(call: ApiCall, star: number, info?: joinFightData) {
clslDb().updateOne({ uid: call.uid, type: 'clsl' }, { $inc: { allStar: star } }, { upsert: true });
G.clientCross.callApi('clsl/UpLoad', { uid: call.uid, allStar: star, info: info || await call.conn.getDefaultFightData() });
}

View File

@ -19,7 +19,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
if (!db) {
await G.mongodb.cEvent(_dbType).updateOne(
{uid: call.uid, type: _dbType},
{$set: {sTime: sTime, recIndex: [], round: 0}},
{$set: {sTime: sTime, recIndex: []}},
{upsert: true}
);
}
@ -33,6 +33,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
recIndex: db?.recIndex || [],
payNum: payNum,
hdinfo: _hdinfo,
round: db?.round || 0
round: db.round || 0
});
}

View File

@ -4,9 +4,6 @@ import {PlayerFun} from "../../public/player";
import {ReqYanShi, ResYanShi} from "../../shared/protocols/kuangdong/PtlYanShi";
export default async function (call: ApiCall<ReqYanShi, ResYanShi>) {
return call.errorCode(1)
let hdid = call.req.hdid
let con = await KuangDongfun.getCon(hdid)

View File

@ -6,8 +6,7 @@ import { getToper50RankInfo } from "../hbzb/jfs/fun";
import { getZbsRankList } from "../hbzb/zbs/fun";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
console.log("==============>", call.req)
let obj = await rankOpenfun(call, call.req);
let obj = await rankOpenfun(call, call.req)
call.succ(obj);
}
@ -25,7 +24,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
export async function rankOpenfun(call, req: ReqOpen): Promise<ResOpen> {
let obj: ResOpen = {};
// 数组,兼容旧的参数
if (req instanceof Array) {
if(req instanceof Array) {
var types = req
var page = 0
var offset = 1
@ -40,7 +39,7 @@ export async function rankOpenfun(call, req: ReqOpen): Promise<ResOpen> {
const { min, max } = Rank.pageToMin(page, offset)
for (let type of types) {
switch (type) {
case 'jjc':
case 'jjc':
// 获取前50名ranklist数据
let rankList = await JJCFun.getRankList(min, max);
// 获取自己的排名
@ -69,23 +68,21 @@ export async function rankOpenfun(call, req: ReqOpen): Promise<ResOpen> {
case 'slzd4':
case 'slzd5':
case 'slzd6':
obj[type] = await Rank.list[type].getRankList(call.conn.gud.ghId, { min, max });
obj[type] = await Rank.list[type].getRankList(call.conn.gud.ghId, {min, max});
break;
case 'kbzz':
let resCall = await G.clientCross.callApi('kbzz/Rank', { uid: call.uid, page, offset });
let resCall = await G.clientCross.callApi('kbzz/Rank', { uid: call.uid, page, offset});
if (!resCall.isSucc) {
return call.error('', { code: -2, message: globalThis.lng.rank_kbzz });
}
obj[type] = resCall.res;
break;
case 'clslCross':
let res = await G.clientCross.callApi('clsl/Rank', {
uid: call.uid, page: page, offset: offset
});
obj[type] = res.res;
//let resCallClsl = await G.clientCross.callApi('clsl/Rank', { gud: call.conn.gud, page, offset});
//obj[type] = resCallClsl.res;
break;
case 'wzryCross':
let resCallWzry = await G.clientCross.callApi('wzry/Rank', { gud: call.conn.gud, page, offset });
let resCallWzry = await G.clientCross.callApi('wzry/Rank', { gud: call.conn.gud, page, offset});
obj[type] = resCallWzry.res;
break;
case "hbzbLocal":
@ -96,7 +93,7 @@ export async function rankOpenfun(call, req: ReqOpen): Promise<ResOpen> {
obj[type] = await getZbsRankList(call.uid) as any;
break;
default:
obj[type] = await Rank.list[type].getRankList(call.uid, { min, max });
obj[type] = await Rank.list[type].getRankList(call.uid, {min, max});
break;
}
}

View File

@ -3,7 +3,6 @@ import { joinFightData } from '../../../shared/fightControl/fightType';
export type ReqFindEnemy = {
uid: string;
myStasr:number;
};
export type ResFindEnemy = {

View File

@ -3,7 +3,7 @@ import { player } from '../../../shared/protocols/user/type';
export type ReqRank = {
uid: string;
gud: player;
page?: number;
offset?: number;
};

View File

@ -0,0 +1,9 @@
export type ReqRankUids = {
};
export type ResRankUids = {
uids: string[];
};

View File

@ -2,6 +2,7 @@ import { ServiceProto } from 'tsrpc-proto';
import { ReqFindEnemy, ResFindEnemy } from './clsl/PtlFindEnemy';
import { ReqLog, ResLog } from './clsl/PtlLog';
import { ReqRank, ResRank } from './clsl/PtlRank';
import { ReqRankUids, ResRankUids } from './clsl/PtlRankUids';
import { ReqUpLoad, ResUpLoad } from './clsl/PtlUpLoad';
import { ReqDelCrossEmail, ResDelCrossEmail } from './email/PtlDelCrossEmail';
import { ReqGetCrossEmail, ResGetCrossEmail } from './email/PtlGetCrossEmail';
@ -53,6 +54,10 @@ export interface ServiceType {
req: ReqRank,
res: ResRank
},
"clsl/RankUids": {
req: ReqRankUids,
res: ResRankUids
},
"clsl/UpLoad": {
req: ReqUpLoad,
res: ResUpLoad
@ -206,181 +211,186 @@ export const serviceProto: ServiceProto<ServiceType> = {
},
{
"id": 3,
"name": "clsl/UpLoad",
"name": "clsl/RankUids",
"type": "api"
},
{
"id": 4,
"name": "email/DelCrossEmail",
"name": "clsl/UpLoad",
"type": "api"
},
{
"id": 5,
"name": "email/GetCrossEmail",
"name": "email/DelCrossEmail",
"type": "api"
},
{
"id": 6,
"name": "hbzb/jfs/GetEnemy",
"name": "email/GetCrossEmail",
"type": "api"
},
{
"id": 7,
"name": "hbzb/jfs/GetLog",
"name": "hbzb/jfs/GetEnemy",
"type": "api"
},
{
"id": 8,
"name": "hbzb/jfs/GetRankList",
"name": "hbzb/jfs/GetLog",
"type": "api"
},
{
"id": 9,
"name": "hbzb/jfs/GetUser",
"name": "hbzb/jfs/GetRankList",
"type": "api"
},
{
"id": 10,
"name": "hbzb/GetUser",
"name": "hbzb/jfs/GetUser",
"type": "api"
},
{
"id": 11,
"name": "hbzb/UpdateHbzbCrossUser",
"name": "hbzb/GetUser",
"type": "api"
},
{
"id": 12,
"name": "hbzb/zbs/GetEnemy",
"name": "hbzb/UpdateHbzbCrossUser",
"type": "api"
},
{
"id": 13,
"name": "hbzb/zbs/GetLog",
"name": "hbzb/zbs/GetEnemy",
"type": "api"
},
{
"id": 14,
"name": "hbzb/zbs/GetRankList",
"name": "hbzb/zbs/GetLog",
"type": "api"
},
{
"id": 15,
"name": "hbzb/zbs/GetStatus",
"name": "hbzb/zbs/GetRankList",
"type": "api"
},
{
"id": 16,
"name": "hbzb/zbs/SendJjcTop",
"name": "hbzb/zbs/GetStatus",
"type": "api"
},
{
"id": 17,
"name": "kbzz/Apply",
"name": "hbzb/zbs/SendJjcTop",
"type": "api"
},
{
"id": 18,
"name": "kbzz/GetUser",
"name": "kbzz/Apply",
"type": "api"
},
{
"id": 19,
"name": "kbzz/GroupRank",
"name": "kbzz/GetUser",
"type": "api"
},
{
"id": 20,
"name": "kbzz/Rank",
"name": "kbzz/GroupRank",
"type": "api"
},
{
"id": 21,
"name": "kbzz/Refresh",
"name": "kbzz/Rank",
"type": "api"
},
{
"id": 22,
"name": "kbzz/State",
"name": "kbzz/Refresh",
"type": "api"
},
{
"id": 23,
"name": "kbzz/UpUser",
"name": "kbzz/State",
"type": "api"
},
{
"id": 24,
"name": "kbzz/UpUser",
"type": "api"
},
{
"id": 25,
"name": "msg_cross/CrossChat",
"type": "msg"
},
{
"id": 25,
"id": 26,
"name": "msg_cross/HbzbChangeRank",
"type": "msg"
},
{
"id": 26,
"id": 27,
"name": "msg_cross/HbzbJfsLog",
"type": "msg"
},
{
"id": 27,
"id": 28,
"name": "msg_cross/HbzbSendUser",
"type": "msg"
},
{
"id": 28,
"id": 29,
"name": "msg_cross/HbzbZbsLog",
"type": "msg"
},
{
"id": 29,
"id": 30,
"name": "wzry/BaoMing",
"type": "api"
},
{
"id": 30,
"id": 31,
"name": "wzry/catFightLog",
"type": "api"
},
{
"id": 31,
"id": 32,
"name": "wzry/DldRefre",
"type": "api"
},
{
"id": 32,
"id": 33,
"name": "wzry/getJingCai",
"type": "api"
},
{
"id": 33,
"id": 34,
"name": "wzry/Rank",
"type": "api"
},
{
"id": 34,
"id": 35,
"name": "wzry/SetWzFight",
"type": "api"
},
{
"id": 35,
"id": 36,
"name": "wzry/UpdateFight",
"type": "api"
},
{
"id": 36,
"id": 37,
"name": "wzry/WzFightData",
"type": "api"
},
{
"id": 37,
"id": 38,
"name": "wzry/WzFightGroup",
"type": "api"
},
{
"id": 38,
"id": 39,
"name": "wzry/Wzzd",
"type": "api"
}
@ -395,13 +405,6 @@ export const serviceProto: ServiceProto<ServiceType> = {
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "myStasr",
"type": {
"type": "Number"
}
}
]
},
@ -2750,9 +2753,10 @@ export const serviceProto: ServiceProto<ServiceType> = {
"properties": [
{
"id": 0,
"name": "uid",
"name": "gud",
"type": {
"type": "String"
"type": "Reference",
"target": "../../shared/protocols/user/type/player"
}
},
{
@ -2773,6 +2777,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
]
},
"../../shared/protocols/user/type/player": {
"type": "IndexedAccess",
"index": "gud",
"objectType": {
"type": "Reference",
"target": "../../shared/protocols/user/PtlLogin/ResLogin"
}
},
"clsl/PtlRank/ResRank": {
"type": "IndexedAccess",
"index": "",
@ -2885,6 +2897,24 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
]
},
"clsl/PtlRankUids/ReqRankUids": {
"type": "Interface"
},
"clsl/PtlRankUids/ResRankUids": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "uids",
"type": {
"type": "Array",
"elementType": {
"type": "String"
}
}
}
]
},
"clsl/PtlUpLoad/ReqUpLoad": {
"type": "Partial",
"target": {
@ -3228,14 +3258,6 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
]
},
"../../shared/protocols/user/type/player": {
"type": "IndexedAccess",
"index": "gud",
"objectType": {
"type": "Reference",
"target": "../../shared/protocols/user/PtlLogin/ResLogin"
}
},
"hbzb/jfs/PtlGetEnemy/ResGetEnemy": {
"type": "Interface",
"properties": [

View File

@ -30,17 +30,16 @@ async function connGameLogDB() {
process.on('uncaughtException',function(err:Error){
addErrorLog((err?.stack)?.toString());
addErrorLog((err.stack).toString());
})
process.on('unhandledRejection', function (err:Error, promise) {
addErrorLog((err?.stack)?.toString());
addErrorLog((err.stack).toString());
})
async function addErrorLog(errData:any){
try{
//g123测试版连接不上db不抓取
if(!errData)return;
if(isG123stg())return;
let log = {
serverId : G.config.serverId,

View File

@ -1,11 +1,18 @@
{
//赛区划分按照周三23:50的时候王者玩家100个一组
//赛区划分时间周三23:50
divideTime: 258600,
//挑战时间周一08:00——周六22:00
//赛区划分
divide: [
{ day: [1, 30], group: 0 },
{ day: [31, 60], group: 1 },
{ day: [61, 120], group: 2 },
{ day: [121, 210], group: 3 },
{ day: [211, 99999999], group: 4 },
],
//赛区划分时间
divideTime: 0,
//挑战时间
fightTime: [28800, 511200],
//发奖时间周六22:05
prizeTime: 511500,
//发奖时间
prizeTime: 598200,
//胜场奖励
fightWinPrize: [
{ total: 5, prize: [{ a: 'attr', t: 'clsl_sd', n: 1 },{ a: 'item', t: '37', n: 1 }], star: 1 },
@ -32,13 +39,13 @@
],
//段位奖励
danPrize: [
{ star: 49, title: "clsl_7", prize: [{ a: 'item', t: '605', n:3 },{ a: 'item', t: '29', n:10 },{ a: 'item', t: '631', n:3 },{ a: 'item', t: '40', n:1 }] },
{ star: 39, title: "clsl_6", prize: [{ a: 'item', t: '605', n:2 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '631', n:2 }] },
{ star: 29, title: "clsl_5", prize: [{ a: 'item', t: '606', n:3 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '631', n:1 }] },
{ star: 21, title: "clsl_4", prize: [{ a: 'item', t: '606', n:2 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:1000 }] },
{ star: 13, title: "clsl_3", prize: [{ a: 'item', t: '606', n:1 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:800 }] },
{ star: 7, title: "clsl_2", prize: [{ a: 'item', t: '29', n:10 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:600 }] },
{ star: 0, title: "clsl_1", prize: [{ a: 'item', t: '29', n:5 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:400 }] }
{ star: [49, 49], prize: [{ a: 'item', t: '605', n:3 },{ a: 'item', t: '29', n:10 },{ a: 'item', t: '631', n:3 },{ a: 'item', t: '40', n:1 }] },
{ star: [39, 48], prize: [{ a: 'item', t: '605', n:2 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '631', n:2 }] },
{ star: [29, 38], prize: [{ a: 'item', t: '606', n:3 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '631', n:1 }] },
{ star: [21, 28], prize: [{ a: 'item', t: '606', n:2 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:1000 }] },
{ star: [13, 20], prize: [{ a: 'item', t: '606', n:1 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:800 }] },
{ star: [7, 12], prize: [{ a: 'item', t: '29', n:10 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:600 }] },
{ star: [0, 6], prize: [{ a: 'item', t: '29', n:5 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:400 }] }
],
//王者排名邮件信息
email_rank: {

View File

@ -18,11 +18,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
0,
6
],
"npc": 60001
},
"1": {
@ -44,11 +39,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
0,
6
],
"npc": 60002
},
"2": {
@ -70,11 +60,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
0,
6
],
"npc": 60003
},
"3": {
@ -96,11 +81,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
0,
6
],
"npc": 60004
},
"4": {
@ -122,11 +102,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
0,
6
],
"npc": 60005
},
"5": {
@ -148,11 +123,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
0,
6
],
"npc": 60006
},
"6": {
@ -174,11 +144,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
0,
6
],
"npc": 60007
},
"7": {
@ -200,11 +165,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
7,
12
],
"npc": 60008
},
"8": {
@ -226,11 +186,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
7,
12
],
"npc": 60009
},
"9": {
@ -252,11 +207,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
7,
12
],
"npc": 60010
},
"10": {
@ -278,11 +228,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
7,
12
],
"npc": 60011
},
"11": {
@ -304,11 +249,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
7,
12
],
"npc": 60012
},
"12": {
@ -330,11 +270,6 @@
"n": 100
}
],
"pro": 0.6,
"fighter": [
7,
12
],
"npc": 60013
},
"13": {
@ -356,11 +291,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
13,
20
],
"npc": 60014
},
"14": {
@ -382,11 +312,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
13,
20
],
"npc": 60015
},
"15": {
@ -408,11 +333,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
13,
20
],
"npc": 60016
},
"16": {
@ -434,11 +354,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
13,
20
],
"npc": 60017
},
"17": {
@ -460,11 +375,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
13,
20
],
"npc": 60018
},
"18": {
@ -486,11 +396,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
13,
20
],
"npc": 60019
},
"19": {
@ -512,11 +417,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
13,
20
],
"npc": 60020
},
"20": {
@ -538,11 +438,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
13,
20
],
"npc": 60021
},
"21": {
@ -564,11 +459,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
21,
28
],
"npc": 60022
},
"22": {
@ -590,11 +480,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
21,
28
],
"npc": 60023
},
"23": {
@ -616,11 +501,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
21,
28
],
"npc": 60024
},
"24": {
@ -642,11 +522,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
21,
28
],
"npc": 60025
},
"25": {
@ -668,11 +543,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
21,
28
],
"npc": 60026
},
"26": {
@ -694,11 +564,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
21,
28
],
"npc": 60027
},
"27": {
@ -720,11 +585,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
21,
28
],
"npc": 60028
},
"28": {
@ -746,11 +606,6 @@
"n": 100
}
],
"pro": 0.3,
"fighter": [
21,
28
],
"npc": 60029
},
"29": {
@ -772,11 +627,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60030
},
"30": {
@ -798,11 +648,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60031
},
"31": {
@ -824,11 +669,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60032
},
"32": {
@ -850,11 +690,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60033
},
"33": {
@ -876,11 +711,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60034
},
"34": {
@ -902,11 +732,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60035
},
"35": {
@ -928,11 +753,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60036
},
"36": {
@ -954,11 +774,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60037
},
"37": {
@ -980,11 +795,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60038
},
"38": {
@ -1006,11 +816,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
29,
38
],
"npc": 60039
},
"39": {
@ -1032,11 +837,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60040
},
"40": {
@ -1058,11 +858,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60041
},
"41": {
@ -1084,11 +879,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60042
},
"42": {
@ -1110,11 +900,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60043
},
"43": {
@ -1136,11 +921,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60044
},
"44": {
@ -1162,11 +942,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60045
},
"45": {
@ -1188,11 +963,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60046
},
"46": {
@ -1214,11 +984,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60047
},
"47": {
@ -1240,11 +1005,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60048
},
"48": {
@ -1266,11 +1026,6 @@
"n": 100
}
],
"pro": 0.15,
"fighter": [
39,
48
],
"npc": 60049
},
"49": {
@ -1292,11 +1047,6 @@
"n": 100
}
],
"pro": 0,
"fighter": [
39,
49
],
"npc": 60050
}
}

View File

@ -103,7 +103,7 @@ type gc_choujiang = {
type gc_chuanshuozhilu = { "hid": string, "time": number, "task": { "idx": number, "total": number, "type": string, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], "des": string, [x: string]: any }[], "box": { "total": number, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], [x: string]: any }, [x: string]: any }[]
type gc_clsl_com = {
"divide": { "day": [number, number], "group": number, [x: string]: any }[], "divideTime": number, "fightTime": [number, number], "prizeTime": number, "fightWinPrize": { "total": number, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], "star": number, [x: string]: any }[], "fightNum": number, "vipBuyFightNum": [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number], "buyFightNumNeed": { "a": string, "t": string, "n": number, [x: string]: any }[], "rankPrize": { "rank": [number, number], "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], "title": string, [x: string]: any }[], "danPrize": { "star": number, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], [x: string]: any }[], "email_rank": { "title": string, "content": string, [x: string]: any }, "email_dan": { "title": string, "content": string, [x: string]: any }, [x: string]: any
"divide": { "day": [number, number], "group": number, [x: string]: any }[], "divideTime": number, "fightTime": [number, number], "prizeTime": number, "fightWinPrize": { "total": number, "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], "star": number, [x: string]: any }[], "fightNum": number, "vipBuyFightNum": [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number], "buyFightNumNeed": { "a": string, "t": string, "n": number, [x: string]: any }[], "rankPrize": { "rank": [number, number], "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], "title": string, [x: string]: any }[], "danPrize": { "star": [number, number], "prize": { "a": string, "t": string, "n": number, [x: string]: any }[], [x: string]: any }[], "email_rank": { "title": string, "content": string, [x: string]: any }, "email_dan": { "title": string, "content": string, [x: string]: any }, [x: string]: any
}
type gc_clsl_dan = k_v<{
@ -122,11 +122,7 @@ type gc_clsl_dan = k_v<{
/** 战斗奖励 */
'fightPrize': { "a": string, "t": string, "n": number, [x: string]: any }[]
/** 机器人 */
'npc': number,
/** 随机机器人概率*/
'pro':number
/** 对手范围 */
'fighter':number[]
'npc': number
}>;
type gc_com = k_v<{

View File

@ -6,9 +6,4 @@ export type CollectionCllsCrossUser = {
area: number;
allStar: number;
info: joinFightData;
};
export type CollectionCllsCrossGroup = {
week: string;
groups: { [group: string]: { st: number, et: number } };
}
};

View File

@ -4,7 +4,7 @@ import {rankType} from '../shared/protocols/rank/PtlOpen';
import {CollectionChatLog} from './collection_chatlog';
import {CollectionActionLog} from './collection_actionLog';
import {CollectionCardlog} from './collection_cardlog';
import {CollectionCllsCrossGroup, CollectionCllsCrossUser} from './collection_clsl';
import {CollectionCllsCrossUser} from './collection_clsl';
import {CollectionCrosskv} from './collection_crosskv';
import {CollectionDayPay} from './collection_dayPay';
import {CollectionDxlt} from './collection_dxlt';
@ -115,8 +115,7 @@ export type MongodbCollections = {
any: { type: string, data: any[]; };
zhanling: CollectionZhanLing;
clslCrossGroup: CollectionCllsCrossGroup;
clslCrossUser: CollectionCllsCrossUser & { group: string };
clslCrossUser: CollectionCllsCrossUser;
lingzhulaixi: CollectionLingZhuLaiXi;
wzry_user_cross: CollectionWzryCross;
wzry_fight: CollectionWzryCrossFight;

View File

@ -709,21 +709,21 @@ export const serviceProto: ServiceProto<ServiceType> = {
"id": 13,
"type": {
"type": "Literal",
"literal": "clslCross"
"literal": "kbzz"
}
},
{
"id": 14,
"type": {
"type": "Literal",
"literal": "kbzz"
"literal": "xszm"
}
},
{
"id": 15,
"type": {
"type": "Literal",
"literal": "xszm"
"literal": "clslCross"
}
},
{

View File

@ -130,7 +130,7 @@ 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']
if (uid.indexOf('npc') != -1 || !writeList.includes(type)) return;
G.mongodb.collection('fightLog').insertOne({uid, type, ...result})

View File

@ -108,12 +108,8 @@ export abstract class Rank {
return this.getType();
}
constructor(param?: any) {
// 将param属性赋值给this
param && Object.assign(this, param);
constructor() {
Rank.list[this.getType() as string] = this;
// 初始化排行榜
this.cotr();
}
@ -139,7 +135,7 @@ export abstract class Rank {
//将db里的数据写入到 rank:xxx:sort里
//写入的单条数据为: {uid:score}
// 首先清理redis中sort数据 在从数据库中初始化
await G.ioredis.del(this.getRedisKeySort);
@ -257,57 +253,61 @@ export abstract class Rank {
if (uids && uids.length > 0) {
let res = await this.db.find({ idKey: { $in: uids }, type: this.getType() }).toArray()
if (this.type.indexOf("slzd") != -1) {
let ghid = [];
res = res.map(item => {
if (!item.data?.player?.ghid || item.data.utime + 60 < G.time) {
ghid.push(G.mongodb.conversionId(item.idKey));
}
return item;
})
if (ghid.length > 0) {
let ghinfo = await G.mongodb.collection("gonghui").find(
{ _id: { $in: ghid } }, { projection: { name: 1 } }
).toArray();
ghinfo.forEach(item => {
let index = res.findIndex(x => x.idKey == item._id.toHexString());
res[index].data.player = {
ghName: item.name,
ghId: item._id.toHexString(),
};
this.db.updateOne({ idKey: item._id.toHexString(), type: this.getType() }, { $set: { "data.player": res[index].data.player } });
switch (this.getType()) {
case "slzd1":
case "slzd2":
case "slzd3":
case "slzd4":
case "slzd5":
case "slzd6":
let ghid = [];
res = res.map(item => {
if (!item.data?.player?.ghid || item.data.utime + 60 < G.time) {
ghid.push(G.mongodb.conversionId(item.idKey));
}
return item;
})
}
} else if (this.type.indexOf('clslCross') != -1) {
// 丛林猎手 跨服排行榜 不需要更新
} else {
let updateUids = [];
res = res.map(item => {
// 没有player 或者 player 过期
if (!item.data?.player || item.data.utime + 60 < G.time) {
updateUids.push(item.idKey);
if (ghid.length > 0) {
let ghinfo = await G.mongodb.collection("gonghui").find(
{ _id: { $in: ghid } }, { projection: { name: 1 } }
).toArray();
ghinfo.forEach(item => {
let index = res.findIndex(x => x.idKey == item._id.toHexString());
res[index].data.player = {
ghName: item.name,
ghId: item._id.toHexString(),
};
this.db.updateOne({ idKey: item._id.toHexString(), type: this.getType() }, { $set: { "data.player": res[index].data.player } });
})
}
return item;
});
break;
default: // 排行数据更新逻辑 默认更新playerInfo
let updateUids = [];
res = res.map(item => {
// 没有player 或者 player 过期
if (!item.data?.player || item.data.utime + 60 < G.time) {
updateUids.push(item.idKey);
}
return item;
});
let newUserArr = await G.mongodb.collection('user').find(
{ uid: { $in: updateUids } }, { projection: { _id: 0 } }
).toArray();
let newUserArr = await G.mongodb.collection('user').find(
{ uid: { $in: updateUids } }, { projection: { _id: 0 } }
).toArray();
newUserArr.forEach(item => {
// 每次遍历查找?
let index = res.findIndex(x => x.idKey == item.uid);
newUserArr.forEach(item => {
// 每次遍历查找?
let index = res.findIndex(x => x.idKey == item.uid);
res[index].data.player = item;
this.db.updateOne({ idKey: item.uid, type: this.getType() }, { $set: { "data.player": item } });
res[index].data.player = item;
this.db.updateOne({ idKey: item.uid, type: this.getType() }, { $set: { "data.player": item } });
// 跟新redis score
// this.setRankData(item.uid, res[index].data as any);
})
// 跟新redis score
// this.setRankData(item.uid, res[index].data as any);
})
}
// 按照redis uids 排序顺序排序
return res.sort((a, b) => uids.indexOf(a.idKey) - uids.indexOf(b.idKey)).map(ele => ele.data);
return res.sort((a,b)=>uids.indexOf(a.idKey)-uids.indexOf(b.idKey)).map(ele => ele.data);
}
return []
}
@ -405,10 +405,10 @@ export abstract class Rank {
// 清空相关rank数据
async clear() {
// this.queue.enqueue(async () => {
// G.redis.rawDel(this.getRedisKey)
G.redis.rawDel(this.getRedisKeySort);
this.db.deleteMany({ type: this.type });
// });
this.queue.enqueue(async () => {
// G.redis.rawDel(this.getRedisKey)
G.redis.rawDel(this.getRedisKeySort);
await this.db.deleteMany({ type: this.type });
});
}
}

View File

@ -1,58 +1,58 @@
import { rankType } from '../../shared/protocols/rank/PtlOpen';
import { rankInfo } from '../../shared/protocols/type';
import { PublicShared } from '../../shared/public/public';
import { player } from '../../shared/protocols/user/type';
import { Rank } from './rank';
export class RankClslCross extends Rank {
group: string;
countMaxNum = 99999;
minStar = Object.values(G.gc.clsl_dan)[Object.keys(G.gc.clsl_dan).length - 1].allStar;
constructor(group: string = 'group0') {
super({ group });
}
getType(): rankType { return `clslCross_${this.group}` as rankType }
getValArr(info: rankInfo): number | string {
// 星级
let star = info?.valArr[0] || 0;
// 战力
let zhanli1 = info?.valArr[1] || 0;
// 将星级作为整数部分战力作为小数部分长度为10位 进行拼接
let val = `${star}.${zhanli1.toString().padStart(10, '0')}`;
return Number(val)
}
async getRankData(uid: string) {
let data: rankInfo;
return (await this.db.findOne({ "idKey": uid, "type": this.getType() }))?.data
getType(): rankType {
return 'clslCross';
}
// compare(other: rankInfo, cur: rankInfo): boolean {
// return cur.valArr[0] > other.valArr[0];
// }
// compareSort(a: rankInfo, b: rankInfo): number {
// return b.valArr[0] - a.valArr[0];
// }
// // 积分, 排名依据
// getValArr(info: rankInfo):number|string {
// return info?.valArr[0] || 0
// }
// async getRankList(uid: string, {gud, min, max}) {
// let rankList = await this.getRankListRange(min, max);
// let rank = await this.getRankSortByOne(uid);
// let score = await this.getRankScore(uid)
// return {
// rankList: rankList,
// myRank: {
// rank: rank,
// player: gud,
// valArr: [score]
// }
// };
// }
async addNew(info: rankInfo) {
// 积分大于配置的最小参数,更新数据
if (info.valArr[0] >= this.minStar) {
this.setRankData(info.player[this.findKey], info)
this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true });
}
}
}
/**
*
*/
export async function RankClslCrossInit() {
let week = PublicShared.getToWeek();
let group_time = G.gc.clsl_com.divideTime;
let week_zero_time = PublicShared.getToWeekMondayZeroTime();
if (G.time > week_zero_time + group_time) {
let groups = await G.mongodb.collection('clslCrossGroup').findOne({ week: week });
Object.keys(groups.groups).forEach(group => {
new RankClslCross(group);
})
this.queue.enqueue(async () => {
// 积分大于配置的最小参数,更新数据
if (info.valArr[0] >= this.minStar) {
this.setRankData(info.player[this.findKey], info)
this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true });
// rankList.sort(this.compareSort);
}
// 积分小于配置,且用户数据存在时,删除
else if (info.valArr[0] < this.minStar) {
let rankInfo = await this.getRankData(info.player[this.findKey])
if(rankInfo?.player) {
this.db.deleteOne({ type: this.type, idKey: info.player[this.findKey] });
this.delRankData(info.player[this.findKey])
}
}
});
}
}

View File

@ -13,9 +13,9 @@ export type schedulerType =
| 'hbzb_cross_reset'
| 'hbzb_zbs_ready'
| 'kbzz'
| 'clsl_prize'
| 'clsl_cross_ctor'
| 'clsl_cross_group'
| 'clsl_local_ctor'
| 'clsl_prize'
| 'wzry_autobaoming'
| 'wzry_dldstart'
| 'wzry_dldjinji'

View File

@ -1,60 +1,13 @@
import {PublicShared} from '../../shared/public/public';
import {EmailFun} from '../email';
import {RankClslCross} from '../rank/rank_clsl';
import {Scheduler, schedulerType} from './scheduler';
import { EmailFun } from '../email';
import { Rank } from '../rank/rank';
import { Scheduler, schedulerType } from './scheduler';
/**
*
*/
export class SchedulerClslLocalCtor extends Scheduler {
id: schedulerType = 'clsl_cross_ctor';
time = 0;
name = '丛林猎手赛季重置';
type: 'day' | 'week' = 'week';
async read() {
await this.ctorStartTime();
this.isReady = false;
}
async start() {
let week = PublicShared.getToWeek(
PublicShared.getToWeekMondayZeroTime(G.time - 3600)
);
// 修改clslCrossUser表中的uid为del_uid_week 并且 设置ttltime为当前时间
await G.mongodb.collection('clslCrossUser').updateMany(
{
ttltime: {$exists: false}
}, {$rename: {"uid": `del_uid_${week}`}, $set: {"ttltime": new Date()}}
);
// 获取分组信息 重置排行榜
let groups = await G.mongodb.collection('clslCrossGroup').findOne({week});
Object.keys(groups.groups).forEach((group) => {
// 清理排行数据
new RankClslCross(group).clear();
})
await this.record();
}
}
/**
*
* 100
*/
export class SchedulerClslCrossCtor extends Scheduler {
id: schedulerType = 'clsl_cross_group';
num: number = 2;
type: 'day' | 'week' = 'week';
id: schedulerType = 'clsl_cross_ctor';
time = G.gc.clsl_com.divideTime;
name = '丛林猎手赛季区间划分 周四00:00';
star = Object.values(G.gc.clsl_dan).slice(-1)[0].allStar;
name = '丛林猎手赛季初始化';
type: 'day' | 'week' = 'week';
async read() {
await this.ctorStartTime();
@ -62,96 +15,30 @@ export class SchedulerClslCrossCtor extends Scheduler {
}
async start() {
let week = PublicShared.getToWeek();
let users = await G.mongodb.collection('clslCrossUser').find({
ttltime: {$exists: false}
}, {
projection: {
"uid": 1,
"allStar": 1,
"info.player.cTime": 1
}
}).toArray();
// 筛选出所有王者分段 按照建号时间排序
let wzusers = users.filter(u => u.allStar >= this.star).sort((a, b) => a.info.player.cTime - b.info.player.cTime);
// 每100个玩家划分一个区间
let groups: { [group: string]: { st: number, et: number, users: string[] } } = {};
let group_num = wzusers.length / this.num;
// 非王者玩家
let remaining_users = users.filter(u => u.allStar < this.star);
if (group_num >= 1) {
let tt = parseInt(group_num + '')
for (let i = 1; i <= tt; i++) {
groups['group' + i] = {
et: wzusers[i * this.num - 1].info.player.cTime,
st: wzusers[(i - 1) * this.num].info.player.cTime,
users: wzusers.slice((i - 1) * this.num, i * this.num).map(u => u.uid),
}
if (i == 1) {
groups['group1'].st = 0
}
if (i == tt) {
groups['group' + i].et = G.time + 7 * 14 * 3600;
groups['group' + i].users = wzusers.slice((i - 1) * this.num).map(u => u.uid);
}
}
;
} else {
groups['group0'] = {
st: 0,
et: G.time + 7 * 14 * 3600,
users: wzusers.map(u => u.uid),
}
}
// 剩余玩家
for (let i = 0; i < remaining_users.length; i++) {
for (let group in groups) {
if (remaining_users[i].info.player.cTime >= groups[group].st && remaining_users[i].info.player.cTime <= groups[group].et) {
groups[group].users.push(remaining_users[i].uid);
}
}
}
// 更新玩家分组id
for (let group in groups) {
await G.mongodb.collection('clslCrossUser').updateMany({uid: {$in: groups[group].users}}, {$set: {group: group}});
}
// 记录分组
await G.mongodb.collection("clslCrossGroup").updateOne({week: week}, {$set: {groups: groups}}, {upsert: true});
// 初始化丛林猎手排行榜
G.mongodb.collection('clslCrossUser').find({
allStar: {$gte: this.star}, ttltime: {$exists: false}
}).toArray().then(users => {
users.forEach(u => {
new RankClslCross(u.group).addNew({
valArr: [u.allStar, u.info.player.power],
player: u.info.player,
roles: u.info.roles,
})
})
})
G.mongodb.collection('clslCrossUser').updateMany({}, { $set: { allStar: 0 } });
Rank.list.clslCross.clear();
await this.record();
}
}
export class SchedulerClslLocalCtor extends SchedulerClslCrossCtor {
id: schedulerType = 'clsl_local_ctor';
async start() {
G.mongodb.cPlayerInfo('clsl').updateMany({ type: 'clsl' }, { $set: { allStar: 0 } });
await this.record();
}
}
/**
*
*/
export class SchedulerClslPrize extends Scheduler {
id: schedulerType = 'clsl_prize';
time = G.gc.clsl_com.prizeTime;
name = '丛林猎手赛季发奖';
type: 'day' | 'week' = 'week';
time = G.gc.clsl_com.prizeTime;
star = Object.values(G.gc.clsl_dan).slice(-1)[0].allStar;
async read() {
await this.ctorStartTime();
@ -159,32 +46,41 @@ export class SchedulerClslPrize extends Scheduler {
}
async start() {
// 排名奖励
let group2users: { [group: string]: string[] } = {};
(await G.mongodb.collection('clslCrossUser').find({allStar: {$gte: this.star}}).toArray()).forEach(u => {
if (u.group in group2users) {
group2users[u.group].push(u.uid);
} else {
group2users[u.group] = [u.uid];
}
});
Object.values(group2users).forEach((uids, index) => {
G.gc.clsl_com.rankPrize.forEach((conf) => {
let players = uids.slice(conf.rank[0] - 1, conf.rank[1]);
players.forEach((uid, index) => {
EmailFun.addEmail({
uid: uid,
type: 'system',
title: G.gc.clsl_com.email_rank.title,
content: G.gc.clsl_com.email_rank.content,
prize: conf.prize,
contentInsertArr: [conf.rank[0] + index]
}, true);
// 段位奖励
let locals = await G.mongodb.cPlayerInfo('clsl').find({ type: 'clsl' }).toArray();
G.gc.clsl_com.danPrize.forEach((conf) => {
let sends = locals.filter(l => l.allStar >= conf.star[0]).map(s => s.uid);
// locals.remove(l => sends.includes(l.uid));
sends.forEach(uid => {
EmailFun.addEmail({
uid: uid,
type: 'system',
title: G.gc.clsl_com.email_dan.title,
content: G.gc.clsl_com.email_dan.content,
prize: conf.prize,
contentInsertArr: [conf.star]
});
});
})
// 排名奖励
let crossUids = (await G.clientCross.callApi('clsl/RankUids', {})).res.uids;
G.gc.clsl_com.rankPrize.forEach((conf) => {
let players = crossUids.slice(conf.rank[0] - 1, conf.rank[1]);
players.forEach((uid, index) => {
EmailFun.addEmail({
uid: uid,
type: 'system',
title: G.gc.clsl_com.email_rank.title,
content: G.gc.clsl_com.email_rank.content,
prize: conf.prize,
contentInsertArr: [conf.rank[0] + index]
});
});
});
await this.record();
}
}

View File

@ -406,15 +406,7 @@ const crossIndexs: Partial<{ [k in keyof MongodbCollections]: IndexDescription[]
],
clslCrossUser: [
{
key: { uid: 1 },
},
{
key: { ttltime: 1 }, expireAfterSeconds: 7 * 24 * 3600
}
],
clslCrossGroup: [
{
key: { week: 1 },
key: {uid: 1}, unique: true
}
],
rankList: [

View File

@ -2,7 +2,7 @@ import { GanHaiRed } from './api_s2c/ganhai/ApiOpen';
import { FriendManage } from './public/friend/manage';
import { GHManage } from './public/gonghui/manage';
import { JJCFun } from './public/jjc';
import { RankClslCross, RankClslCrossInit } from './public/rank/rank_clsl';
import { RankClslCross } from './public/rank/rank_clsl';
//import { RankHbzbJfsCross, RankHbzbJfsLocal, RankHbzbZbsCross } from './public/rank/rank_hbzb_jfs';
import { RankKbzz } from './public/rank/rank_kbzz';
import { RankPower } from './public/rank/rank_power';
@ -104,19 +104,18 @@ export async function startAfter() {
});
} else if (G.argv.serverType == 'cross') {
RankKbzz.init();
RankClslCrossInit();
new RankClslCross();
// new RankHbzbJfsCross().loadAllPlayer();
// new RankHbzbZbsCross();
new RankWzryCross();
new SchedulerKbzzGroup().init();
new SchedulerClslPrize().init();
new SchedulerClslCrossCtor().init();
new SchedulerClslLocalCtor ().init();
new Scheduler_hbzb_zbs_cross_clear().init();
//new Scheduler_hbzb_corss_reset();
new Scheduler_hbzb_zbs_cross_group().init();
new SchedulerClslCrossCtor().init();
new SchedulerWzryDlDstart().init();
new SchedulerWzryDlDjinji().init();
new SchedulerWzryZuanshiOne().init();

View File

@ -17,10 +17,4 @@ export type ResOpen = {
fightWinNum: number;
/**已领取的胜场奖励 */
recWinPrize: number[];
/**本期最高段位*/
curMaxStar: number;
/**段位奖励发放记录*/
danPrize: number[];
week?:number; // 返回给客户端用
};

View File

@ -13,8 +13,9 @@ export type ResOpen = {
};
export type rankType = 'jjc' | 'tanxian' | 'zhanli' | 'qjzzd' | 'hbzbLocal' | 'hbzbCross' | 'hbzbZbsCross'
| 'slzd1' | 'slzd2' | 'slzd3' | 'slzd4' | 'slzd5' | 'slzd6' | "clslCross"
| 'kbzz' | 'xszm' | 'zccg' | 'gbzl' | 'tujian' | 'wzryCross';
| 'slzd1' | 'slzd2' | 'slzd3' | 'slzd4' | 'slzd5' | 'slzd6'
| 'kbzz' | 'xszm' | 'clslCross'
| 'zccg' | 'gbzl' | 'tujian' | 'wzryCross';
export type rankTypeObj = {
type?: rankType[],

View File

@ -7253,31 +7253,6 @@ export const serviceProto: ServiceProto<ServiceType> = {
"type": "Number"
}
}
},
{
"id": 5,
"name": "curMaxStar",
"type": {
"type": "Number"
}
},
{
"id": 6,
"name": "danPrize",
"type": {
"type": "Array",
"elementType": {
"type": "Number"
}
}
},
{
"id": 7,
"name": "week",
"type": {
"type": "Number"
},
"optional": true
}
]
},
@ -20105,21 +20080,21 @@ export const serviceProto: ServiceProto<ServiceType> = {
"id": 13,
"type": {
"type": "Literal",
"literal": "clslCross"
"literal": "kbzz"
}
},
{
"id": 14,
"type": {
"type": "Literal",
"literal": "kbzz"
"literal": "xszm"
}
},
{
"id": 15,
"type": {
"type": "Literal",
"literal": "xszm"
"literal": "clslCross"
}
},
{