From 7d8dff97992a0dff684bcc7cbcedfe1a2393a2dd Mon Sep 17 00:00:00 2001 From: "DESKTOP-15R5JU0\\legu" Date: Fri, 17 Nov 2023 21:55:32 +0800 Subject: [PATCH] init --- src/api_cross/clsl/ApiRank.ts | 5 +- src/api_cross/clsl/ApiRankUids.ts | 7 +- src/api_cross/hbzb/jfs/ApiGetEnemy.ts | 45 +- src/api_cross/hbzb/jfs/ApiGetRankList.ts | 11 +- src/api_cross/hbzb/zbs/ApiGetEnemy.ts | 41 +- src/api_cross/hbzb/zbs/ApiGetRankList.ts | 5 +- src/api_cross/kbzz/ApiRank.ts | 6 +- src/api_cross/wzry/ApiRank.ts | 5 +- src/api_s2c/hbzb/jfs/ApiRefresh.ts | 2 +- src/api_s2c/rank/ApiOpen.ts | 43 +- src/api_s2c/task/ApiFinsh.ts | 6 +- src/api_s2c/wzry/ApiUpdateFight.ts | 4 +- src/cross/protocols/clsl/PtlRank.ts | 2 + src/cross/protocols/hbzb/jfs/PtlGetEnemy.ts | 2 + .../protocols/hbzb/jfs/PtlGetRankList.ts | 2 + .../protocols/hbzb/zbs/PtlGetRankList.ts | 5 +- src/cross/protocols/kbzz/PtlRank.ts | 2 + src/cross/protocols/serviceProto.ts | 93 ++- src/cross/protocols/wzry/PtlRank.ts | 2 + src/event.ts | 13 +- src/extends.ts | 1 - src/global.ts | 2 + src/json/guide.json | 1 + src/json/guideConfig.json | 725 ++++++++++++------ src/json/task.json | 5 + src/public/jjc.ts | 2 +- src/public/player.ts | 34 +- src/public/rank/rank.ts | 124 +-- src/public/rank/rank_clsl.ts | 27 +- src/public/rank/rank_hbzb_jfs.ts | 78 +- src/public/rank/rank_kbzz.ts | 7 +- src/public/rank/rank_power.ts | 4 +- src/public/rank/rank_qjzzd.ts | 5 +- src/public/rank/rank_slzd.ts | 7 +- src/public/rank/rank_tanxian.ts | 4 +- src/public/rank/rank_tujian.ts | 4 +- src/public/rank/rank_wzry.ts | 12 +- src/public/rank/rank_xszm.ts | 4 +- src/public/rank/rank_zccg.ts | 4 +- src/public/scheduler/scheduler.ts | 2 +- src/public/scheduler/scheduler_hbzb.ts | 7 +- src/public/task.ts | 38 +- src/public/wzry.ts | 41 +- src/setRedis.ts | 32 +- src/shared/fightControl/fightCntrol.ts | 1 + src/shared/protocols/rank/PtlOpen.ts | 10 +- src/shared/protocols/serviceProto.ts | 58 +- 47 files changed, 1049 insertions(+), 491 deletions(-) diff --git a/src/api_cross/clsl/ApiRank.ts b/src/api_cross/clsl/ApiRank.ts index ff8eeff..755a9b5 100644 --- a/src/api_cross/clsl/ApiRank.ts +++ b/src/api_cross/clsl/ApiRank.ts @@ -3,5 +3,8 @@ import { ReqRank, ResRank } from "../../cross/protocols/clsl/PtlRank"; import { Rank } from '../../public/rank/rank'; export default async function (call: ApiCall) { - call.succ(await Rank.list.clslCross.getRankList(call.req.gud.uid, call.req.gud)); + 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, { gud:call.req.gud, min, max })); } \ No newline at end of file diff --git a/src/api_cross/clsl/ApiRankUids.ts b/src/api_cross/clsl/ApiRankUids.ts index 4530770..8854781 100644 --- a/src/api_cross/clsl/ApiRankUids.ts +++ b/src/api_cross/clsl/ApiRankUids.ts @@ -3,8 +3,7 @@ import { ReqRankUids, ResRankUids } from "../../cross/protocols/clsl/PtlRankUids import { Rank } from '../../public/rank/rank'; export default async function (call: ApiCall) { - let rankList = await Rank.list.clslCross.getRankListAll() - call.succ({ - uids: rankList.map(li => li.player.uid) - }); + // 返回排名的uids, 应用场景是定时器发送奖励,不分页。 + let uids = await Rank.list.clslCross.getRankListIdKeyAll() + call.succ({uids}); } \ No newline at end of file diff --git a/src/api_cross/hbzb/jfs/ApiGetEnemy.ts b/src/api_cross/hbzb/jfs/ApiGetEnemy.ts index 7ea9a6b..0d7f998 100644 --- a/src/api_cross/hbzb/jfs/ApiGetEnemy.ts +++ b/src/api_cross/hbzb/jfs/ApiGetEnemy.ts @@ -3,41 +3,58 @@ import { ReqGetEnemy, ResGetEnemy } from "../../../cross/protocols/hbzb/jfs/PtlG import { Rank } from '../../../public/rank/rank'; import { formatNpcData } from '../../../shared/fightControl/fightFun'; import { PublicShared } from "../../../shared/public/public"; +import { rankInfo } from "../../../shared/protocols/type"; export default async function (call: ApiCall) { - // TODO - let allPlayers = Rank.list.hbzbCross.allPlayer; - let user = allPlayers[call.req.uid]; - if (!user) return call.succ({ enemy: [] }); + // TODO ### debug allPlayer���������� + let allPlayers:rankInfo[] = await Rank.list.hbzbCross.getRankListRange(); + let user:rankInfo = await Rank.list.hbzbCross.getRankData(call.req.uid); + if(!user?.player) { + // 写入默认参数到数据库 + user = { + player: call.req.gud, + valArr: [1000] + } + await Rank.list.hbzbCross.addNew(user) + } + // if(!user?.player) return call.succ({ enemy: [] }); let conf = call.req.auto ? G.gc.hbzb.jfsMatchingAuto : G.gc.hbzb.jfsMatchingHand; let rang = conf.map(val => { - return [PublicShared.eval(val.min, { zhanli: user.data.player.power }), PublicShared.eval(val.max, { zhanli: user.data.player.power })] as [number, number]; + return [PublicShared.eval(val.min, { zhanli: user.player.power }), PublicShared.eval(val.max, { zhanli: user.player.power })] as [number, number]; }); let min = rang.slice(-1)[0][0]; let max = rang[0][1]; - let players = Object.values(allPlayers).filter(p => { - return p.data.player.power >= min && p.data.player.power <= max && p.data.player.uid != call.req.uid; + let players = allPlayers.filter(p => { + return p.player.power >= min && p.player.power <= max && p.player.uid != call.req.uid; }); let select: string[] = []; let enemy = rang.map((r, index) => { - let es = players.filter(p => p.data.player.power >= r[0] && p.data.player.power <= r[1] && !select.includes(p.data.player.uid)); + let es = players.filter(p => p.player.power >= r[0] && p.player.power <= r[1] && !select.includes(p.player.uid)); if (es.length > 0) { - let { uid, ...ops } = es.random(); - select.push(uid); - return ops; + let ops = es.random(); + if(ops) { + let data:any = { + data: { + player: ops.player, + roles: ops.roles + }, + jifen: ops.valArr[0] + } + return data; + } } else { return { - data: getNpc(user.data.player.lv, index), + data: getNpc(user.player.lv, index), jifen: 1000 }; } }); - call.succ({ enemy: enemy }); } function getNpc(lv: number, index: number) { let rang = G.gc.hbzb.jfsRefreshNpcId.find(v => lv >= v.lvs[0] && lv <= v.lvs[1]); - return formatNpcData(rang.npcs[index].random()); + let res = formatNpcData(rang.npcs[index].random()) + return res; } \ No newline at end of file diff --git a/src/api_cross/hbzb/jfs/ApiGetRankList.ts b/src/api_cross/hbzb/jfs/ApiGetRankList.ts index 90718c9..50e1322 100644 --- a/src/api_cross/hbzb/jfs/ApiGetRankList.ts +++ b/src/api_cross/hbzb/jfs/ApiGetRankList.ts @@ -3,7 +3,12 @@ import { ReqGetRankList, ResGetRankList } from "../../../cross/protocols/hbzb/jf import { Rank } from '../../../public/rank/rank'; export default async function (call: ApiCall) { - let rankList = await Rank.list.hbzbCross.getRankListAll() - // TODO - call.succ({ rankList: rankList, jifen: Rank.list.hbzbCross.allPlayer[call.req.uid]?.jifen || 1000 }); + let page = call.req.page || 0 + let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题 + let {min, max} = Rank.pageToMin(page, offset) + let rankList = await Rank.list.hbzbCross.getRankListRange(min, max) + let myRankData = await Rank.list.hbzbCross.getRankData(call.conn.uid) + let jifen = myRankData?.valArr ? myRankData?.valArr[0] : 1000 + // TODO ### debug + call.succ({ rankList: rankList, jifen: jifen }); } \ No newline at end of file diff --git a/src/api_cross/hbzb/zbs/ApiGetEnemy.ts b/src/api_cross/hbzb/zbs/ApiGetEnemy.ts index 757c5c2..41ac454 100644 --- a/src/api_cross/hbzb/zbs/ApiGetEnemy.ts +++ b/src/api_cross/hbzb/zbs/ApiGetEnemy.ts @@ -1,22 +1,43 @@ import {ApiCall} from "tsrpc"; import {ReqGetEnemy, ResGetEnemy} from "../../../cross/protocols/hbzb/zbs/PtlGetEnemy"; import {Rank} from '../../../public/rank/rank'; +import { rankInfo } from "../../../shared/protocols/type"; export default async function (call: ApiCall) { - let list = await Rank.list.hbzbZbsCross.getRankListAll(); - let enemys = list.slice(0, 10); - let myRank = list.findIndex(e => e.player.uid == call.req.uid); + let enemys:rankInfo[] = await Rank.list.hbzbZbsCross.getRankListRange(0, 10); + enemys.forEach((_, i) => { + enemys[i].rank = i + }) + let myRank:number = await Rank.list.hbzbZbsCross.getRankSortByOne(call.req.uid); + // 随机匹配其它对手 + let rankArr = [] if (myRank > 8) { - if (myRank == 9) enemys.push(list.slice(10, 5).random()); - else if (myRank == 10) enemys.push(list.slice(11, 5).random()); - else { - let two = list.slice(10, myRank - 10).shuffle(); - enemys.push(...two.slice(0, 2)); - enemys.push(list.slice(myRank + 1, 5).random()); + if(myRank < 10) { + let min = myRank + 1 + let max = myRank + 6 + let randomRank = Math.round(Math.random() * (max - min) + min) + rankArr.push(randomRank) + } + if (myRank > 10) { + let min = 10 + let max = myRank + let arr = [] + for(let i = 0; i < 5 || arr.length >= 3; i++) { + let randomRank = Math.round(Math.random() * (max - min) + min) + if(arr.indexOf(randomRank) == -1) arr.push(randomRank) + } } } + // 写入随机的对手 + for(let rank of rankArr) { + let rankRange = await Rank.list.hbzbZbsCross.getRankSortDataByOne(rank); + if(rankRange) { + rankRange.rank = rank + enemys.push(rankRange) + } + } call.succ({ enemy: enemys.map((e, i) => ({ @@ -24,7 +45,7 @@ export default async function (call: ApiCall) { player: e.player, roles: e.roles }, - rank: i + rank: e.rank })), rank: myRank }); diff --git a/src/api_cross/hbzb/zbs/ApiGetRankList.ts b/src/api_cross/hbzb/zbs/ApiGetRankList.ts index aa01d09..5735cf0 100644 --- a/src/api_cross/hbzb/zbs/ApiGetRankList.ts +++ b/src/api_cross/hbzb/zbs/ApiGetRankList.ts @@ -3,6 +3,9 @@ import { ReqGetRankList, ResGetRankList } from "../../../cross/protocols/hbzb/zb import { Rank } from '../../../public/rank/rank'; export default async function (call: ApiCall) { - let rankList = await Rank.list.hbzbZbsCross.getRankListAll(); + let page = call.req.page || 0 + let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题 + let {min, max} = Rank.pageToMin(page, offset) + let rankList = await Rank.list.hbzbZbsCross.getRankListRange(min, max); call.succ({ rankList: rankList }); } \ No newline at end of file diff --git a/src/api_cross/kbzz/ApiRank.ts b/src/api_cross/kbzz/ApiRank.ts index 237b8e2..b5df141 100644 --- a/src/api_cross/kbzz/ApiRank.ts +++ b/src/api_cross/kbzz/ApiRank.ts @@ -2,14 +2,18 @@ import { ApiCall } from "tsrpc"; import { ReqRank, ResRank } from "../../cross/protocols/kbzz/PtlRank"; import { RankKbzz } from '../../public/rank/rank_kbzz'; + export default async function (call: ApiCall) { + let page = call.req.page || 0 + let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题 let _cunzai = await G.mongodb.collection('kbzzGroupTroop').findOne({}) if (!_cunzai) { return call.error('', { code: -1, message: '功能未开放' }) } let db = await G.mongodb.collection('kbzzGroupUser').findOne({ uid: call.req.uid }); let group = db?.group || 0; - let rank = await RankKbzz.groupList[group].getRankList(call.req.uid); + let {min, max} = RankKbzz.pageToMin(page, offset) + let rank = await RankKbzz.groupList[group].getRankList(call.req.uid, { min, max }); call.succ({ ...rank diff --git a/src/api_cross/wzry/ApiRank.ts b/src/api_cross/wzry/ApiRank.ts index f31e925..f919ccb 100644 --- a/src/api_cross/wzry/ApiRank.ts +++ b/src/api_cross/wzry/ApiRank.ts @@ -9,7 +9,10 @@ import { WangZheRongYaofun } from "../../public/wzry"; import { PublicShared } from "../../shared/public/public"; export default async function (call: ApiCall) { - let _r = await Rank.list.wzryCross.getRankList(call.req.gud.uid, call.req.gud) + let page = call.req.page || 0 + let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题 + let {min, max} = Rank.pageToMin(page, offset) + let _r = await Rank.list.wzryCross.getRankList(call.req.gud.uid, {gud: call.req.gud, min, max}) call.succ(_r); } \ No newline at end of file diff --git a/src/api_s2c/hbzb/jfs/ApiRefresh.ts b/src/api_s2c/hbzb/jfs/ApiRefresh.ts index 09c496f..f01784c 100644 --- a/src/api_s2c/hbzb/jfs/ApiRefresh.ts +++ b/src/api_s2c/hbzb/jfs/ApiRefresh.ts @@ -16,7 +16,7 @@ export default async function (call: ApiCall) { let change: ResRefresh['change'] = {}; change.useRefreshNum = dbData.data.useRefreshNum + 1; - let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', { uid: call.uid, auto: false }); + let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', { uid: call.uid, auto: false, gud: call.conn.gud}); change.enemy = callRes.res.enemy.map(e => { return { ...e, result: null }; }); await G.mongodb.cPlayerInfo('hbzb').updateOne( diff --git a/src/api_s2c/rank/ApiOpen.ts b/src/api_s2c/rank/ApiOpen.ts index 9be5797..f02dc8a 100644 --- a/src/api_s2c/rank/ApiOpen.ts +++ b/src/api_s2c/rank/ApiOpen.ts @@ -4,21 +4,42 @@ import { Rank } from '../../public/rank/rank'; import { ReqOpen, ResOpen } from "../../shared/protocols/rank/PtlOpen"; export default async function (call: ApiCall) { - let obj = await rankOpenfun(call, call.req) call.succ(obj); } -// ### debug 参数需调整,req数组应使用types字段接收,需增加分页参数,需前端配合,优化redis存储暂不改。 +// 参数需调整,req数组应使用types字段接收,需增加分页参数,需前端配合,优化redis存储暂不改。 +/** + * + * @param call + * @param req 旧模式兼容,保留数组的判断 + * @param req.type 查询数据的类型 + * @param req.page 页码,从0开始 + * @param req.offset 每页条数 + * @returns + */ export async function rankOpenfun(call, req: ReqOpen): Promise { let obj: ResOpen = {}; + // 数组,兼容旧的参数 + if(req instanceof Array) { + var types = req + var page = 0 + var offset = 1 - for (let type of req) { + } else { + var types = req.type + var page = req.page || 0 + var offset = req.offset || 1 + } + // 取排行范围 + // 应用规则:接口类(如跨服)统一使用page&offset, 接口内部需要min&max自行转换; 调用函数使用min,max + const { min, max } = Rank.pageToMin(page, offset) + for (let type of types) { switch (type) { case 'jjc': // 获取前50名ranklist数据 - let rankList = await JJCFun.getRankList(0, 50); + let rankList = await JJCFun.getRankList(min, max); // 获取自己的排名 let myRank = await JJCFun.getPlayerRank(call.uid) // 获取自己的rank信息 @@ -34,10 +55,10 @@ export async function rankOpenfun(call, req: ReqOpen): Promise { }; break; case 'hbzbCross': - obj[type] = await Rank.list.hbzbLocal.getCrossRankList(call.uid); + obj[type] = await Rank.list.hbzbLocal.getCrossRankList(call.uid, page, offset); break; case 'hbzbZbsCross': - obj[type] = await Rank.list.hbzbLocal.getZbsRankList(call.uid); + obj[type] = await Rank.list.hbzbLocal.getZbsRankList(call.uid, page, offset); break; case 'slzd1': case 'slzd2': @@ -45,25 +66,25 @@ 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); + 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 }); + 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 }); + 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 }); + let resCallWzry = await G.clientCross.callApi('wzry/Rank', { gud: call.conn.gud, page, offset}); obj[type] = resCallWzry.res; break; default: - obj[type] = await Rank.list[type].getRankList(call.uid); + obj[type] = await Rank.list[type].getRankList(call.uid, {min, max}); break; } } diff --git a/src/api_s2c/task/ApiFinsh.ts b/src/api_s2c/task/ApiFinsh.ts index b7b4cb1..8cdf8db 100644 --- a/src/api_s2c/task/ApiFinsh.ts +++ b/src/api_s2c/task/ApiFinsh.ts @@ -37,13 +37,14 @@ export default async function (call: ApiCall) { // 检测生成后续任务 let _follow = _con["followtask"] - let newTask: taskType + let newTask = {} if (_follow) { // 检测生成新任务 newTask = await TaskFun.setTaskInfo(call, _follow, _task) } // 设置数据 await TaskFun.setTask(call.uid, {taskid: taskid}, {finish: 1}) + let _prize = await PlayerFun.sendPrize(call, _con["prize"]) _task["finish"] = 1 @@ -53,7 +54,8 @@ export default async function (call: ApiCall) { newtask: newTask } - // G.server.sendMsgByUid(call.uid, 'msg_s2c/TaskChange', newTask) HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']) call.succ(data); + + call.conn.sendMsg('msg_s2c/TaskChange', {..._task, finish: 1}) } \ No newline at end of file diff --git a/src/api_s2c/wzry/ApiUpdateFight.ts b/src/api_s2c/wzry/ApiUpdateFight.ts index 4770b16..1f2c20f 100644 --- a/src/api_s2c/wzry/ApiUpdateFight.ts +++ b/src/api_s2c/wzry/ApiUpdateFight.ts @@ -11,8 +11,8 @@ export default async function (call: ApiCall) { let canChangeZr = G.gc.wangzherongyao.wangzhe.noupdate let status = await WangZheRongYaofun.getWangZheStatus(); - if (canChangeZr.includes(status.status) && (status.stime - 5 * 60) <= G.time && G.time <= (status.etime + 5 * 60)) { - // 每个状态开始的前5后5分钟 无法更换 + // 每个状态开始的前5后5分钟 无法更换 + if ((canChangeZr.includes(status.status + 1) && G.time >= (status.etime - 5 * 60)) || (canChangeZr.includes(status.status - 1) && G.time <= (status.stime + 5 * 60))) { return call.error('', {code: -2, message: ''/* globalThis.lng.wzry_17 */}); } diff --git a/src/cross/protocols/clsl/PtlRank.ts b/src/cross/protocols/clsl/PtlRank.ts index 60b990b..c240888 100644 --- a/src/cross/protocols/clsl/PtlRank.ts +++ b/src/cross/protocols/clsl/PtlRank.ts @@ -4,6 +4,8 @@ import { player } from '../../../shared/protocols/user/type'; export type ReqRank = { gud: player; + page?: number; + offset?: number; }; export type ResRank = ResOpen['']; \ No newline at end of file diff --git a/src/cross/protocols/hbzb/jfs/PtlGetEnemy.ts b/src/cross/protocols/hbzb/jfs/PtlGetEnemy.ts index 3f85e94..ebdfa29 100644 --- a/src/cross/protocols/hbzb/jfs/PtlGetEnemy.ts +++ b/src/cross/protocols/hbzb/jfs/PtlGetEnemy.ts @@ -1,8 +1,10 @@ import { joinFightData } from '../../../../shared/fightControl/fightType'; +import { player } from '../../../../shared/protocols/user/type'; export type ReqGetEnemy = { uid: string; auto: boolean; + gud?: player; }; export type ResGetEnemy = { diff --git a/src/cross/protocols/hbzb/jfs/PtlGetRankList.ts b/src/cross/protocols/hbzb/jfs/PtlGetRankList.ts index 87f3f2e..b978cb3 100644 --- a/src/cross/protocols/hbzb/jfs/PtlGetRankList.ts +++ b/src/cross/protocols/hbzb/jfs/PtlGetRankList.ts @@ -3,6 +3,8 @@ import { rankInfo } from '../../../../shared/protocols/type'; export type ReqGetRankList = { uid: string; + page?: number; + offset?: number; }; export type ResGetRankList = { diff --git a/src/cross/protocols/hbzb/zbs/PtlGetRankList.ts b/src/cross/protocols/hbzb/zbs/PtlGetRankList.ts index 3ffc052..8fba2da 100644 --- a/src/cross/protocols/hbzb/zbs/PtlGetRankList.ts +++ b/src/cross/protocols/hbzb/zbs/PtlGetRankList.ts @@ -1,7 +1,10 @@ import { rankInfo } from '../../../../shared/protocols/type'; -export type ReqGetRankList = {}; +export type ReqGetRankList = { + page?:number; + offset?:number; +}; export type ResGetRankList = { rankList: rankInfo[]; diff --git a/src/cross/protocols/kbzz/PtlRank.ts b/src/cross/protocols/kbzz/PtlRank.ts index 4386d36..45911c9 100644 --- a/src/cross/protocols/kbzz/PtlRank.ts +++ b/src/cross/protocols/kbzz/PtlRank.ts @@ -3,6 +3,8 @@ import { rankInfo } from '../../../shared/protocols/type'; export type ReqRank = { uid: string; + page?: number; + offset?: number; }; export type ResRank = { diff --git a/src/cross/protocols/serviceProto.ts b/src/cross/protocols/serviceProto.ts index 2df4768..c6558dd 100644 --- a/src/cross/protocols/serviceProto.ts +++ b/src/cross/protocols/serviceProto.ts @@ -2628,6 +2628,22 @@ export const serviceProto: ServiceProto = { "type": "Reference", "target": "../../shared/protocols/user/type/player" } + }, + { + "id": 1, + "name": "page", + "type": { + "type": "Number" + }, + "optional": true + }, + { + "id": 2, + "name": "offset", + "type": { + "type": "Number" + }, + "optional": true } ] }, @@ -2829,6 +2845,15 @@ export const serviceProto: ServiceProto = { "type": { "type": "Boolean" } + }, + { + "id": 2, + "name": "gud", + "type": { + "type": "Reference", + "target": "../../shared/protocols/user/type/player" + }, + "optional": true } ] }, @@ -2892,6 +2917,22 @@ export const serviceProto: ServiceProto = { "type": { "type": "String" } + }, + { + "id": 1, + "name": "page", + "type": { + "type": "Number" + }, + "optional": true + }, + { + "id": 2, + "name": "offset", + "type": { + "type": "Number" + }, + "optional": true } ] }, @@ -3028,7 +3069,25 @@ export const serviceProto: ServiceProto = { } }, "hbzb/zbs/PtlGetRankList/ReqGetRankList": { - "type": "Interface" + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "page", + "type": { + "type": "Number" + }, + "optional": true + }, + { + "id": 1, + "name": "offset", + "type": { + "type": "Number" + }, + "optional": true + } + ] }, "hbzb/zbs/PtlGetRankList/ResGetRankList": { "type": "Interface", @@ -3238,6 +3297,22 @@ export const serviceProto: ServiceProto = { "type": { "type": "String" } + }, + { + "id": 1, + "name": "page", + "type": { + "type": "Number" + }, + "optional": true + }, + { + "id": 2, + "name": "offset", + "type": { + "type": "Number" + }, + "optional": true } ] }, @@ -3771,6 +3846,22 @@ export const serviceProto: ServiceProto = { "type": "Reference", "target": "../../shared/protocols/user/type/player" } + }, + { + "id": 1, + "name": "page", + "type": { + "type": "Number" + }, + "optional": true + }, + { + "id": 2, + "name": "offset", + "type": { + "type": "Number" + }, + "optional": true } ] }, diff --git a/src/cross/protocols/wzry/PtlRank.ts b/src/cross/protocols/wzry/PtlRank.ts index 60b990b..c240888 100644 --- a/src/cross/protocols/wzry/PtlRank.ts +++ b/src/cross/protocols/wzry/PtlRank.ts @@ -4,6 +4,8 @@ import { player } from '../../../shared/protocols/user/type'; export type ReqRank = { gud: player; + page?: number; + offset?: number; }; export type ResRank = ResOpen['']; \ No newline at end of file diff --git a/src/event.ts b/src/event.ts index f4ea716..ce946d2 100644 --- a/src/event.ts +++ b/src/event.ts @@ -307,15 +307,8 @@ EventEmitter.prototype.listeners = function (type) { return ret; }; -EventEmitter.listenerCount = function (emitter, type) { - var ret; - if (!emitter._events || !emitter._events[type]) - ret = 0; - else if (isFunction(emitter._events[type])) - ret = 1; - else - ret = emitter._events[type].length; - return ret; +EventEmitter.prototype.debug = function () { + console.log(this._events); }; export const MyEvent = EventEmitter as any as { @@ -324,4 +317,6 @@ export const MyEvent = EventEmitter as any as { once(type: any, callback: any): any; off(type: any, callback: any, caller?: any): void; emit(type: any, ...args: any[]): void; + debug(): any; + removeAllListeners(type?:any):void; }; diff --git a/src/extends.ts b/src/extends.ts index ac635a1..41a0e5d 100644 --- a/src/extends.ts +++ b/src/extends.ts @@ -113,7 +113,6 @@ Object.defineProperties(BaseConnection.prototype, { }, }, 'gonghui': { - // ###debug GHManage 对象内同步转异步 // 涉及call.conn.gonghui,对应引用变量处需增加await async get(this: BaseConnection): Promise { // return GHManage.list[this.gud.ghId]; diff --git a/src/global.ts b/src/global.ts index ed3e9ae..4b19f76 100644 --- a/src/global.ts +++ b/src/global.ts @@ -105,6 +105,8 @@ class _G { once(type: any, callback: any): any; off(type: any, callback: any, caller?: any): void; emit(type: any, ...args: any[]): void; + debug(): any; + removeAllListeners(type?:any):void; } { return MyEvent as any; } diff --git a/src/json/guide.json b/src/json/guide.json index 6b7b91e..0d1ea56 100644 --- a/src/json/guide.json +++ b/src/json/guide.json @@ -2482,6 +2482,7 @@ "break": 0, "mask": 0, "content": "zhuanchang", + "afterGuide": "100_180", "intr": "转场", "skip": 0 }, diff --git a/src/json/guideConfig.json b/src/json/guideConfig.json index dabe972..5cbad89 100644 --- a/src/json/guideConfig.json +++ b/src/json/guideConfig.json @@ -6,7 +6,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", "undefined": "点探险", - "initiative": 1 + "initiative": 1, + "location": 2 }, "2": { "id": 2, @@ -15,16 +16,19 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", "undefined": "点战斗", - "initiative": 1 + "initiative": 1, + "nonum": "a1", + "location": 1 }, "3": { "id": 3, "triggerType": "task", - "typeId": 2000, + "typeId": 2001, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/rw_tis", - "undefined": "点任务", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/dy", + "undefined": "点主城", + "initiative": 1, + "location": 2 }, "4": { "id": 4, @@ -35,46 +39,42 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "5": { "id": 5, "triggerType": "task", "typeId": 2001, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/dy", - "undefined": "点主城", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainView/mainView/ScrollView/view/content/zc_bg/name/zc_btn_jg", + "undefined": "点酒吧", + "initiative": 1, + "location": 1 }, "6": { "id": 6, "triggerType": "task", "typeId": 2001, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainView/mainView/ScrollView/view/content/zc_bg/name/zc_btn_jg", - "undefined": "点酒吧", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_jiuba/jiuba/bg/panel_btn/btn_zmyc", + "undefined": "点抽卡", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "7": { "id": 7, "triggerType": "task", - "typeId": 2001, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_jiuba/jiuba/bg/panel_btn/btn_zmyc", - "undefined": "点抽卡", - "initiative": 1 - }, - "8": { - "id": 8, - "triggerType": "task", "typeId": 2002, "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", "undefined": "点干部", - "initiative": 1 + "initiative": 1, + "location": 1 }, - "9": { - "id": 9, + "8": { + "id": 8, "triggerType": "task", "typeId": 2002, "Type": "dialog", @@ -82,25 +82,39 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 + }, + "9": { + "id": 9, + "triggerType": "task", + "typeId": 2002, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_top/lay_szhero/sz_list2/txt_kw", + "undefined": "点第二个干部加号", + "initiative": 1, + "location": 1 }, "10": { "id": 10, "triggerType": "task", "typeId": 2002, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_top/lay_szhero/sz_list2/txt_kw", - "undefined": "点第二个干部加号", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_hero_gh/hero_gh/bg/ScrollView/view/content/list/btn", + "undefined": "弹框点上阵", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "11": { "id": 11, "triggerType": "task", - "typeId": 2002, + "typeId": 2003, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_hero_gh/hero_gh/bg/ScrollView/view/content/list/btn", - "undefined": "弹框点上阵", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", + "undefined": "点干部", + "initiative": 1, + "location": 1 }, "12": { "id": 12, @@ -111,143 +125,157 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "13": { "id": 13, "triggerType": "task", "typeId": 2003, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", - "undefined": "点干部", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_zb", + "undefined": "点装备页签", + "initiative": 1, + "location": 2 }, "14": { "id": 14, "triggerType": "task", "typeId": 2003, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_zb", - "undefined": "点装备页签", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/panel_rdown/panel_zb/btn_yjzb", + "undefined": "点一键装备", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "15": { "id": 15, "triggerType": "task", - "typeId": 2003, + "typeId": 2004, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/panel_rdown/panel_zb/btn_yjzb", - "undefined": "点一键装备", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", + "undefined": "点探险", + "initiative": 1, + "location": 2 }, "16": { "id": 16, "triggerType": "task", "typeId": 2004, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", - "undefined": "点探险", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", + "undefined": "点战斗", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "17": { "id": 17, "triggerType": "task", - "typeId": 2004, + "typeId": 2005, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", - "undefined": "点战斗", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/wp", + "undefined": "点背包", + "initiative": 1, + "location": 2 }, "18": { "id": 18, "triggerType": "task", "typeId": 2005, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/wp", - "undefined": "点背包", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_beibao/beibao/bb_bg_001/Scr_btn/view/content/btnLayout/sp", + "undefined": "点碎片页签", + "initiative": 1, + "location": 2 }, "19": { "id": 19, "triggerType": "task", "typeId": 2005, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_beibao/beibao/bb_bg_001/Scr_btn/view/content/btnLayout/sp", - "undefined": "点碎片页签", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_beibao/beibao/bb_bg_001/ScrollView2/view/content/spfirstItem/item/ItemClass", + "undefined": "点第一个碎片", + "initiative": 1, + "nonum": "sp", + "location": 1 }, "20": { "id": 20, "triggerType": "task", "typeId": 2005, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_beibao/beibao/bb_bg_001/ScrollView2/view/content/dj4/item/ItemClass", - "undefined": "点第一个碎片", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_itemInfo/itemInfo/pop_01/panel_btns/btn", + "undefined": "点合成", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "21": { "id": 21, "triggerType": "task", - "typeId": 2005, + "typeId": 2006, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_itemInfo/itemInfo/pop_01/panel_btns/btn", - "undefined": "点合成", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", + "undefined": "点干部", + "initiative": 1, + "location": 1 }, "22": { "id": 22, "triggerType": "task", "typeId": 2006, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", - "undefined": "点干部", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_top/lay_szhero/sz_list3/txt_kw", + "undefined": "点第三个干部加号", + "initiative": 1, + "location": 1 }, "23": { "id": 23, "triggerType": "task", "typeId": 2006, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_top/lay_szhero/sz_list3/txt_kw", - "undefined": "点第三个干部加号", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_hero_gh/hero_gh/bg/ScrollView/view/content/list/btn", + "undefined": "弹框点上阵", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "24": { "id": 24, "triggerType": "task", - "typeId": 2006, + "typeId": 2007, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_hero_gh/hero_gh/bg/ScrollView/view/content/list/btn", - "undefined": "弹框点上阵", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", + "undefined": "点探险", + "initiative": 1, + "location": 2 }, "25": { "id": 25, "triggerType": "task", "typeId": 2007, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", - "undefined": "点探险" + "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", + "undefined": "点战斗", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "26": { "id": 26, "triggerType": "task", - "typeId": 2007, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", - "undefined": "点战斗" - }, - "27": { - "id": 27, - "triggerType": "task", "typeId": 2008, "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", "undefined": "点探险", - "initiative": 1 + "initiative": 1, + "location": 2 }, - "28": { - "id": 28, + "27": { + "id": 27, "triggerType": "task", "typeId": 2008, "Type": "dialog", @@ -255,320 +283,347 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, - "29": { - "id": 29, + "28": { + "id": 28, "triggerType": "task", "typeId": 2008, "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/map/gjBoxPrize", "undefined": "点挂机奖励宝箱", - "initiative": 1 + "initiative": 1, + "nonum": "a1", + "location": 1 + }, + "29": { + "id": 29, + "triggerType": "task", + "typeId": 2009, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", + "undefined": "点干部", + "initiative": 1, + "location": 2 }, "30": { "id": 30, "triggerType": "task", "typeId": 2009, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", - "undefined": "点干部", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_sj", + "undefined": "点升级页签", + "initiative": 1, + "location": 2 }, "31": { "id": 31, "triggerType": "task", "typeId": 2009, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_sj", - "undefined": "点升级页签", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/panel_rdown/panel_sj/btn_shengji", + "undefined": "点升级按钮", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "32": { "id": 32, "triggerType": "task", - "typeId": 2009, + "typeId": 2010, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/panel_rdown/panel_sj/btn_shengji", - "undefined": "点升级按钮", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", + "undefined": "点干部", + "initiative": 1, + "location": 2 }, "33": { "id": 33, "triggerType": "task", "typeId": 2010, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", - "undefined": "点干部", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_jj", + "undefined": "点进阶页签", + "initiative": 1, + "location": 2 }, "34": { "id": 34, "triggerType": "task", "typeId": 2010, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_jj", - "undefined": "点进阶页签", - "initiative": 1 - }, - "35": { - "id": 35, - "triggerType": "task", - "typeId": 2010, "Type": "dialog", "path": "intr_guide_content_54", "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, - "36": { - "id": 36, + "35": { + "id": 35, "triggerType": "task", "typeId": 2010, "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/panel_rdown/panel_jj/btn_jinjie", "undefined": "点进阶按钮", - "initiative": 1 + "initiative": 1, + "nonum": "a1", + "location": 1 + }, + "36": { + "id": 36, + "triggerType": "task", + "typeId": 2011, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", + "undefined": "点探险", + "initiative": 1, + "location": 2 }, "37": { "id": 37, "triggerType": "task", "typeId": 2011, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", - "undefined": "点探险" + "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", + "undefined": "点战斗", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "38": { "id": 38, "triggerType": "task", - "typeId": 2011, + "typeId": 2012, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", - "undefined": "点战斗" + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/dy", + "undefined": "点主城", + "initiative": 1, + "location": 1 }, "39": { "id": 39, "triggerType": "task", "typeId": 2012, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_mainView/mainView/ScrollView/view/content/zc_bg/name/zc_btn_jg", + "undefined": "点酒吧", + "initiative": 1, + "location": 1 + }, + "40": { + "id": 40, + "triggerType": "task", + "typeId": 2012, "Type": "dialog", "path": "intr_guide_content_68", "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 - }, - "40": { - "id": 40, - "triggerType": "task", - "typeId": 2012, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/dy", - "undefined": "点主城", - "initiative": 1 + "initiative": 1, + "location": 1 }, "41": { "id": 41, "triggerType": "task", "typeId": 2012, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainView/mainView/ScrollView/view/content/zc_bg/name/zc_btn_jg", - "undefined": "点酒吧", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_jiuba/jiuba/bg/panel_btn/btn_zmsc", + "undefined": "十连抽", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "42": { "id": 42, "triggerType": "task", - "typeId": 2012, + "typeId": 2013, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_jiuba/jiuba/bg/panel_btn/btn_zmsc", - "undefined": "十连抽", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", + "undefined": "点干部", + "initiative": 1, + "location": 2 }, "43": { "id": 43, "triggerType": "task", "typeId": 2013, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", - "undefined": "点干部" + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_top/lay_szhero/sz_list4/txt_kw", + "undefined": "点第四个干部加号", + "initiative": 1, + "location": 1 }, "44": { "id": 44, "triggerType": "task", "typeId": 2013, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_top/lay_szhero/sz_list4/txt_kw", - "undefined": "点第四个干部加号" + "path": "Canvas/draw/uiRoot/uiView_hero_gh/hero_gh/bg/ScrollView/view/content/list/btn", + "undefined": "弹框点上阵", + "initiative": 1, + "nonum": "a1", + "location": 1 }, "45": { "id": 45, "triggerType": "task", - "typeId": 2013, + "typeId": 2014, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_hero_gh/hero_gh/bg/ScrollView/view/content/list/btn", - "undefined": "弹框点上阵" + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", + "undefined": "点探险", + "location": 2 }, "46": { "id": 46, "triggerType": "task", "typeId": 2014, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", - "undefined": "点探险" + "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", + "undefined": "点战斗", + "location": 1 }, "47": { "id": 47, "triggerType": "task", - "typeId": 2014, + "typeId": 2015, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/btn_kz", - "undefined": "点战斗" + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", + "undefined": "点干部", + "location": 1 }, "48": { "id": 48, "triggerType": "task", "typeId": 2015, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/gb", - "undefined": "点干部" + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_sj", + "undefined": "点升级页签", + "location": 2 }, "49": { "id": 49, "triggerType": "task", "typeId": 2015, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_sj", - "undefined": "点升级页签" + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/panel_rdown/panel_sj/btn_shengji", + "undefined": "点升级按钮", + "location": 1 }, "50": { "id": 50, "triggerType": "task", - "typeId": 2015, + "typeId": 2029, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/panel_rdown/panel_sj/btn_shengji", - "undefined": "点升级按钮" + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/dy", + "undefined": "点主城", + "initiative": 1, + "location": 1 }, "51": { "id": 51, "triggerType": "task", - "typeId": 2016, + "typeId": 2029, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/rw_tis", - "undefined": "点任务", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_mainView/mainView/ScrollView/view/content/zc_bg/name/zc_btn_zjdj", + "undefined": "点主角的家", + "initiative": 1, + "location": 1 }, "52": { "id": 52, "triggerType": "task", - "typeId": 2017, + "typeId": 2029, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/rw_tis", - "undefined": "点任务", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_zhujuegongyu/zhujuegongyu/btn_zzjh", + "undefined": "点作战计划", + "initiative": 1, + "location": 1 }, "53": { "id": 53, "triggerType": "task", - "typeId": 2031, + "typeId": 2029, "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/dy", - "undefined": "点主城", - "initiative": 1 + "path": "Canvas/draw/uiRoot/uiView_xunlianjihua2/xunlianjihua2/panel_1/ScrollView_New/view/content/jinengClass_810/810", + "undefined": "点第一个技能", + "initiative": 1, + "location": 1 }, "54": { "id": 54, "triggerType": "task", - "typeId": 2031, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_mainView/mainView/ScrollView/view/content/zc_bg/name/zc_btn_zjdj", - "undefined": "点主角的家", - "initiative": 1 - }, - "55": { - "id": 55, - "triggerType": "task", - "typeId": 2031, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_zhujuegongyu/zhujuegongyu/btn_zzjh", - "undefined": "点作战计划", - "initiative": 1 - }, - "56": { - "id": 56, - "triggerType": "task", - "typeId": 2031, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_xunlianjihua2/xunlianjihua2/panel_1/ScrollView_New/view/content/jinengClass_810/810", - "undefined": "点第一个技能", - "initiative": 1 - }, - "57": { - "id": 57, - "triggerType": "task", - "typeId": 2031, + "typeId": 2029, "Type": "dialog", "path": "intr_guide_content_23", "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, - "58": { - "id": 58, + "55": { + "id": 55, "triggerType": "task", - "typeId": 2031, + "typeId": 2029, "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_xunlianjihua_tanchuang/xunlianjihua_tanchuang/btn_red3", "undefined": "点升级按钮", - "initiative": 1 + "initiative": 1, + "location": 1 }, - "59": { - "id": 59, + "56": { + "id": 56, "triggerType": "task", - "typeId": 2031, + "typeId": 2029, "Type": "dialog", "path": "intr_guide_content_24", "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 + }, + "57": { + "id": 57, + "triggerType": "task", + "typeId": 2029, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_xunlianjihua2/xunlianjihua2/btn_gd", + "undefined": "点布置计划", + "initiative": 1, + "location": 1 + }, + "58": { + "id": 58, + "triggerType": "task", + "typeId": 2029, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_xunlianjihua2/xunlianjihua2/panel_2/uiView_zuozhanjihua_youhua/zuozhanjihua_youhua/bg_shouc1/panel_nr/list1", + "undefined": "点第一个格子", + "initiative": 1, + "location": 1 + }, + "59": { + "id": 59, + "triggerType": "task", + "typeId": 2029, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_genghuanjihua/genghuanjihua/pop_02/panel_nr/ScrollView/view/content/list/ty_bg_gou", + "undefined": "勾选技能", + "initiative": 1, + "location": 1 }, "60": { "id": 60, "triggerType": "task", - "typeId": 2031, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_xunlianjihua2/xunlianjihua2/btn_gd", - "undefined": "点布置计划", - "initiative": 1 - }, - "61": { - "id": 61, - "triggerType": "task", - "typeId": 2031, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_xunlianjihua2/xunlianjihua2/panel_2/uiView_zuozhanjihua_youhua/zuozhanjihua_youhua/bg_shouc1/panel_nr/list1", - "undefined": "点第一个格子", - "initiative": 1 - }, - "62": { - "id": 62, - "triggerType": "task", - "typeId": 2031, - "Type": "finger", - "path": "Canvas/draw/uiRoot/uiView_genghuanjihua/genghuanjihua/pop_02/panel_nr/ScrollView/view/content/list/ty_bg_gou", - "undefined": "勾选技能", - "initiative": 1 - }, - "63": { - "id": 63, - "triggerType": "task", - "typeId": 2031, + "typeId": 2029, "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_genghuanjihua/genghuanjihua/pop_02/btn_red", "undefined": "确认", - "initiative": 1 + "initiative": 1, + "location": 1 }, "10001": { "id": 10001, @@ -579,7 +634,8 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "10002": { "id": 10002, @@ -588,7 +644,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/tj", "undefined": "点码头", - "initiative": 1 + "initiative": 1, + "location": 2 }, "10003": { "id": 10003, @@ -597,7 +654,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_matou_main/matou_main/bg_phb/PageView/view/content/page1/jjc", "undefined": "点游轮竞技", - "initiative": 1 + "initiative": 1, + "location": 1 }, "10004": { "id": 10004, @@ -608,7 +666,8 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "10101": { "id": 10101, @@ -619,7 +678,8 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "10102": { "id": 10102, @@ -628,7 +688,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/tj", "undefined": "点码头", - "initiative": 1 + "initiative": 1, + "location": 2 }, "10103": { "id": 10103, @@ -637,7 +698,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_matou_main/matou_main/bg_phb/PageView/view/content/page1/zccg", "undefined": "点黑暗塔", - "initiative": 1 + "initiative": 1, + "location": 1 }, "10104": { "id": 10104, @@ -648,7 +710,8 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "10105": { "id": 10105, @@ -657,7 +720,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_pata/pata/ui/scrollView/view/content/item1", "undefined": "点第一关", - "initiative": 1 + "initiative": 1, + "location": 1 }, "10201": { "id": 10201, @@ -668,7 +732,8 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "10202": { "id": 10202, @@ -676,7 +741,9 @@ "typeId": "zc_btn_slzb", "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/dy", - "undefined": "点主城" + "undefined": "点主城", + "initiative": 1, + "location": 2 }, "10203": { "id": 10203, @@ -684,7 +751,9 @@ "typeId": "zc_btn_slzb", "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_mainView/mainView/ScrollView/view/content/zc_bg/name/zc_btn_slzb", - "undefined": "点势力" + "undefined": "点势力", + "initiative": 1, + "location": 1 }, "10204": { "id": 10204, @@ -695,7 +764,8 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "10301": { "id": 10301, @@ -706,7 +776,8 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "10302": { "id": 10302, @@ -715,7 +786,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/tj", "undefined": "点码头", - "initiative": 1 + "initiative": 1, + "location": 2 }, "10303": { "id": 10303, @@ -724,7 +796,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_matou_main/matou_main/bg_phb/PageView/view/content/page1/wzcj", "undefined": "点物资缴获", - "initiative": 1 + "initiative": 1, + "location": 1 }, "10304": { "id": 10304, @@ -735,7 +808,8 @@ "undefined": "对话", "spine": 5001, "direction": 1, - "initiative": 1 + "initiative": 1, + "location": 1 }, "10305": { "id": 10305, @@ -744,7 +818,8 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_meirishilian/meirishilian/bg_wzcj/btn/btn1", "undefined": "点休闲区", - "initiative": 1 + "initiative": 1, + "location": 1 }, "10306": { "id": 10306, @@ -753,6 +828,146 @@ "Type": "finger", "path": "Canvas/draw/uiRoot/uiView_meirishilian/meirishilian/bg_wzcj/btn_red", "undefined": "点挑战", - "initiative": 1 + "initiative": 1, + "location": 1 + }, + "10401": { + "id": 10401, + "triggerType": "openCond", + "typeId": "ganbutexun_main", + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/tj", + "undefined": "点码头", + "initiative": 1, + "location": 2 + }, + "10402": { + "id": 10402, + "triggerType": "openCond", + "typeId": "ganbutexun_main", + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_matou_main/matou_main/bg_phb/PageView/view/content/page1/gbtx", + "undefined": "点干部特训", + "initiative": 1, + "location": 1 + }, + "10403": { + "id": 10403, + "triggerType": "openCond", + "typeId": "ganbutexun_main", + "Type": "dialog", + "path": "intr_guide_content_27", + "undefined": "对话", + "spine": 5001, + "direction": 1, + "initiative": 1, + "location": 1 + }, + "10404": { + "id": 10404, + "triggerType": "openCond", + "typeId": "ganbutexun_main", + "Type": "dialog", + "path": "intr_guide_content_28", + "undefined": "对话", + "spine": 5001, + "direction": 1, + "initiative": 1, + "location": 1 + }, + "10501": { + "id": 10501, + "triggerType": "openCond", + "typeId": "zc_btn_lg", + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/dy", + "undefined": "点主城", + "initiative": 1, + "location": 2 + }, + "10502": { + "id": 10502, + "triggerType": "openCond", + "typeId": "zc_btn_lg", + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_mainView/mainView/ScrollView/view/content/zc_bg/name/zc_btn_lg", + "undefined": "点悬赏", + "initiative": 1, + "location": 1 + }, + "10503": { + "id": 10503, + "triggerType": "openCond", + "typeId": "zc_btn_lg", + "Type": "dialog", + "path": "intr_guide_content_37", + "undefined": "对话", + "spine": 5001, + "direction": 1, + "initiative": 1, + "location": 1 + }, + "20001": { + "id": 20001, + "triggerType": "lose", + "typeId": "lose", + "Type": "dialog", + "path": "intr_guide_content_46", + "undefined": "对话", + "spine": 5001, + "direction": 1, + "initiative": 1, + "nonum": "lose", + "location": 1 + }, + "20002": { + "id": 20002, + "triggerType": "lose", + "typeId": "lose", + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_fight_fail/fight_fail/pageNode/tstj/zd_icon_001", + "undefined": "失败界面提升点干部", + "initiative": 1, + "location": 1 + }, + "20003": { + "id": 20003, + "triggerType": "lose", + "typeId": "lose", + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/btnScrollView/view/content/leftBtn/btn_sj", + "undefined": "点升级页签", + "initiative": 1, + "location": 2 + }, + "20004": { + "id": 20004, + "triggerType": "lose", + "typeId": "lose", + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_heroInfo/heroInfo/img_bg/panel_down/panel_rdown/panel_sj/btn_shengji", + "undefined": "点升级按钮", + "initiative": 1, + "location": 1 + }, + "30000": { + "id": 30000, + "triggerType": "task", + "typeId": 99999, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_mainMenu/mainMenu/btnLayout/zd", + "undefined": "点探险", + "initiative": 1, + "location": 2 + }, + "30001": { + "id": 30001, + "triggerType": "task", + "typeId": 99999, + "Type": "finger", + "path": "Canvas/draw/uiRoot/uiView_tanxian/tanxian/tx_map1/rw_tis", + "undefined": "点任务栏", + "initiative": 1, + "location": 1 } } \ No newline at end of file diff --git a/src/json/task.json b/src/json/task.json index 7874b09..6a2928c 100644 --- a/src/json/task.json +++ b/src/json/task.json @@ -658,6 +658,11 @@ "a": "attr", "t": "nexp", "n": 500 + }, + { + "a": "item", + "t": "4", + "n": 1 } ], "pval": 1, diff --git a/src/public/jjc.ts b/src/public/jjc.ts index 4be4e98..a41e417 100644 --- a/src/public/jjc.ts +++ b/src/public/jjc.ts @@ -104,7 +104,7 @@ export class JJCFun { // 函数内max存在-1操作,查自己需保持min=max let rankList = await this.getRankList(rank, rank + 1) let rankInfo = rankList[0] - return rankInfo + return rankInfo || {} } // 写入新玩家排名 diff --git a/src/public/player.ts b/src/public/player.ts index 9a2a032..470f41d 100644 --- a/src/public/player.ts +++ b/src/public/player.ts @@ -90,17 +90,18 @@ export class PlayerFun { static async cutNeed(call: call, val: atn[]) { let needArr = PublicShared.mergePrize(val); needArr.forEach(v => v.n *= -1); + let all = []; let attr = needArr.filter(atn => atn.a == 'attr' && atn.n != 0); if (attr.length > 0) { - await this.addAttr(call, attr); + all.push(this.addAttr(call, attr)); } let item = needArr.filter(atn => atn.a == 'item' && atn.n != 0); if (item.length > 0) { - await this.addItem(call, item); + all.push(this.addItem(call, item)); } - + await Promise.all(all); G.emit('USE_ITEM', call.conn.gud, needArr.map(need => { return {...need, n: Math.abs(need.n)}; })); @@ -139,11 +140,15 @@ export class PlayerFun { }> | atn[]) { let change = {}; if (val instanceof Array) { + let all = []; for (let atn of val) { change[atn.t] = await this.getAtnNum(call, atn) + atn.n; - await this.changeAttr(call.conn.uid, change); - await this.upAttr(call, {...atn, n: change[atn.t]}); + all.push( this.changeAttr(call.conn.uid, change) ); + all.push( this.upAttr(call, {...atn, n: change[atn.t]}) ); + //await this.changeAttr(call.conn.uid, change); + //await this.upAttr(call, {...atn, n: change[atn.t]}); } + await Promise.all(all); } else { change = val; await this.changeAttr(call.conn.uid, change); @@ -237,13 +242,22 @@ export class PlayerFun { call.addEventMsg('msg_s2c/ItemChange', atn.t, data); } else { if (item.num + atn.n <= 0) { - await G.redis.del('item', call.uid, atn.t); - await G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t}); + await Promise.all([ + G.redis.del('item', call.uid, atn.t), + G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t}) + ]); + //await G.redis.del('item', call.uid, atn.t); + //await G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t}); call.addEventMsg('msg_s2c/ItemChange', atn.t, {num: 0}); } else { - await G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime); - await G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n); - await G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options); + await Promise.all([ + G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime), + G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n), + G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options) + ]); + // await G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime); + // await G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n); + // await G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options); call.addEventMsg('msg_s2c/ItemChange', atn.t, { num: item.num + atn.n, lastTime: upObj.update.$set.lastTime diff --git a/src/public/rank/rank.ts b/src/public/rank/rank.ts index b1ea8be..7c91961 100644 --- a/src/public/rank/rank.ts +++ b/src/public/rank/rank.ts @@ -46,9 +46,18 @@ export abstract class Rank { abstract getType(): rankType; abstract compare(other: rankInfo, cur: rankInfo): boolean; abstract compareSort(a: rankInfo, b: rankInfo): number; - abstract getRankList(uid: string, gud?: player): Promise; + abstract getRankList(uid: string, obj?: {gud?:player, min?: number, max?:number}): Promise; abstract getValArr(info: rankInfo): number|string; // 运算后的积分值,排名依据 + // 页码转换为min,max + static pageToMin (page, offset) { + let res = { + min: page * offset, + max: page * offset + offset + } + return res + } + get db() { return G.mongodb.collection('rankList'); } @@ -99,82 +108,109 @@ export abstract class Rank { async getRankData(idKey: string) { let key = this.getRedisKey let data = await G.redis.hGet(key, idKey) - if(!data) { + if(!data || data.utime < (G.time - this.utimeTTL)) { let type = this.getType() let res = await this.db.findOne({isKey: idKey, type}) - data = G.mongodb.conversionIdObj(res) - if(data) this.setRankData(idKey, data) + if(res) { + data = G.mongodb.conversionIdObj(res) + this.setRankData(idKey, data.data) + } } - if(data) data + if(data) return data return undefined } - // 获取单个用户的排名 *倒叙 + // 获取单个用户的排名 *降序 async getRankSortByOne(idKey: string):Promise { let rank = await G.redis.zRevRank(this.getRedisKeySort, idKey) return rank || -1; } + + // 获取单个指定排名的用户数据 *降序 + async getRankSortDataByOne(rank: number): Promise { + let rankList:rankInfo[] = await this.getRankListRange(rank, rank + 1) + let rankInfo = rankList && rankList.length > 0 ? rankList[0] : {} as rankInfo + return rankInfo + } // 获取排名长度 async getRankLen() { return await G.redis.hLen(this.getRedisKey) } + // 获取指定排名范围的数据 *降序 + async getRankListRange(min:number = 0, max:number = 50): Promise { + let idKeys = await this.getRankListIdKeyRange(min, max) + if(idKeys && idKeys.length > 0) { + let res = await G.redis.hmGet(this.getRedisKey, idKeys) + res = await this.checkData(res) + return res.sort(this.compareSort) + } + return undefined + } + + // 获取指定排名范围的idKey *降序 + async getRankListIdKeyRange(min:number = 0, max: number = 50): Promise { + let idKeys = await G.redis.zRevRange(this.getRedisKeySort, min, max - 1) + return idKeys || [] + } + // 获取指定类型的全部rank列表,返回为积分排序后的数组 async getRankListAll(): Promise { let res = await G.redis.hGetAll(this.getRedisKey) if(res) { // 如果是用户数据,则比对utime,更新数据 - let updateUid = [] - Object.keys(res).forEach(key => { - if(res[key].player?.uid && (res[key].utime || 0) < (G.time - this.utimeTTL)) { - // 更新数据 - updateUid.push(res[key].player.uid) - } - }) - if(updateUid.length > 0) { - let newUserArr = await G.mongodb.collection('user').find({uid: {$in: updateUid}}).toArray() - newUserArr.forEach(item => { - res[item.uid].player = item - res[item.uid].utime = G.time - this.setRankData(item.uid, res[item.uid]) - }) - } + // res = await this.checkData(res) return Object.values(res).sort(this.compareSort) } return [] } + // 按排名获取全部的idKey + async getRankListIdKeyAll(): Promise { + let res = this.getRankListIdKeyRange(0, -1) + return res + } + + // 验证数据的过期时间,更新数据 + async checkData(rankList: rankInfo[]): Promise { + let updateUid = [] + rankList.forEach((value,key) => { + // 仅针对用户表,公会表暂不考虑 + if(rankList[key].player?.uid && (rankList[key].utime || 0) < (G.time - this.utimeTTL)) { + // 更新数据 + updateUid.push(rankList[key].player.uid) + } + }) + if(updateUid.length > 0) { + let newUserArr = await G.redis.gets('user', ...updateUid.map(uid => [uid] as [string])) + // G.mongodb.collection('user').find({uid: {$in: updateUid}}).toArray() + newUserArr.forEach(item => { + let index = rankList.findIndex( x => x.player.uid == item.uid) + rankList[index].player = item + this.setRankData(item.uid, rankList[index]) + }) + } + return rankList + } + async delRankData(idKey:string) { G.redis.hDel(this.getRedisKey, idKey) G.redis.zRem(this.getRedisKeySort, idKey) } - // 前50(countMaxNum)名才更新数据(上榜),多余的数据会删除。 + // 原逻辑前50(countMaxNum)名才更新数据(上榜),多余的数据会删除。 async addNew(info: rankInfo) { this.queue.enqueue(async () => { - let rankList = await this.getRankListAll() - // 进入前50名才更新数据 - if (rankList.length < this.countMaxNum || this.compare(rankList.slice(-1)[0], info)) { - // 原逻辑是更新数组内索引(排名)信息,redis更新用户数据即可 - await this.setRankData(info.player[this.findKey], info) - this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true }); - - // 超过50名时,删除最后一名(第51名)。 - let myIndex = rankList.findIndex(li => li.player[this.findKey] == info.player[this.findKey]); - if (myIndex != -1) { - rankList[myIndex] = info; - } else { - rankList.push(info); - } - // 重新排序 - rankList.sort(this.compareSort) - if (rankList.length > this.countMaxNum) { - let del = rankList.pop(); - this.db.deleteOne({ type: this.type, idKey: del.player[this.findKey] }); - this.delRankData(del.player[this.findKey]) - } - } + await this.setRankData(info.player[this.findKey], info) + let myRank = await this.getRankSortByOne(info.player[this.findKey]) + if(myRank < this.countMaxNum) this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true }); + // 删除第50名以后的数据,(排名从0开始计算) + let idKeys:string[] = await this.getRankListIdKeyRange(50, -1) + idKeys.forEach(idKey => { + this.db.deleteOne({ type: this.type, idKey: idKey }); + this.delRankData(idKey) + }) }); } diff --git a/src/public/rank/rank_clsl.ts b/src/public/rank/rank_clsl.ts index 9bccaf0..0f9e243 100644 --- a/src/public/rank/rank_clsl.ts +++ b/src/public/rank/rank_clsl.ts @@ -23,8 +23,8 @@ export class RankClslCross extends Rank { return info?.valArr[0] || 0 } - async getRankList(uid: string, gud: player) { - let rankList = await this.getRankListAll(); + async getRankList(uid: string, {gud, min, max}) { + let rankList = await this.getRankListRange(min, max); let rank = await this.getRankSortByOne(uid); return { @@ -39,22 +39,19 @@ export class RankClslCross extends Rank { async addNew(info: rankInfo) { this.queue.enqueue(async () => { - let rankList = await this.getRankListAll() + // 积分大于配置的最小参数,更新数据 if (info.valArr[0] >= this.minStar) { - let myIndex = rankList.findIndex(li => li.player[this.findKey] == info.player[this.findKey]); - - if (myIndex != -1) { - rankList[myIndex] = info; - } else { - rankList.push(info); - } 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 && rankList.find(li => li.player[this.findKey] == info.player[this.findKey])) { - // this.list.removeOne(li => li.player[this.findKey] == info.player[this.findKey]); - this.delRankData(info.player[this.findKey]) - this.db.deleteOne({ type: this.type, idKey: info.player[this.findKey] }); + // 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]) + } } }); } diff --git a/src/public/rank/rank_hbzb_jfs.ts b/src/public/rank/rank_hbzb_jfs.ts index b693d94..2d9a290 100644 --- a/src/public/rank/rank_hbzb_jfs.ts +++ b/src/public/rank/rank_hbzb_jfs.ts @@ -21,9 +21,10 @@ export class RankHbzbJfsLocal extends Rank { getValArr(info: rankInfo):number|string { return info?.valArr[0] || 0 } - async getRankList(uid: string) { + async getRankList(uid: string, {min, max}) { let conn = G.server.uid_connections[uid]; - let rankList = await this.getRankListAll(); + // ###debug + let rankList = await this.getRankListRange(min, max); return { rankList: rankList, @@ -34,9 +35,9 @@ export class RankHbzbJfsLocal extends Rank { } }; } - async getCrossRankList(uid: string) { + async getCrossRankList(uid: string, page = 0, offset = 50) { let conn = G.server.uid_connections[uid]; - let callRes = await G.clientCross.callApi('hbzb/jfs/GetRankList', { uid: uid }); + let callRes = await G.clientCross.callApi('hbzb/jfs/GetRankList', { uid: uid, page , offset }); let list = callRes.res.rankList; let myRankIndex = list.findIndex(li => li.player.uid == uid); @@ -49,9 +50,9 @@ export class RankHbzbJfsLocal extends Rank { } }; } - async getZbsRankList(uid: string) { + async getZbsRankList(uid: string, page = 0, offset = 50) { let conn = G.server.uid_connections[uid]; - let callRes = await G.clientCross.callApi('hbzb/zbs/GetRankList', { uid: uid }); + let callRes = await G.clientCross.callApi('hbzb/zbs/GetRankList', { page, offset }); let list = callRes.res.rankList; let myRankIndex = list.findIndex(li => li.player.uid == uid); @@ -75,27 +76,39 @@ export class RankHbzbJfsCross extends RankHbzbJfsLocal { getType(): rankType { return 'hbzbCross'; } + async addNew(info: rankInfo) { - this.allPlayer[info.player.uid] = { - uid: info.player.uid, - jifen: info.valArr[0], - data: { - player: info.player, - roles: info.roles - } - }; - G.mongodb.collection('hbzb_user_cross').updateOne({ uid: info.player.uid }, { $set: { jifen: info.valArr[0], data: this.allPlayer[info.player.uid].data } }, { upsert: true }); + let data = { + player: info.player, + roles: info.roles + } + G.mongodb.collection('hbzb_user_cross').updateOne({ uid: info.player.uid }, { $set: { jifen: info.valArr[0], data: data } }, { upsert: true }); + this.setRankData(info.player.uid, info) Rank.prototype.addNew.call(this, info); } - allPlayer: k_v = {}; + // allPlayer: k_v = {}; + + // 初始化 async loadAllPlayer() { + if(await this.getRankLen() > 0) return let players = await G.mongodb.collection('hbzb_user_cross').find().toArray(); - players.forEach(p => { - let { _id, ...ops } = p; - this.allPlayer[ops.uid] = ops; - }); + players.forEach(item => { + if(item.uid && item.data) { + // 格式与其它排行榜不同,同步格式。 + let data:rankInfo = { + player: item.data.player, + roles: item.data.roles, + valArr: [item.jifen] + } + this.setRankData(item.uid, data) + } + }) } + + // 添加默认数据 + + async addJfsLog(uid: string, fightLog: fightResult) { if (uid.indexOf('npc') != -1) return; FightFun.saveLog(uid, 'hbzbJfs', fightLog); @@ -123,9 +136,8 @@ export class RankHbzbZbsCross extends Rank { return res } async changeRank(uid: string, toUid: string) { - let rankList = await this.getRankListAll(); - let role1 = rankList.find(li => li.player.uid == uid); - let role2 = rankList.find(li => li.player.uid == toUid); + let role1 = await this.getRankData(uid); + let role2 = await this.getRankData(toUid); if (role1 && role2 && role1.valArr[0] > role2.valArr[0]) { let temp = role1.valArr[0]; @@ -136,9 +148,10 @@ export class RankHbzbZbsCross extends Rank { this.addNew(role2); } } - async getRankList(uid: string) { - let rankList = await this.getRankListAll(); - let conn = rankList.find(li => li.player.uid == uid); + async getRankList(uid: string, {min, max}) { + let rankList = await this.getRankListRange(min, max); + // let conn = rankList.find(li => li.player.uid == uid); + let conn = await this.getRankData(uid) return { rankList: rankList, @@ -151,12 +164,13 @@ export class RankHbzbZbsCross extends Rank { async addNew(info: rankInfo) { this.queue.enqueue(async () => { - let rankList = await this.getRankListAll(); - let myIndex = rankList.findIndex(li => li.player[this.findKey] == info.player[this.findKey]); - - if (myIndex != -1) { - rankList[myIndex] = info; - } + // 原逻辑排名最高50条,更新ranklist内排名数据, + // let rankList = await this.getRankListRange(); + // let myIndex = rankList.findIndex(li => li.player[this.findKey] == info.player[this.findKey]); + // if (myIndex != -1) { + // rankList[myIndex] = info; + // } + // 当前更新redis相关数据即可 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); diff --git a/src/public/rank/rank_kbzz.ts b/src/public/rank/rank_kbzz.ts index e2314b9..aec87a5 100644 --- a/src/public/rank/rank_kbzz.ts +++ b/src/public/rank/rank_kbzz.ts @@ -39,13 +39,14 @@ export class RankKbzz extends Rank { return res } - async getRankList(uid: string) { - let rankList = await this.getRankListAll(); + async getRankList(uid: string, {min, max}) { + let rankList = await this.getRankListRange(min, max); + let gud = await this.getRankData(uid) return { rankList: rankList, myRank: { rank: await this.getRankSortByOne(uid), - player: {}, + player: gud?.player || {}, valArr: [(await G.mongodb.collection('kbzzGroupUser').findOne({ uid: uid }))?.score || 1000] } }; diff --git a/src/public/rank/rank_power.ts b/src/public/rank/rank_power.ts index 0a21886..664485d 100644 --- a/src/public/rank/rank_power.ts +++ b/src/public/rank/rank_power.ts @@ -17,9 +17,9 @@ export class RankPower extends Rank { getValArr(info: rankInfo):number|string { return info?.valArr[0] || 0 } - async getRankList(uid: string): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { + async getRankList(uid: string, {min, max}): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { let conn = G.server.uid_connections[uid]; - let rankList = await this.getRankListAll() + let rankList = await this.getRankListRange(min, max) return { rankList: rankList, diff --git a/src/public/rank/rank_qjzzd.ts b/src/public/rank/rank_qjzzd.ts index 10e2e58..ecdbd28 100644 --- a/src/public/rank/rank_qjzzd.ts +++ b/src/public/rank/rank_qjzzd.ts @@ -19,9 +19,10 @@ export class RankQjzzd extends Rank { return info?.valArr[0] || 0 } - async getRankList(uid: string): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { + async getRankList(uid: string, {min, max}): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { let conn = G.server.uid_connections[uid]; - let rankList = await this.getRankListAll() + // debug + let rankList = await this.getRankListRange(min, max) return { rankList: rankList, myRank: { diff --git a/src/public/rank/rank_slzd.ts b/src/public/rank/rank_slzd.ts index 649e7e6..a62e3fc 100644 --- a/src/public/rank/rank_slzd.ts +++ b/src/public/rank/rank_slzd.ts @@ -21,9 +21,10 @@ export class RankSlzd1 extends Rank { return info?.valArr[0] || 0 } - async getRankList(ghid: string): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { - let rankList = await this.getRankListAll() - let li = rankList.find(l => l.player.ghId == ghid); + async getRankList(ghid: string, { min, max }): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { + let rankList = await this.getRankListRange( min, max ) + // let li = rankList.find(l => l.player.ghId == ghid); // debug 查询自身数据 + let li = await this.getRankData(ghid); return { rankList: rankList, myRank: { diff --git a/src/public/rank/rank_tanxian.ts b/src/public/rank/rank_tanxian.ts index ae53ba4..493ea38 100644 --- a/src/public/rank/rank_tanxian.ts +++ b/src/public/rank/rank_tanxian.ts @@ -17,9 +17,9 @@ export class RankTanXian extends Rank { getValArr(info: rankInfo):number|string { return info?.valArr[0] || 0 } - async getRankList(uid: string): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { + async getRankList(uid: string, { min, max }): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { let conn = G.server.uid_connections[uid]; - let rankList = await this.getRankListAll() + let rankList = await this.getRankListRange(min, max) return { rankList: rankList, myRank: { diff --git a/src/public/rank/rank_tujian.ts b/src/public/rank/rank_tujian.ts index 89be82b..6507dc2 100644 --- a/src/public/rank/rank_tujian.ts +++ b/src/public/rank/rank_tujian.ts @@ -21,9 +21,9 @@ export class RankTujian extends Rank { return info?.valArr[0] || 0 } - async getRankList(uid: string): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { + async getRankList(uid: string, { min, max }): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { let conn = G.server.uid_connections[uid]; - let rankList = await this.getRankListAll(); + let rankList = await this.getRankListRange(min, max); return { rankList: rankList, myRank: { diff --git a/src/public/rank/rank_wzry.ts b/src/public/rank/rank_wzry.ts index 84f69bd..459fa02 100644 --- a/src/public/rank/rank_wzry.ts +++ b/src/public/rank/rank_wzry.ts @@ -23,15 +23,13 @@ export class RankWzryCross extends Rank { } async getPlayerRank(uid: string): Promise { - let _r = await this.getRankListAll(); - if (!Object.keys(_r).length) { - return -1 - } - return _r.findIndex(li => li.player.uid == uid) + 1 || -1; + // 获取用户指定排名 + let rank = await this.getRankSortByOne(uid) + return rank + 1; // 原逻辑有+1操作,与其它地点取排名逻辑有差异 } - async getRankList(uid: string, gud: player) { - let rankList = await this.getRankListAll(); + async getRankList(uid: string, {gud, min, max }) { + let rankList = await this.getRankListRange(min, max); return { rankList: rankList, diff --git a/src/public/rank/rank_xszm.ts b/src/public/rank/rank_xszm.ts index e5c92c6..13be60b 100644 --- a/src/public/rank/rank_xszm.ts +++ b/src/public/rank/rank_xszm.ts @@ -25,9 +25,9 @@ export class RankXszm extends Rank { return res } - async getRankList(uid: string): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { + async getRankList(uid: string, { min, max }): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { let conn = G.server.uid_connections[uid]; - let rankList = await this.getRankListAll(); + let rankList = await this.getRankListRange(min, max); return { rankList: rankList, myRank: { diff --git a/src/public/rank/rank_zccg.ts b/src/public/rank/rank_zccg.ts index 95abf1a..9b21e3a 100644 --- a/src/public/rank/rank_zccg.ts +++ b/src/public/rank/rank_zccg.ts @@ -21,9 +21,9 @@ export class RankZccg extends Rank { return info?.valArr[0] || 0 } - async getRankList(uid: string): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { + async getRankList(uid: string, { min, max }): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> { let conn = G.server.uid_connections[uid]; - let rankList = await this.getRankListAll(); + let rankList = await this.getRankListRange(min, max); return { rankList: rankList, myRank: { diff --git a/src/public/scheduler/scheduler.ts b/src/public/scheduler/scheduler.ts index 8bcaf15..56bb8e6 100644 --- a/src/public/scheduler/scheduler.ts +++ b/src/public/scheduler/scheduler.ts @@ -24,7 +24,7 @@ export class SchedulerManage { static onlyPm2() { setInterval(() => { - Scheduler.schedulers.forEach(s => s.cheak()); // ### debug 方法奖励等定时器检测 + Scheduler.schedulers.forEach(s => s.cheak()); }, 1000); } } diff --git a/src/public/scheduler/scheduler_hbzb.ts b/src/public/scheduler/scheduler_hbzb.ts index 628966c..1116b7b 100644 --- a/src/public/scheduler/scheduler_hbzb.ts +++ b/src/public/scheduler/scheduler_hbzb.ts @@ -58,7 +58,7 @@ export class Scheduler_hbzb_zbs_local_prize extends Scheduler { async start() { - let crossRank = (await G.clientCross.callApi('hbzb/zbs/GetRankList', { uid: '' })).res.rankList; + let crossRank = (await G.clientCross.callApi('hbzb/zbs/GetRankList', {})).res.rankList; this.sendEmail(crossRank.map(rank => { return { uid: rank.player.uid, valArr: [...rank.valArr] }; })); // crossRank.length > 0 && ChatFun.newMsg({ @@ -123,13 +123,10 @@ export class Scheduler_hbzb_zbs_cross_ready extends Scheduler { } async start() { - let rankList = await Rank.list.hbzbCross.getRankListAll() + let top100 = await Rank.list.hbzbCross.getRankListRange(0, 100) let zbsRankList = await Rank.list.hbzbZbsCross.getRankListAll() - let top100 = rankList.slice(0, 100); let top100uids = top100.map(t => t.player.uid); - console.log(Rank.list.hbzbZbsCross); - top100.push(...zbsRankList.filter(l => !top100uids.includes(l.player.uid)).sort((a, b) => b.player.power - a.player.power)); zbsRankList = top100.map((v, i) => { diff --git a/src/public/task.ts b/src/public/task.ts index 902a7ef..f0389bf 100644 --- a/src/public/task.ts +++ b/src/public/task.ts @@ -98,8 +98,14 @@ export class TaskFun { static async setTaskVal(call: ApiCall, stype: number, val: number, chkCall: Function, chkval: number = 0, isinc: number = 0, alchangeVal: Function, arg) { let uid = call.uid; // let _unFinish = await this.getFinishByStype(call, stype, { finish: 0, "$where": "return this.pval > this.nval" }); - let _unFinish = await this.getFinishByStype(call, stype, {finish: 0}); - _unFinish = _unFinish.filter(x => x.pval > x.nval) + //let _unFinish = await this.getFinishByStype(call, stype, {finish: 0}); + //_unFinish = _unFinish.filter(x => x.pval > x.nval) + let _unFinish = await this.getFinishByStype(call, stype, { + finish: 0, '$expr': { + $gt: ["$pval", "$nval"] + } + }); + if (_unFinish.length == 0) return; for (let index = 0; index < _unFinish.length; index++) { const _task = _unFinish[index]; @@ -138,6 +144,10 @@ export class TaskFun { let _setData = {nval: _resVal}; let _where = {taskid: _task["taskid"]}; await this.setTask(uid, _where, _setData); + + if (_resVal == _pval) { + call.conn.sendMsg('msg_s2c/TaskChange', {..._task, nval: _resVal}) + } } } @@ -299,8 +309,8 @@ export class TaskFun { * 生成所有任务 */ static async generateAllTask(call: ApiCall) { - let _r = await G.mongodb.collection(SHUJUKU).findOne({uid: call.uid}); - if (_r) return; + let _r = await G.mongodb.collection(SHUJUKU).count({uid: call.uid}); + if (_r > 0) return; let _taskInfo = []; let _con = G.gc.task; for (let _type in _con) { @@ -320,9 +330,9 @@ export class TaskFun { /**生成指定类型任务-初始化 */ static async reInitTask(call: ApiCall, type: string) { // 查询类型任务是否存在 - let _r = await G.mongodb.collection(SHUJUKU).findOne({uid: call.uid, type: ~~type}); + let _r = await G.mongodb.collection(SHUJUKU).count({uid: call.uid, type: ~~type}); let _taskInfo = []; - if (!_r) { + if (_r == 0) { let _con = G.gc.task; // 数据不存在,未初始化,执行初始化 for (let _taskid in _con[type]) { @@ -333,7 +343,7 @@ export class TaskFun { } } } - await this.insertTasks(call, _taskInfo); + _taskInfo.length > 0 && await this.insertTasks(call, _taskInfo); return _taskInfo; } @@ -412,11 +422,17 @@ export class TaskFun { const element = Object.keys(_ttype)[index]; if ((element == "1" || element == "3") && call.conn.gud.lv < 7) continue; let _values: number[] = _ttype[element]; - let _where: {} = {uid: call.uid, type: {$in: _values}, finish: 0}; + let _where: {} = { + uid: call.uid, type: {$in: _values}, finish: 0, '$expr': { + $lte: ["$pval", "$nval"] + } + }; - let taskArr = await G.mongodb.collection(SHUJUKU).find(_where).toArray(); - let _tmp = taskArr.filter(x => x.pval <= x.nval) - if (_tmp.length) { + //let taskArr = await G.mongodb.collection(SHUJUKU).find(_where).toArray(); + let count = await G.mongodb.collection(SHUJUKU).count(_where); + //let _tmp = taskArr.filter(x => x.pval <= x.nval) + //if (_tmp.length) { + if (count > 0) { _res.show = true; _res.val.tasktypes.push(element); } diff --git a/src/public/wzry.ts b/src/public/wzry.ts index 2faf393..afd68fb 100644 --- a/src/public/wzry.ts +++ b/src/public/wzry.ts @@ -1,8 +1,8 @@ -import { ApiCall } from 'tsrpc'; -import { formatNpcData } from '../shared/fightControl/fightFun'; -import { hongdianVal } from '../shared/protocols/hongdian/PtlGet'; -import { wangzherongyao_baoming, wangzherongyao_staus, wzry_info } from '../shared/protocols/wzry/PtlOpen'; -import { PublicShared } from '../shared/public/public'; +import {ApiCall} from 'tsrpc'; +import {formatNpcData} from '../shared/fightControl/fightFun'; +import {hongdianVal} from '../shared/protocols/hongdian/PtlGet'; +import {wangzherongyao_baoming, wangzherongyao_staus, wzry_info} from '../shared/protocols/wzry/PtlOpen'; +import {PublicShared} from '../shared/public/public'; export class WangZheRongYaofun { @@ -18,8 +18,8 @@ export class WangZheRongYaofun { let _con = _tmp.wangzhe.timestatus; let _weekOneTime = PublicShared.getToWeekMondayZeroTime(); let _res: wangzherongyao_staus = { // 默认比赛结束状态 - status: 8, - stime: _weekOneTime + 7 * 24 * 3600, + status: _con[_con.length - 1].status + 1, + stime: _weekOneTime + _con[_con.length - 1].etime, etime: _weekOneTime + 7 * 24 * 3600 }; for (let index = 0; index < _con.length; index++) { @@ -40,7 +40,7 @@ export class WangZheRongYaofun { /**获取报名人数 */ static async getBaoMingNum() { let zkey: string = PublicShared.getToWeek(); - let _num = G.mongodb.collection('playerInfo', 'wzry').countDocuments({ isbm: 1 }); + let _num = G.mongodb.collection('playerInfo', 'wzry').countDocuments({isbm: 1}); return _num; } @@ -59,9 +59,12 @@ export class WangZheRongYaofun { isjjzs: 0, uid: call.uid, }; - let _mydata = await G.mongodb.collection('playerInfo', 'wzry').findOne({ uid: call.conn.uid, type: 'wzry' }); + let _mydata = await G.mongodb.collection('playerInfo', 'wzry').findOne({uid: call.conn.uid, type: 'wzry'}); if (!_mydata) { - await G.mongodb.collection('playerInfo', 'wzry').updateOne({ uid: call.uid, type: 'wzry' }, { $set: _res }, { upsert: true }); + await G.mongodb.collection('playerInfo', 'wzry').updateOne({ + uid: call.uid, + type: 'wzry' + }, {$set: _res}, {upsert: true}); return _res; } else { delete _mydata._id; @@ -71,15 +74,15 @@ export class WangZheRongYaofun { /**设置报名数据 */ static async setWzryBaoMing(call: ApiCall, setData: { [id: string]: any; }) { - await G.mongodb.cPlayerInfo("wzry").updateOne({ uid: call.uid, type: 'wzry' }, { $set: setData }, { upsert: true }); + await G.mongodb.cPlayerInfo("wzry").updateOne({uid: call.uid, type: 'wzry'}, {$set: setData}, {upsert: true}); let data = await call.conn.getDefaultFightData(); - let _res = await G.clientCross.callApi('wzry/BaoMing', { zkey: setData.zkey, data: data }); + let _res = await G.clientCross.callApi('wzry/BaoMing', {zkey: setData.zkey, data: data}); return _res; } /**获取我的wzry战斗数据 */ static async getMyFight(call: ApiCall) { - let _res = await G.clientCross.callApi('wzry/WzFightData', { uid: call.uid, iswzfight: true }); + let _res = await G.clientCross.callApi('wzry/WzFightData', {uid: call.uid, iswzfight: true}); if (_res.isSucc && _res.res.info) { return _res.res.info; } @@ -88,7 +91,7 @@ export class WangZheRongYaofun { /**获取王者之巅数据 */ static async getWzzd(uid: string) { - let _res = await G.clientCross.callApi('wzry/WzFightData', { uid: uid, iswzzd: true }); + let _res = await G.clientCross.callApi('wzry/WzFightData', {uid: uid, iswzzd: true}); return _res; } @@ -103,7 +106,7 @@ export class WangZheRongYaofun { /**获取wzry某一组数据 */ static async getFightGroup(call: ApiCall, where: {}) { - let _res = await G.clientCross.callApi('wzry/WzFightGroup', { where: where }); + let _res = await G.clientCross.callApi('wzry/WzFightGroup', {where: where}); if (_res.isSucc && _res.res.info) { return _res.res.info; } @@ -112,8 +115,8 @@ export class WangZheRongYaofun { /**wzry 结束 删除相关数据 */ static async delGroup() { - let _res = await G.clientCross.callApi('wzry/WzFightData', { uid: '', isdel: true }); - await G.mongodb.collection('playerInfo', 'wzry').updateMany({ type: 'wzry' }, { + let _res = await G.clientCross.callApi('wzry/WzFightData', {uid: '', isdel: true}); + await G.mongodb.collection('playerInfo', 'wzry').updateMany({type: 'wzry'}, { $set: { isdldrefre: 0, isbm: 0, @@ -134,7 +137,7 @@ export class WangZheRongYaofun { /**设置大乱斗战斗数据 */ static async setWzryDldFight(call: ApiCall, Fight: wangzherongyao_baoming) { let data = Fight.data; - let _res = await G.clientCross.callApi('wzry/SetWzFight', { zkey: Fight.zkey, data: data, jifen: Fight.jifen }); + let _res = await G.clientCross.callApi('wzry/SetWzFight', {zkey: Fight.zkey, data: data, jifen: Fight.jifen}); return _res.res; } @@ -199,7 +202,7 @@ export class WangZheRongYaofun { } if (!_res.show && status.status == 15 && !_mydata?.isjingcai?.totalmoney) { - let _jcList = await WangZheRongYaofun.getFightGroup(call, { deep: { $gte: 5 } }); + let _jcList = await WangZheRongYaofun.getFightGroup(call, {deep: {$gte: 5}}); if (_jcList) { _res.show = true; } diff --git a/src/setRedis.ts b/src/setRedis.ts index dfd7d90..1889b9b 100644 --- a/src/setRedis.ts +++ b/src/setRedis.ts @@ -91,7 +91,7 @@ export class _redis implements redisJsonFun { // this.logMsg = str; // } } - fromatKey(key: string, state: 'zAdd' | 'zRange' | 'zRem' | 'zRevRank' | 'zRank' | 'zCard' | 'hGet' | 'hGetAll' | 'hLen' | 'hSet' | 'hDel' | 'del' | 'numIncrBy' | 'type' | 'get' | 'set' | 'arrAppend' | 'arrPop' | 'arrLen' | 'arrInsert' | null) { + fromatKey(key: string, state: 'zAdd' | 'zRange' | 'zRevRange' | 'zRem' | 'zRevRank' | 'zRank' | 'zCard' | 'hGet' | 'hmGet' | 'hGetAll' | 'hLen' | 'hSet' | 'hDel' | 'del' | 'numIncrBy' | 'type' | 'get' | 'set' | 'arrAppend' | 'arrPop' | 'arrLen' | 'arrInsert' | null) { let sid = G.config.serverId || 0; let fmtKey = `${G.config.projectName}_${G.argv.serverType == 'cross' ? `corss${sid}` : sid}_${key}`; state && this.log(state + ' ' + fmtKey, 'start'); @@ -115,6 +115,16 @@ export class _redis implements redisJsonFun { } catch (err) {} return result } + async hmGet() { + let _args = Array.from(arguments); + let result = await this.redis.hmGet(this.fromatKey(_args[0], 'hmGet'), _args[1]); + try{ + for(let i in result) { + result[i] = JSON.parse(result[i]) + } + } catch(err) {} + return result + } async hGetAll() { let _args = Array.from(arguments); @@ -168,6 +178,15 @@ export class _redis implements redisJsonFun { let _args = Array.from(arguments); return await this.redis.zRange(this.fromatKey(_args[0], 'zRange'), _args[1], _args[2]) } + + + async zRevRange() { + let _args = Array.from(arguments); + this.redis.zRange + return await this.redis.zRange(this.fromatKey(_args[0], 'zRange'), _args[1], _args[2], {REV: true}) + } + + /** * 获取指定key排名 @@ -555,9 +574,12 @@ export interface redisJsonFun { hGet>(key: key, hash:string): Promise; hGet>(key: key, hash:string): Promise; - + // 变量传key无法通过检测时,不做强制key类型验证。 hGet(key: key, hash:string): Promise; + + hmGet>(key: key, hash:string[]): Promise; + hmGet(key: key, hash:string[]): Promise; /**获取全部的hash数据 */ hGetAll>(key: key):Promise; @@ -586,8 +608,12 @@ export interface redisJsonFun { * @param key */ zRange>(key: key, min: number, max: number): Promise; - + zRange(key: key, min: number, max: number): Promise; + + zRevRange>(key: key, min: number, max: number): Promise; + + zRevRange(key: key, min: number, max: number): Promise; /** * 取出指定member排名数据 diff --git a/src/shared/fightControl/fightCntrol.ts b/src/shared/fightControl/fightCntrol.ts index ee10fe9..38fb7e5 100644 --- a/src/shared/fightControl/fightCntrol.ts +++ b/src/shared/fightControl/fightCntrol.ts @@ -214,6 +214,7 @@ export class FightControl { this.winSide = winside as 1 | 0; this.record({ act: 'fightEnd', winSide: this.winSide }); + this.event.removeAllListeners() } eachLiveRoles(callback: (role: Role) => void) { diff --git a/src/shared/protocols/rank/PtlOpen.ts b/src/shared/protocols/rank/PtlOpen.ts index cdaa8e5..a020fd2 100644 --- a/src/shared/protocols/rank/PtlOpen.ts +++ b/src/shared/protocols/rank/PtlOpen.ts @@ -3,7 +3,7 @@ import { rankInfo } from '../type'; /** * 排行榜 */ -export type ReqOpen = Array; +export type ReqOpen = rankTypeObj|Array; export type ResOpen = { [type: string]: { @@ -15,4 +15,10 @@ 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'; \ No newline at end of file + | 'zccg' | 'gbzl' | 'tujian' | 'wzryCross'; + +export type rankTypeObj = { + type?: rankType[], + page?: number, + offset?: number +} \ No newline at end of file diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index 648f80b..ca19845 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -18019,11 +18019,59 @@ export const serviceProto: ServiceProto = { "type": "Interface" }, "rank/PtlOpen/ReqOpen": { - "type": "Array", - "elementType": { - "type": "Reference", - "target": "rank/PtlOpen/rankType" - } + "type": "Union", + "members": [ + { + "id": 0, + "type": { + "type": "Reference", + "target": "rank/PtlOpen/rankTypeObj" + } + }, + { + "id": 1, + "type": { + "type": "Array", + "elementType": { + "type": "Reference", + "target": "rank/PtlOpen/rankType" + } + } + } + ] + }, + "rank/PtlOpen/rankTypeObj": { + "type": "Interface", + "properties": [ + { + "id": 0, + "name": "type", + "type": { + "type": "Array", + "elementType": { + "type": "Reference", + "target": "rank/PtlOpen/rankType" + } + }, + "optional": true + }, + { + "id": 1, + "name": "page", + "type": { + "type": "Number" + }, + "optional": true + }, + { + "id": 2, + "name": "offset", + "type": { + "type": "Number" + }, + "optional": true + } + ] }, "rank/PtlOpen/rankType": { "type": "Union",