From 686f1fafc65cc8928120bd747f0abc5df2ea1c5d Mon Sep 17 00:00:00 2001 From: xcy Date: Sun, 31 Dec 2023 14:18:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=9B=E6=9E=97=E7=8C=8E=E6=89=8B?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_cross/clsl/ApiFindEnemy.ts | 44 ++- src/api_cross/clsl/ApiLog.ts | 2 +- src/api_cross/clsl/ApiRank.ts | 29 +- src/api_cross/clsl/ApiRankUids.ts | 9 - src/api_cross/clsl/ApiUpLoad.ts | 34 ++- src/api_s2c/conglinshoulie/ApiFind.ts | 101 +++++-- src/api_s2c/conglinshoulie/ApiOpen.ts | 16 +- src/api_s2c/rank/ApiOpen.ts | 19 +- src/cross/protocols/clsl/PtlFindEnemy.ts | 1 + src/cross/protocols/clsl/PtlRank.ts | 2 +- src/cross/protocols/clsl/PtlRankUids.ts | 9 - src/cross/protocols/serviceProto.ts | 126 ++++----- src/json/clsl_com.json5 | 33 +-- src/json/clsl_dan.json | 250 ++++++++++++++++++ src/jsonType.ts | 8 +- src/module/collection_clsl.ts | 7 +- src/module/mongodb.ts | 5 +- src/monopoly/protocols/serviceProto.ts | 6 +- src/public/fight.ts | 2 +- src/public/rank/rank.ts | 20 +- src/public/rank/rank_clsl.ts | 89 +++---- src/public/scheduler/scheduler.ts | 4 +- src/public/scheduler/scheduler_clsl.ts | 148 ++++++++--- .../protocols/conglinshoulie/PtlOpen.ts | 4 + src/shared/protocols/rank/PtlOpen.ts | 5 +- src/shared/protocols/serviceProto.ts | 23 +- 26 files changed, 715 insertions(+), 281 deletions(-) delete mode 100644 src/api_cross/clsl/ApiRankUids.ts delete mode 100644 src/cross/protocols/clsl/PtlRankUids.ts diff --git a/src/api_cross/clsl/ApiFindEnemy.ts b/src/api_cross/clsl/ApiFindEnemy.ts index e6ead85..743f42f 100644 --- a/src/api_cross/clsl/ApiFindEnemy.ts +++ b/src/api_cross/clsl/ApiFindEnemy.ts @@ -1,16 +1,48 @@ 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) { - 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(); + 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, + } + } + } call.succ({ - allStar: enemy?.allStar || my.allStar, - info: enemy?.info || formatNpcData(starConf.npc) + allStar: enemy.allStar, + info: enemy.info || formatNpcData(starConf.npc) }); } diff --git a/src/api_cross/clsl/ApiLog.ts b/src/api_cross/clsl/ApiLog.ts index 7b795f7..6f8b44b 100644 --- a/src/api_cross/clsl/ApiLog.ts +++ b/src/api_cross/clsl/ApiLog.ts @@ -4,7 +4,7 @@ import { FightFun } from '../../public/fight'; export default async function (call: ApiCall) { 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({ diff --git a/src/api_cross/clsl/ApiRank.ts b/src/api_cross/clsl/ApiRank.ts index a12970e..ada7663 100644 --- a/src/api_cross/clsl/ApiRank.ts +++ b/src/api_cross/clsl/ApiRank.ts @@ -1,10 +1,35 @@ 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) { + 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: [] } }) + } + + let a = await G.mongodb.collection('clslCrossUser').findOne({ + uid: call.req.uid + }); + + if (!a){ + call.succ({ rankList: [], myRank: { rank: -1, player: {}, valArr: [] } }) + } + + 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.list.clslCross.getRankList(call.req.gud.uid, { min, max })); + let { min, max } = Rank.pageToMin(page, offset) + call.succ(await rank.getRankList(call.req.uid, { min, max })); } \ No newline at end of file diff --git a/src/api_cross/clsl/ApiRankUids.ts b/src/api_cross/clsl/ApiRankUids.ts deleted file mode 100644 index 8854781..0000000 --- a/src/api_cross/clsl/ApiRankUids.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { ApiCall } from "tsrpc"; -import { ReqRankUids, ResRankUids } from "../../cross/protocols/clsl/PtlRankUids"; -import { Rank } from '../../public/rank/rank'; - -export default async function (call: ApiCall) { - // 返回排名的uids, 应用场景是定时器发送奖励,不分页。 - let uids = await Rank.list.clslCross.getRankListIdKeyAll() - call.succ({uids}); -} \ No newline at end of file diff --git a/src/api_cross/clsl/ApiUpLoad.ts b/src/api_cross/clsl/ApiUpLoad.ts index 7d40b57..57a47fd 100644 --- a/src/api_cross/clsl/ApiUpLoad.ts +++ b/src/api_cross/clsl/ApiUpLoad.ts @@ -1,23 +1,41 @@ 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) { 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 } - ); + { upsert: true, returnDocument: "after" } + )).value; + + let week = PublicShared.getToWeek(); + let group_time = G.gc.clsl_com.divideTime; + let week_zero_time = PublicShared.getToWeekMondayZeroTime(); - if (allStar != undefined && ops.info) { - Rank.list.clslCross.addNew({ - player: a.value.info.player, - valArr: [(await G.mongodb.collection('clslCrossUser').findOne({ uid: uid })).allStar] - }); + if (G.time > week_zero_time + group_time) { + 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] + }); + } } } \ No newline at end of file diff --git a/src/api_s2c/conglinshoulie/ApiFind.ts b/src/api_s2c/conglinshoulie/ApiFind.ts index e0436cd..2309485 100644 --- a/src/api_s2c/conglinshoulie/ApiFind.ts +++ b/src/api_s2c/conglinshoulie/ApiFind.ts @@ -1,43 +1,90 @@ -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 { 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"; export default async function (call: ApiCall) { 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); - let db = await clslDb().findOne({uid: call.uid, type: 'clsl'}); + // 未到开启时间 + 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 curStar = db?.allStar || 0; let useNum = db?.useFightNum || 0; let buyNum = db?.buyFightNum || 0; - let starConf = G.gc.clsl_dan[curStar] || Object.values(G.gc.clsl_dan).slice(-1)[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})).res; - let result = FightFun.fight([my, other.info]); - - if ((result.winSide != 0 && starConf.failCut) || result.winSide == 0) { - addStar(call, result.winSide == 0 ? 1 : -starConf.failCut, my); + // 战斗次数不足 + if (useNum >= buyNum + G.gc.clsl_com.fightNum) { + return call.errorCode(-2); } - result.initData[0].star = curStar - result.initData[1].star = other.allStar + // 自己战斗数据 + let my = await call.conn.getDefaultFightData(); - result.winSide == 0 && clslDb().updateOne({uid: call.uid, type: 'clsl'}, {$inc: {fightWinNum: 1}}); - clslDb().updateOne({uid: call.uid, type: 'clsl'}, {$inc: {useFightNum: 1}}); + // 获取一个对手 + 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 (result.winSide == 0) { + updata.$inc["fightWinNum"] = 1; + + // 首次达到某个段位 + if (curStar + 1 > curMaxStar) { + curMaxStar += 1; + updata.$inc["curMaxStar"] = 1; + } + } + + // 段位奖励邮件 + 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 + } + + // 发放邮件 + EmailFun.addEmail({ + uid: call.uid, + type: 'system', + title: title, + content: content, + prize: conf.prize, + }) + + 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 }); } \ No newline at end of file diff --git a/src/api_s2c/conglinshoulie/ApiOpen.ts b/src/api_s2c/conglinshoulie/ApiOpen.ts index e50e2b8..4824215 100644 --- a/src/api_s2c/conglinshoulie/ApiOpen.ts +++ b/src/api_s2c/conglinshoulie/ApiOpen.ts @@ -9,8 +9,8 @@ export default async function (call: ApiCall) { let db = await clslDb().findOne({ uid: call.uid, type: 'clsl' }); let { _id, uid, type, ...ops } = db || {} as WithId>>; + // 刷新 挑战次数、购买挑战次数、胜利次数任务 if (!db || ops?.refreshTime < PublicShared.getToDayZeroTime()) { - let change: Partial = { refreshTime: G.time, useFightNum: 0, @@ -30,6 +30,8 @@ export default async function (call: ApiCall) { call.succ({ allStar: ops?.allStar || 0, + danPrize: ops?.danPrize || [], + curMaxStar: ops?.curMaxStar || 0, buyFightNum: ops?.buyFightNum || 0, useFightNum: ops?.useFightNum || 0, fightWinNum: ops?.fightWinNum || 0, @@ -41,7 +43,15 @@ export function clslDb() { return G.mongodb.cPlayerInfo('clsl'); } -export async function addStar(call: ApiCall, star: number, info?: joinFightData) { - clslDb().updateOne({ uid: call.uid, type: 'clsl' }, { $inc: { allStar: star } }, { upsert: true }); +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 }); G.clientCross.callApi('clsl/UpLoad', { uid: call.uid, allStar: star, info: info || await call.conn.getDefaultFightData() }); } \ No newline at end of file diff --git a/src/api_s2c/rank/ApiOpen.ts b/src/api_s2c/rank/ApiOpen.ts index 9605fe4..a5bd1fe 100644 --- a/src/api_s2c/rank/ApiOpen.ts +++ b/src/api_s2c/rank/ApiOpen.ts @@ -4,6 +4,7 @@ import { Rank } from '../../public/rank/rank'; import { ReqOpen, ResOpen } from "../../shared/protocols/rank/PtlOpen"; import { getToper50RankInfo } from "../hbzb/jfs/fun"; import { getZbsRankList } from "../hbzb/zbs/fun"; +import { re } from "mathjs"; export default async function (call: ApiCall) { let obj = await rankOpenfun(call, call.req) @@ -24,7 +25,7 @@ export default async function (call: ApiCall) { export async function rankOpenfun(call, req: ReqOpen): Promise { let obj: ResOpen = {}; // 数组,兼容旧的参数 - if(req instanceof Array) { + if (req instanceof Array) { var types = req var page = 0 var offset = 1 @@ -39,7 +40,7 @@ export async function rankOpenfun(call, req: ReqOpen): Promise { 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); // 获取自己的排名 @@ -68,21 +69,23 @@ export async function rankOpenfun(call, req: ReqOpen): Promise { 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 resCallClsl = await G.clientCross.callApi('clsl/Rank', { gud: call.conn.gud, page, offset}); - //obj[type] = resCallClsl.res; + let res = await G.clientCross.callApi('clsl/Rank', { + uid: call.uid, page: page, offset: offset + }); + obj[type] = res.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": @@ -93,7 +96,7 @@ export async function rankOpenfun(call, req: ReqOpen): Promise { 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; } } diff --git a/src/cross/protocols/clsl/PtlFindEnemy.ts b/src/cross/protocols/clsl/PtlFindEnemy.ts index a3f5368..c7cb7df 100644 --- a/src/cross/protocols/clsl/PtlFindEnemy.ts +++ b/src/cross/protocols/clsl/PtlFindEnemy.ts @@ -3,6 +3,7 @@ import { joinFightData } from '../../../shared/fightControl/fightType'; export type ReqFindEnemy = { uid: string; + myStasr:number; }; export type ResFindEnemy = { diff --git a/src/cross/protocols/clsl/PtlRank.ts b/src/cross/protocols/clsl/PtlRank.ts index c240888..13a6a83 100644 --- a/src/cross/protocols/clsl/PtlRank.ts +++ b/src/cross/protocols/clsl/PtlRank.ts @@ -3,7 +3,7 @@ import { player } from '../../../shared/protocols/user/type'; export type ReqRank = { - gud: player; + uid: string; page?: number; offset?: number; }; diff --git a/src/cross/protocols/clsl/PtlRankUids.ts b/src/cross/protocols/clsl/PtlRankUids.ts deleted file mode 100644 index 9938f0d..0000000 --- a/src/cross/protocols/clsl/PtlRankUids.ts +++ /dev/null @@ -1,9 +0,0 @@ - - -export type ReqRankUids = { - -}; - -export type ResRankUids = { - uids: string[]; -}; \ No newline at end of file diff --git a/src/cross/protocols/serviceProto.ts b/src/cross/protocols/serviceProto.ts index e99cd52..f403b19 100644 --- a/src/cross/protocols/serviceProto.ts +++ b/src/cross/protocols/serviceProto.ts @@ -2,7 +2,6 @@ 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'; @@ -54,10 +53,6 @@ export interface ServiceType { req: ReqRank, res: ResRank }, - "clsl/RankUids": { - req: ReqRankUids, - res: ResRankUids - }, "clsl/UpLoad": { req: ReqUpLoad, res: ResUpLoad @@ -211,186 +206,181 @@ export const serviceProto: ServiceProto = { }, { "id": 3, - "name": "clsl/RankUids", - "type": "api" - }, - { - "id": 4, "name": "clsl/UpLoad", "type": "api" }, { - "id": 5, + "id": 4, "name": "email/DelCrossEmail", "type": "api" }, { - "id": 6, + "id": 5, "name": "email/GetCrossEmail", "type": "api" }, { - "id": 7, + "id": 6, "name": "hbzb/jfs/GetEnemy", "type": "api" }, { - "id": 8, + "id": 7, "name": "hbzb/jfs/GetLog", "type": "api" }, { - "id": 9, + "id": 8, "name": "hbzb/jfs/GetRankList", "type": "api" }, { - "id": 10, + "id": 9, "name": "hbzb/jfs/GetUser", "type": "api" }, { - "id": 11, + "id": 10, "name": "hbzb/GetUser", "type": "api" }, { - "id": 12, + "id": 11, "name": "hbzb/UpdateHbzbCrossUser", "type": "api" }, { - "id": 13, + "id": 12, "name": "hbzb/zbs/GetEnemy", "type": "api" }, { - "id": 14, + "id": 13, "name": "hbzb/zbs/GetLog", "type": "api" }, { - "id": 15, + "id": 14, "name": "hbzb/zbs/GetRankList", "type": "api" }, { - "id": 16, + "id": 15, "name": "hbzb/zbs/GetStatus", "type": "api" }, { - "id": 17, + "id": 16, "name": "hbzb/zbs/SendJjcTop", "type": "api" }, { - "id": 18, + "id": 17, "name": "kbzz/Apply", "type": "api" }, { - "id": 19, + "id": 18, "name": "kbzz/GetUser", "type": "api" }, { - "id": 20, + "id": 19, "name": "kbzz/GroupRank", "type": "api" }, { - "id": 21, + "id": 20, "name": "kbzz/Rank", "type": "api" }, { - "id": 22, + "id": 21, "name": "kbzz/Refresh", "type": "api" }, { - "id": 23, + "id": 22, "name": "kbzz/State", "type": "api" }, { - "id": 24, + "id": 23, "name": "kbzz/UpUser", "type": "api" }, { - "id": 25, + "id": 24, "name": "msg_cross/CrossChat", "type": "msg" }, { - "id": 26, + "id": 25, "name": "msg_cross/HbzbChangeRank", "type": "msg" }, { - "id": 27, + "id": 26, "name": "msg_cross/HbzbJfsLog", "type": "msg" }, { - "id": 28, + "id": 27, "name": "msg_cross/HbzbSendUser", "type": "msg" }, { - "id": 29, + "id": 28, "name": "msg_cross/HbzbZbsLog", "type": "msg" }, { - "id": 30, + "id": 29, "name": "wzry/BaoMing", "type": "api" }, { - "id": 31, + "id": 30, "name": "wzry/catFightLog", "type": "api" }, { - "id": 32, + "id": 31, "name": "wzry/DldRefre", "type": "api" }, { - "id": 33, + "id": 32, "name": "wzry/getJingCai", "type": "api" }, { - "id": 34, + "id": 33, "name": "wzry/Rank", "type": "api" }, { - "id": 35, + "id": 34, "name": "wzry/SetWzFight", "type": "api" }, { - "id": 36, + "id": 35, "name": "wzry/UpdateFight", "type": "api" }, { - "id": 37, + "id": 36, "name": "wzry/WzFightData", "type": "api" }, { - "id": 38, + "id": 37, "name": "wzry/WzFightGroup", "type": "api" }, { - "id": 39, + "id": 38, "name": "wzry/Wzzd", "type": "api" } @@ -405,6 +395,13 @@ export const serviceProto: ServiceProto = { "type": { "type": "String" } + }, + { + "id": 1, + "name": "myStasr", + "type": { + "type": "Number" + } } ] }, @@ -2753,10 +2750,9 @@ export const serviceProto: ServiceProto = { "properties": [ { "id": 0, - "name": "gud", + "name": "uid", "type": { - "type": "Reference", - "target": "../../shared/protocols/user/type/player" + "type": "String" } }, { @@ -2777,14 +2773,6 @@ export const serviceProto: ServiceProto = { } ] }, - "../../shared/protocols/user/type/player": { - "type": "IndexedAccess", - "index": "gud", - "objectType": { - "type": "Reference", - "target": "../../shared/protocols/user/PtlLogin/ResLogin" - } - }, "clsl/PtlRank/ResRank": { "type": "IndexedAccess", "index": "", @@ -2897,24 +2885,6 @@ export const serviceProto: ServiceProto = { } ] }, - "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": { @@ -3258,6 +3228,14 @@ export const serviceProto: ServiceProto = { } ] }, + "../../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": [ diff --git a/src/json/clsl_com.json5 b/src/json/clsl_com.json5 index def4d62..1595c97 100644 --- a/src/json/clsl_com.json5 +++ b/src/json/clsl_com.json5 @@ -1,18 +1,11 @@ { - //赛区划分 - 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, - //挑战时间 + //赛区划分按照周三23:50的时候王者玩家100个一组 + //赛区划分时间周三23:50 + divideTime: 258600, + //挑战时间周一08:00——周六22:00 fightTime: [28800, 511200], - //发奖时间 - prizeTime: 598200, + //发奖时间周六22:05 + prizeTime: 511500, //胜场奖励 fightWinPrize: [ { total: 5, prize: [{ a: 'attr', t: 'clsl_sd', n: 1 },{ a: 'item', t: '37', n: 1 }], star: 1 }, @@ -39,13 +32,13 @@ ], //段位奖励 danPrize: [ - { 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 }] } + { star: 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, prize: [{ a: 'item', t: '605', n:2 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '631', n:2 }] }, + { star: 29, prize: [{ a: 'item', t: '606', n:3 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '631', n:1 }] }, + { star: 21, prize: [{ a: 'item', t: '606', n:2 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:1000 }] }, + { star: 13, prize: [{ a: 'item', t: '606', n:1 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:800 }] }, + { star: 7, prize: [{ a: 'item', t: '29', n:10 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:600 }] }, + { star: 0, prize: [{ a: 'item', t: '29', n:5 },{ a: 'item', t: '29', n:5 },{ a: 'item', t: '39', n:400 }] } ], //王者排名邮件信息 email_rank: { diff --git a/src/json/clsl_dan.json b/src/json/clsl_dan.json index cf565d0..0ed85ab 100644 --- a/src/json/clsl_dan.json +++ b/src/json/clsl_dan.json @@ -18,6 +18,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 0, + 6 + ], "npc": 60001 }, "1": { @@ -39,6 +44,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 0, + 6 + ], "npc": 60002 }, "2": { @@ -60,6 +70,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 0, + 6 + ], "npc": 60003 }, "3": { @@ -81,6 +96,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 0, + 6 + ], "npc": 60004 }, "4": { @@ -102,6 +122,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 0, + 6 + ], "npc": 60005 }, "5": { @@ -123,6 +148,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 0, + 6 + ], "npc": 60006 }, "6": { @@ -144,6 +174,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 0, + 6 + ], "npc": 60007 }, "7": { @@ -165,6 +200,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 7, + 12 + ], "npc": 60008 }, "8": { @@ -186,6 +226,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 7, + 12 + ], "npc": 60009 }, "9": { @@ -207,6 +252,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 7, + 12 + ], "npc": 60010 }, "10": { @@ -228,6 +278,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 7, + 12 + ], "npc": 60011 }, "11": { @@ -249,6 +304,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 7, + 12 + ], "npc": 60012 }, "12": { @@ -270,6 +330,11 @@ "n": 100 } ], + "pro": 0.6, + "fighter": [ + 7, + 12 + ], "npc": 60013 }, "13": { @@ -291,6 +356,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 13, + 20 + ], "npc": 60014 }, "14": { @@ -312,6 +382,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 13, + 20 + ], "npc": 60015 }, "15": { @@ -333,6 +408,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 13, + 20 + ], "npc": 60016 }, "16": { @@ -354,6 +434,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 13, + 20 + ], "npc": 60017 }, "17": { @@ -375,6 +460,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 13, + 20 + ], "npc": 60018 }, "18": { @@ -396,6 +486,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 13, + 20 + ], "npc": 60019 }, "19": { @@ -417,6 +512,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 13, + 20 + ], "npc": 60020 }, "20": { @@ -438,6 +538,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 13, + 20 + ], "npc": 60021 }, "21": { @@ -459,6 +564,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 21, + 28 + ], "npc": 60022 }, "22": { @@ -480,6 +590,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 21, + 28 + ], "npc": 60023 }, "23": { @@ -501,6 +616,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 21, + 28 + ], "npc": 60024 }, "24": { @@ -522,6 +642,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 21, + 28 + ], "npc": 60025 }, "25": { @@ -543,6 +668,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 21, + 28 + ], "npc": 60026 }, "26": { @@ -564,6 +694,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 21, + 28 + ], "npc": 60027 }, "27": { @@ -585,6 +720,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 21, + 28 + ], "npc": 60028 }, "28": { @@ -606,6 +746,11 @@ "n": 100 } ], + "pro": 0.3, + "fighter": [ + 21, + 28 + ], "npc": 60029 }, "29": { @@ -627,6 +772,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60030 }, "30": { @@ -648,6 +798,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60031 }, "31": { @@ -669,6 +824,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60032 }, "32": { @@ -690,6 +850,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60033 }, "33": { @@ -711,6 +876,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60034 }, "34": { @@ -732,6 +902,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60035 }, "35": { @@ -753,6 +928,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60036 }, "36": { @@ -774,6 +954,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60037 }, "37": { @@ -795,6 +980,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60038 }, "38": { @@ -816,6 +1006,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 29, + 38 + ], "npc": 60039 }, "39": { @@ -837,6 +1032,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60040 }, "40": { @@ -858,6 +1058,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60041 }, "41": { @@ -879,6 +1084,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60042 }, "42": { @@ -900,6 +1110,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60043 }, "43": { @@ -921,6 +1136,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60044 }, "44": { @@ -942,6 +1162,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60045 }, "45": { @@ -963,6 +1188,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60046 }, "46": { @@ -984,6 +1214,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60047 }, "47": { @@ -1005,6 +1240,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60048 }, "48": { @@ -1026,6 +1266,11 @@ "n": 100 } ], + "pro": 0.15, + "fighter": [ + 39, + 48 + ], "npc": 60049 }, "49": { @@ -1047,6 +1292,11 @@ "n": 100 } ], + "pro": 0, + "fighter": [ + 39, + 49 + ], "npc": 60050 } } \ No newline at end of file diff --git a/src/jsonType.ts b/src/jsonType.ts index c953d75..59a07a6 100644 --- a/src/jsonType.ts +++ b/src/jsonType.ts @@ -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, 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, "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,7 +122,11 @@ type gc_clsl_dan = k_v<{ /** 战斗奖励 */ 'fightPrize': { "a": string, "t": string, "n": number, [x: string]: any }[] /** 机器人 */ - 'npc': number + 'npc': number, + /** 随机机器人概率*/ + 'pro':number + /** 对手范围 */ + 'fighter':number[] }>; type gc_com = k_v<{ diff --git a/src/module/collection_clsl.ts b/src/module/collection_clsl.ts index 39767cd..e4de710 100644 --- a/src/module/collection_clsl.ts +++ b/src/module/collection_clsl.ts @@ -6,4 +6,9 @@ export type CollectionCllsCrossUser = { area: number; allStar: number; info: joinFightData; -}; \ No newline at end of file +}; + +export type CollectionCllsCrossGroup = { + week: string; + groups: { [group: string]: { st: number, et: number } }; +} \ No newline at end of file diff --git a/src/module/mongodb.ts b/src/module/mongodb.ts index e5c920e..8bcacc7 100644 --- a/src/module/mongodb.ts +++ b/src/module/mongodb.ts @@ -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 {CollectionCllsCrossUser} from './collection_clsl'; +import {CollectionCllsCrossGroup, CollectionCllsCrossUser} from './collection_clsl'; import {CollectionCrosskv} from './collection_crosskv'; import {CollectionDayPay} from './collection_dayPay'; import {CollectionDxlt} from './collection_dxlt'; @@ -115,7 +115,8 @@ export type MongodbCollections = { any: { type: string, data: any[]; }; zhanling: CollectionZhanLing; - clslCrossUser: CollectionCllsCrossUser; + clslCrossGroup: CollectionCllsCrossGroup; + clslCrossUser: CollectionCllsCrossUser & { group: string }; lingzhulaixi: CollectionLingZhuLaiXi; wzry_user_cross: CollectionWzryCross; wzry_fight: CollectionWzryCrossFight; diff --git a/src/monopoly/protocols/serviceProto.ts b/src/monopoly/protocols/serviceProto.ts index 886f4d6..3d8d36f 100644 --- a/src/monopoly/protocols/serviceProto.ts +++ b/src/monopoly/protocols/serviceProto.ts @@ -709,21 +709,21 @@ export const serviceProto: ServiceProto = { "id": 13, "type": { "type": "Literal", - "literal": "kbzz" + "literal": "clslCross" } }, { "id": 14, "type": { "type": "Literal", - "literal": "xszm" + "literal": "kbzz" } }, { "id": 15, "type": { "type": "Literal", - "literal": "clslCross" + "literal": "xszm" } }, { diff --git a/src/public/fight.ts b/src/public/fight.ts index 2e99911..b2029a4 100644 --- a/src/public/fight.ts +++ b/src/public/fight.ts @@ -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'] + 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}) diff --git a/src/public/rank/rank.ts b/src/public/rank/rank.ts index 634f4a5..fe7ed27 100644 --- a/src/public/rank/rank.ts +++ b/src/public/rank/rank.ts @@ -108,8 +108,12 @@ export abstract class Rank { return this.getType(); } - constructor() { + constructor(param?: any) { + // 将param属性赋值给this + param && Object.assign(this, param); Rank.list[this.getType() as string] = this; + + // 初始化排行榜 this.cotr(); } @@ -135,7 +139,7 @@ export abstract class Rank { //将db里的数据,写入到 rank:xxx:sort里 //写入的单条数据为: {uid:score} - this.db.find({ type: this.type }, { + this.db.find({ type: this.type }, { projection: { "idKey": 1, "type": 1, @@ -263,7 +267,7 @@ export abstract class Rank { } return item; }) - if(ghid.length > 0){ + if (ghid.length > 0) { let ghinfo = await G.mongodb.collection("gonghui").find( { _id: { $in: ghid } }, { projection: { name: 1 } } ).toArray(); @@ -400,10 +404,10 @@ export abstract class Rank { // 清空相关rank数据 async clear() { - this.queue.enqueue(async () => { - // G.redis.rawDel(this.getRedisKey) - G.redis.rawDel(this.getRedisKeySort); - await this.db.deleteMany({ type: this.type }); - }); + // this.queue.enqueue(async () => { + // G.redis.rawDel(this.getRedisKey) + G.redis.rawDel(this.getRedisKeySort); + this.db.deleteMany({ type: this.type }); + // }); } } \ No newline at end of file diff --git a/src/public/rank/rank_clsl.ts b/src/public/rank/rank_clsl.ts index 551c184..3849146 100644 --- a/src/public/rank/rank_clsl.ts +++ b/src/public/rank/rank_clsl.ts @@ -1,58 +1,53 @@ import { rankType } from '../../shared/protocols/rank/PtlOpen'; import { rankInfo } from '../../shared/protocols/type'; -import { player } from '../../shared/protocols/user/type'; +import { PublicShared } from '../../shared/public/public'; import { Rank } from './rank'; export class RankClslCross extends Rank { - - countMaxNum = 99999; + group: string; minStar = Object.values(G.gc.clsl_dan)[Object.keys(G.gc.clsl_dan).length - 1].allStar; - 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] - // } - // }; - // } - + 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 addNew(info: rankInfo) { - 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]) - } - } - }); + // 积分大于配置的最小参数,更新数据 + 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); + }) } } \ No newline at end of file diff --git a/src/public/scheduler/scheduler.ts b/src/public/scheduler/scheduler.ts index a8b93a7..438360c 100644 --- a/src/public/scheduler/scheduler.ts +++ b/src/public/scheduler/scheduler.ts @@ -13,9 +13,9 @@ export type schedulerType = | 'hbzb_cross_reset' | 'hbzb_zbs_ready' | 'kbzz' - | 'clsl_cross_ctor' - | 'clsl_local_ctor' | 'clsl_prize' + | 'clsl_cross_ctor' + | 'clsl_cross_group' | 'wzry_autobaoming' | 'wzry_dldstart' | 'wzry_dldjinji' diff --git a/src/public/scheduler/scheduler_clsl.ts b/src/public/scheduler/scheduler_clsl.ts index dfc83b4..73936bf 100644 --- a/src/public/scheduler/scheduler_clsl.ts +++ b/src/public/scheduler/scheduler_clsl.ts @@ -1,12 +1,16 @@ +import { PublicShared } from '../../shared/public/public'; import { EmailFun } from '../email'; -import { Rank } from '../rank/rank'; +import { RankClslCross, RankClslCrossInit } from '../rank/rank_clsl'; import { Scheduler, schedulerType } from './scheduler'; - -export class SchedulerClslCrossCtor extends Scheduler { +/** + * 丛林猎手赛季重置 +*/ +export class SchedulerClslLocalCtor extends Scheduler { id: schedulerType = 'clsl_cross_ctor'; - time = G.gc.clsl_com.divideTime; - name = '丛林猎手赛季初始化'; + + time = 0; + name = '丛林猎手赛季重置'; type: 'day' | 'week' = 'week'; async read() { @@ -15,30 +19,101 @@ export class SchedulerClslCrossCtor extends Scheduler { } async start() { + let week = PublicShared.getToWeek( + PublicShared.getToWeekMondayZeroTime(G.time - 3600) + ); - G.mongodb.collection('clslCrossUser').updateMany({}, { $set: { allStar: 0 } }); - Rank.list.clslCross.clear(); + // 修改clslCrossUser表中的uid为del_uid_week 并且 设置ttltime为当前时间 + await G.mongodb.collection('clslCrossUser').updateMany( + {}, { $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'; + time = G.gc.clsl_com.divideTime; + name = '丛林猎手赛季区间划分 周四00:00'; + type: 'day' | 'week' = 'week'; + star = Object.values(G.gc.clsl_dan).slice(-1)[0].allStar; -export class SchedulerClslLocalCtor extends SchedulerClslCrossCtor { - id: schedulerType = 'clsl_local_ctor'; + async read() { + await this.ctorStartTime(); + this.isReady = false; + } async start() { + let week = PublicShared.getToWeek(); + let users = await G.mongodb.collection('clslCrossUser').find({}, { + projection: { + "uid": 1, + "allStar": 1, + "info.player.cTime": 1 + } + }).toArray(); - G.mongodb.cPlayerInfo('clsl').updateMany({ type: 'clsl' }, { $set: { allStar: 0 } }); + // 筛选出所有王者分段 按照建号时间排序 + 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[] } } = {}; + for (let i = 0; i < wzusers.length / 100; i++) { + groups['group' + i] = { + st: wzusers[i * 100].info.player.cTime, + et: wzusers[(i + 1) * 100 - 1].info.player.cTime, + users: wzusers.slice(i * 100, (i + 1) * 100).map(u => u.uid), + } + } + + // 剩余玩家 + let remaining_users = [].concat(wzusers.slice((wzusers.length / 100) * 100)); // 王者剩余玩家 + remaining_users = remaining_users.concat(users.filter(u => u.allStar < this.star)); // 非王者剩余玩家 + 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 }); + + // 初始化丛林猎手排行榜 + await RankClslCrossInit() 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(); @@ -46,41 +121,32 @@ 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]; + } + }); - // 段位奖励 - 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] + 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 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(); } } \ No newline at end of file diff --git a/src/shared/protocols/conglinshoulie/PtlOpen.ts b/src/shared/protocols/conglinshoulie/PtlOpen.ts index 356c588..d506509 100644 --- a/src/shared/protocols/conglinshoulie/PtlOpen.ts +++ b/src/shared/protocols/conglinshoulie/PtlOpen.ts @@ -17,4 +17,8 @@ export type ResOpen = { fightWinNum: number; /**已领取的胜场奖励 */ recWinPrize: number[]; + /**本期最高段位*/ + curMaxStar: number; + /**段位奖励发放记录*/ + danPrize: number[]; }; \ No newline at end of file diff --git a/src/shared/protocols/rank/PtlOpen.ts b/src/shared/protocols/rank/PtlOpen.ts index d85d8d8..f878176 100644 --- a/src/shared/protocols/rank/PtlOpen.ts +++ b/src/shared/protocols/rank/PtlOpen.ts @@ -13,9 +13,8 @@ export type ResOpen = { }; export type rankType = 'jjc' | 'tanxian' | 'zhanli' | 'qjzzd' | 'hbzbLocal' | 'hbzbCross' | 'hbzbZbsCross' - | 'slzd1' | 'slzd2' | 'slzd3' | 'slzd4' | 'slzd5' | 'slzd6' - | 'kbzz' | 'xszm' | 'clslCross' - | 'zccg' | 'gbzl' | 'tujian' | 'wzryCross'; + | 'slzd1' | 'slzd2' | 'slzd3' | 'slzd4' | 'slzd5' | 'slzd6' | "clslCross" + | 'kbzz' | 'xszm' | 'zccg' | 'gbzl' | 'tujian' | 'wzryCross'; export type rankTypeObj = { type?: rankType[], diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index 57b3262..723937c 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -7253,6 +7253,23 @@ export const serviceProto: ServiceProto = { "type": "Number" } } + }, + { + "id": 5, + "name": "curMaxStar", + "type": { + "type": "Number" + } + }, + { + "id": 6, + "name": "danPrize", + "type": { + "type": "Array", + "elementType": { + "type": "Number" + } + } } ] }, @@ -20073,21 +20090,21 @@ export const serviceProto: ServiceProto = { "id": 13, "type": { "type": "Literal", - "literal": "kbzz" + "literal": "clslCross" } }, { "id": 14, "type": { "type": "Literal", - "literal": "xszm" + "literal": "kbzz" } }, { "id": 15, "type": { "type": "Literal", - "literal": "clslCross" + "literal": "xszm" } }, {