init
This commit is contained in:
parent
3163d85652
commit
7d8dff9799
@ -3,5 +3,8 @@ import { ReqRank, ResRank } from "../../cross/protocols/clsl/PtlRank";
|
|||||||
import { Rank } from '../../public/rank/rank';
|
import { Rank } from '../../public/rank/rank';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRank, ResRank>) {
|
export default async function (call: ApiCall<ReqRank, ResRank>) {
|
||||||
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 }));
|
||||||
}
|
}
|
@ -3,8 +3,7 @@ import { ReqRankUids, ResRankUids } from "../../cross/protocols/clsl/PtlRankUids
|
|||||||
import { Rank } from '../../public/rank/rank';
|
import { Rank } from '../../public/rank/rank';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRankUids, ResRankUids>) {
|
export default async function (call: ApiCall<ReqRankUids, ResRankUids>) {
|
||||||
let rankList = await Rank.list.clslCross.getRankListAll()
|
// 返回排名的uids, 应用场景是定时器发送奖励,不分页。
|
||||||
call.succ({
|
let uids = await Rank.list.clslCross.getRankListIdKeyAll()
|
||||||
uids: rankList.map(li => li.player.uid)
|
call.succ({uids});
|
||||||
});
|
|
||||||
}
|
}
|
@ -3,41 +3,58 @@ import { ReqGetEnemy, ResGetEnemy } from "../../../cross/protocols/hbzb/jfs/PtlG
|
|||||||
import { Rank } from '../../../public/rank/rank';
|
import { Rank } from '../../../public/rank/rank';
|
||||||
import { formatNpcData } from '../../../shared/fightControl/fightFun';
|
import { formatNpcData } from '../../../shared/fightControl/fightFun';
|
||||||
import { PublicShared } from "../../../shared/public/public";
|
import { PublicShared } from "../../../shared/public/public";
|
||||||
|
import { rankInfo } from "../../../shared/protocols/type";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
||||||
// TODO
|
// TODO ### debug allPlayer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
let allPlayers = Rank.list.hbzbCross.allPlayer;
|
let allPlayers:rankInfo[] = <rankInfo[]>await Rank.list.hbzbCross.getRankListRange();
|
||||||
let user = allPlayers[call.req.uid];
|
let user:rankInfo = <rankInfo>await Rank.list.hbzbCross.getRankData(call.req.uid);
|
||||||
if (!user) return call.succ({ enemy: [] });
|
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 conf = call.req.auto ? G.gc.hbzb.jfsMatchingAuto : G.gc.hbzb.jfsMatchingHand;
|
||||||
let rang = conf.map(val => {
|
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 min = rang.slice(-1)[0][0];
|
||||||
let max = rang[0][1];
|
let max = rang[0][1];
|
||||||
let players = Object.values(allPlayers).filter(p => {
|
let players = allPlayers.filter(p => {
|
||||||
return p.data.player.power >= min && p.data.player.power <= max && p.data.player.uid != call.req.uid;
|
return p.player.power >= min && p.player.power <= max && p.player.uid != call.req.uid;
|
||||||
});
|
});
|
||||||
let select: string[] = [];
|
let select: string[] = [];
|
||||||
let enemy = rang.map((r, index) => {
|
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) {
|
if (es.length > 0) {
|
||||||
let { uid, ...ops } = es.random();
|
let ops = es.random();
|
||||||
select.push(uid);
|
if(ops) {
|
||||||
return ops;
|
let data:any = {
|
||||||
|
data: {
|
||||||
|
player: ops.player,
|
||||||
|
roles: ops.roles
|
||||||
|
},
|
||||||
|
jifen: ops.valArr[0]
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
data: getNpc(user.data.player.lv, index),
|
data: getNpc(user.player.lv, index),
|
||||||
jifen: 1000
|
jifen: 1000
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
call.succ({ enemy: enemy });
|
call.succ({ enemy: enemy });
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNpc(lv: number, index: number) {
|
function getNpc(lv: number, index: number) {
|
||||||
let rang = G.gc.hbzb.jfsRefreshNpcId.find(v => lv >= v.lvs[0] && lv <= v.lvs[1]);
|
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;
|
||||||
}
|
}
|
@ -3,7 +3,12 @@ import { ReqGetRankList, ResGetRankList } from "../../../cross/protocols/hbzb/jf
|
|||||||
import { Rank } from '../../../public/rank/rank';
|
import { Rank } from '../../../public/rank/rank';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetRankList, ResGetRankList>) {
|
export default async function (call: ApiCall<ReqGetRankList, ResGetRankList>) {
|
||||||
let rankList = await Rank.list.hbzbCross.getRankListAll()
|
let page = call.req.page || 0
|
||||||
// TODO
|
let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
||||||
call.succ({ rankList: rankList, jifen: Rank.list.hbzbCross.allPlayer[call.req.uid]?.jifen || 1000 });
|
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 });
|
||||||
}
|
}
|
@ -1,22 +1,43 @@
|
|||||||
import {ApiCall} from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import {ReqGetEnemy, ResGetEnemy} from "../../../cross/protocols/hbzb/zbs/PtlGetEnemy";
|
import {ReqGetEnemy, ResGetEnemy} from "../../../cross/protocols/hbzb/zbs/PtlGetEnemy";
|
||||||
import {Rank} from '../../../public/rank/rank';
|
import {Rank} from '../../../public/rank/rank';
|
||||||
|
import { rankInfo } from "../../../shared/protocols/type";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
||||||
let list = await Rank.list.hbzbZbsCross.getRankListAll();
|
let enemys:rankInfo[] = await Rank.list.hbzbZbsCross.getRankListRange(0, 10);
|
||||||
let enemys = list.slice(0, 10);
|
enemys.forEach((_, i) => {
|
||||||
let myRank = list.findIndex(e => e.player.uid == call.req.uid);
|
enemys[i].rank = i
|
||||||
|
})
|
||||||
|
let myRank:number = await Rank.list.hbzbZbsCross.getRankSortByOne(call.req.uid);
|
||||||
|
|
||||||
|
// 随机匹配其它对手
|
||||||
|
let rankArr = []
|
||||||
if (myRank > 8) {
|
if (myRank > 8) {
|
||||||
if (myRank == 9) enemys.push(list.slice(10, 5).random());
|
if(myRank < 10) {
|
||||||
else if (myRank == 10) enemys.push(list.slice(11, 5).random());
|
let min = myRank + 1
|
||||||
else {
|
let max = myRank + 6
|
||||||
let two = list.slice(10, myRank - 10).shuffle();
|
let randomRank = Math.round(Math.random() * (max - min) + min)
|
||||||
enemys.push(...two.slice(0, 2));
|
rankArr.push(randomRank)
|
||||||
enemys.push(list.slice(myRank + 1, 5).random());
|
}
|
||||||
|
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({
|
call.succ({
|
||||||
enemy: enemys.map((e, i) => ({
|
enemy: enemys.map((e, i) => ({
|
||||||
@ -24,7 +45,7 @@ export default async function (call: ApiCall<ReqGetEnemy, ResGetEnemy>) {
|
|||||||
player: e.player,
|
player: e.player,
|
||||||
roles: e.roles
|
roles: e.roles
|
||||||
},
|
},
|
||||||
rank: i
|
rank: e.rank
|
||||||
})),
|
})),
|
||||||
rank: myRank
|
rank: myRank
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,9 @@ import { ReqGetRankList, ResGetRankList } from "../../../cross/protocols/hbzb/zb
|
|||||||
import { Rank } from '../../../public/rank/rank';
|
import { Rank } from '../../../public/rank/rank';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetRankList, ResGetRankList>) {
|
export default async function (call: ApiCall<ReqGetRankList, ResGetRankList>) {
|
||||||
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 });
|
call.succ({ rankList: rankList });
|
||||||
}
|
}
|
@ -2,14 +2,18 @@ import { ApiCall } from "tsrpc";
|
|||||||
import { ReqRank, ResRank } from "../../cross/protocols/kbzz/PtlRank";
|
import { ReqRank, ResRank } from "../../cross/protocols/kbzz/PtlRank";
|
||||||
import { RankKbzz } from '../../public/rank/rank_kbzz';
|
import { RankKbzz } from '../../public/rank/rank_kbzz';
|
||||||
|
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRank, ResRank>) {
|
export default async function (call: ApiCall<ReqRank, ResRank>) {
|
||||||
|
let page = call.req.page || 0
|
||||||
|
let offset = call.req.offset || -1 // 预防未查询到的调用,按原逻辑查询全部,避免引起未知问题
|
||||||
let _cunzai = await G.mongodb.collection('kbzzGroupTroop').findOne({})
|
let _cunzai = await G.mongodb.collection('kbzzGroupTroop').findOne({})
|
||||||
if (!_cunzai) {
|
if (!_cunzai) {
|
||||||
return call.error('', { code: -1, message: '功能未开放' })
|
return call.error('', { code: -1, message: '功能未开放' })
|
||||||
}
|
}
|
||||||
let db = await G.mongodb.collection('kbzzGroupUser').findOne({ uid: call.req.uid });
|
let db = await G.mongodb.collection('kbzzGroupUser').findOne({ uid: call.req.uid });
|
||||||
let group = db?.group || 0;
|
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({
|
call.succ({
|
||||||
...rank
|
...rank
|
||||||
|
@ -9,7 +9,10 @@ import { WangZheRongYaofun } from "../../public/wzry";
|
|||||||
import { PublicShared } from "../../shared/public/public";
|
import { PublicShared } from "../../shared/public/public";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRank, ResRank>) {
|
export default async function (call: ApiCall<ReqRank, ResRank>) {
|
||||||
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);
|
call.succ(_r);
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
|||||||
let change: ResRefresh['change'] = {};
|
let change: ResRefresh['change'] = {};
|
||||||
change.useRefreshNum = dbData.data.useRefreshNum + 1;
|
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 }; });
|
change.enemy = callRes.res.enemy.map(e => { return { ...e, result: null }; });
|
||||||
|
|
||||||
await G.mongodb.cPlayerInfo('hbzb').updateOne(
|
await G.mongodb.cPlayerInfo('hbzb').updateOne(
|
||||||
|
@ -4,21 +4,42 @@ import { Rank } from '../../public/rank/rank';
|
|||||||
import { ReqOpen, ResOpen } from "../../shared/protocols/rank/PtlOpen";
|
import { ReqOpen, ResOpen } from "../../shared/protocols/rank/PtlOpen";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
|
|
||||||
let obj = await rankOpenfun(call, call.req)
|
let obj = await rankOpenfun(call, call.req)
|
||||||
call.succ(obj);
|
call.succ(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ### debug 参数需调整,req数组应使用types字段接收,需增加分页参数,需前端配合,优化redis存储暂不改。
|
// 参数需调整,req数组应使用types字段接收,需增加分页参数,需前端配合,优化redis存储暂不改。
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param call
|
||||||
|
* @param req <array> 旧模式兼容,保留数组的判断
|
||||||
|
* @param req.type <array> 查询数据的类型
|
||||||
|
* @param req.page 页码,从0开始
|
||||||
|
* @param req.offset 每页条数
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export async function rankOpenfun(call, req: ReqOpen): Promise<ResOpen> {
|
export async function rankOpenfun(call, req: ReqOpen): Promise<ResOpen> {
|
||||||
let obj: ResOpen = {};
|
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) {
|
switch (type) {
|
||||||
case 'jjc':
|
case 'jjc':
|
||||||
// 获取前50名ranklist数据
|
// 获取前50名ranklist数据
|
||||||
let rankList = await JJCFun.getRankList(0, 50);
|
let rankList = await JJCFun.getRankList(min, max);
|
||||||
// 获取自己的排名
|
// 获取自己的排名
|
||||||
let myRank = await JJCFun.getPlayerRank(call.uid)
|
let myRank = await JJCFun.getPlayerRank(call.uid)
|
||||||
// 获取自己的rank信息
|
// 获取自己的rank信息
|
||||||
@ -34,10 +55,10 @@ export async function rankOpenfun(call, req: ReqOpen): Promise<ResOpen> {
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 'hbzbCross':
|
case 'hbzbCross':
|
||||||
obj[type] = await Rank.list.hbzbLocal.getCrossRankList(call.uid);
|
obj[type] = await Rank.list.hbzbLocal.getCrossRankList(call.uid, page, offset);
|
||||||
break;
|
break;
|
||||||
case 'hbzbZbsCross':
|
case 'hbzbZbsCross':
|
||||||
obj[type] = await Rank.list.hbzbLocal.getZbsRankList(call.uid);
|
obj[type] = await Rank.list.hbzbLocal.getZbsRankList(call.uid, page, offset);
|
||||||
break;
|
break;
|
||||||
case 'slzd1':
|
case 'slzd1':
|
||||||
case 'slzd2':
|
case 'slzd2':
|
||||||
@ -45,25 +66,25 @@ export async function rankOpenfun(call, req: ReqOpen): Promise<ResOpen> {
|
|||||||
case 'slzd4':
|
case 'slzd4':
|
||||||
case 'slzd5':
|
case 'slzd5':
|
||||||
case 'slzd6':
|
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;
|
break;
|
||||||
case 'kbzz':
|
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) {
|
if (!resCall.isSucc) {
|
||||||
return call.error('', { code: -2, message: globalThis.lng.rank_kbzz });
|
return call.error('', { code: -2, message: globalThis.lng.rank_kbzz });
|
||||||
}
|
}
|
||||||
obj[type] = resCall.res;
|
obj[type] = resCall.res;
|
||||||
break;
|
break;
|
||||||
case 'clslCross':
|
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;
|
obj[type] = resCallClsl.res;
|
||||||
break;
|
break;
|
||||||
case 'wzryCross':
|
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;
|
obj[type] = resCallWzry.res;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
obj[type] = await Rank.list[type].getRankList(call.uid);
|
obj[type] = await Rank.list[type].getRankList(call.uid, {min, max});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,13 +37,14 @@ export default async function (call: ApiCall<ReqFinsh, ResFinsh>) {
|
|||||||
|
|
||||||
// 检测生成后续任务
|
// 检测生成后续任务
|
||||||
let _follow = _con["followtask"]
|
let _follow = _con["followtask"]
|
||||||
let newTask: taskType
|
let newTask = {}
|
||||||
if (_follow) {
|
if (_follow) {
|
||||||
// 检测生成新任务
|
// 检测生成新任务
|
||||||
newTask = await TaskFun.setTaskInfo(call, _follow, _task)
|
newTask = await TaskFun.setTaskInfo(call, _follow, _task)
|
||||||
}
|
}
|
||||||
// 设置数据
|
// 设置数据
|
||||||
await TaskFun.setTask(call.uid, {taskid: taskid}, {finish: 1})
|
await TaskFun.setTask(call.uid, {taskid: taskid}, {finish: 1})
|
||||||
|
|
||||||
let _prize = await PlayerFun.sendPrize(call, _con["prize"])
|
let _prize = await PlayerFun.sendPrize(call, _con["prize"])
|
||||||
_task["finish"] = 1
|
_task["finish"] = 1
|
||||||
|
|
||||||
@ -53,7 +54,8 @@ export default async function (call: ApiCall<ReqFinsh, ResFinsh>) {
|
|||||||
newtask: newTask
|
newtask: newTask
|
||||||
}
|
}
|
||||||
|
|
||||||
// G.server.sendMsgByUid(call.uid, 'msg_s2c/TaskChange', newTask)
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd'])
|
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd'])
|
||||||
call.succ(data);
|
call.succ(data);
|
||||||
|
|
||||||
|
call.conn.sendMsg('msg_s2c/TaskChange', {..._task, finish: 1})
|
||||||
}
|
}
|
@ -11,8 +11,8 @@ export default async function (call: ApiCall<ReqUpdateFight, ResUpdateFight>) {
|
|||||||
|
|
||||||
let canChangeZr = G.gc.wangzherongyao.wangzhe.noupdate
|
let canChangeZr = G.gc.wangzherongyao.wangzhe.noupdate
|
||||||
let status = await WangZheRongYaofun.getWangZheStatus();
|
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 */});
|
return call.error('', {code: -2, message: ''/* globalThis.lng.wzry_17 */});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ import { player } from '../../../shared/protocols/user/type';
|
|||||||
|
|
||||||
export type ReqRank = {
|
export type ReqRank = {
|
||||||
gud: player;
|
gud: player;
|
||||||
|
page?: number;
|
||||||
|
offset?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResRank = ResOpen[''];
|
export type ResRank = ResOpen[''];
|
@ -1,8 +1,10 @@
|
|||||||
import { joinFightData } from '../../../../shared/fightControl/fightType';
|
import { joinFightData } from '../../../../shared/fightControl/fightType';
|
||||||
|
import { player } from '../../../../shared/protocols/user/type';
|
||||||
|
|
||||||
export type ReqGetEnemy = {
|
export type ReqGetEnemy = {
|
||||||
uid: string;
|
uid: string;
|
||||||
auto: boolean;
|
auto: boolean;
|
||||||
|
gud?: player;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResGetEnemy = {
|
export type ResGetEnemy = {
|
||||||
|
@ -3,6 +3,8 @@ import { rankInfo } from '../../../../shared/protocols/type';
|
|||||||
|
|
||||||
export type ReqGetRankList = {
|
export type ReqGetRankList = {
|
||||||
uid: string;
|
uid: string;
|
||||||
|
page?: number;
|
||||||
|
offset?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResGetRankList = {
|
export type ResGetRankList = {
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import { rankInfo } from '../../../../shared/protocols/type';
|
import { rankInfo } from '../../../../shared/protocols/type';
|
||||||
|
|
||||||
|
|
||||||
export type ReqGetRankList = {};
|
export type ReqGetRankList = {
|
||||||
|
page?:number;
|
||||||
|
offset?:number;
|
||||||
|
};
|
||||||
|
|
||||||
export type ResGetRankList = {
|
export type ResGetRankList = {
|
||||||
rankList: rankInfo[];
|
rankList: rankInfo[];
|
||||||
|
@ -3,6 +3,8 @@ import { rankInfo } from '../../../shared/protocols/type';
|
|||||||
|
|
||||||
export type ReqRank = {
|
export type ReqRank = {
|
||||||
uid: string;
|
uid: string;
|
||||||
|
page?: number;
|
||||||
|
offset?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResRank = {
|
export type ResRank = {
|
||||||
|
@ -2628,6 +2628,22 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": "Reference",
|
"type": "Reference",
|
||||||
"target": "../../shared/protocols/user/type/player"
|
"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<ServiceType> = {
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "Boolean"
|
"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<ServiceType> = {
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "String"
|
"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<ServiceType> = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"hbzb/zbs/PtlGetRankList/ReqGetRankList": {
|
"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": {
|
"hbzb/zbs/PtlGetRankList/ResGetRankList": {
|
||||||
"type": "Interface",
|
"type": "Interface",
|
||||||
@ -3238,6 +3297,22 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": {
|
"type": {
|
||||||
"type": "String"
|
"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<ServiceType> = {
|
|||||||
"type": "Reference",
|
"type": "Reference",
|
||||||
"target": "../../shared/protocols/user/type/player"
|
"target": "../../shared/protocols/user/type/player"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "page",
|
||||||
|
"type": {
|
||||||
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "offset",
|
||||||
|
"type": {
|
||||||
|
"type": "Number"
|
||||||
|
},
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -4,6 +4,8 @@ import { player } from '../../../shared/protocols/user/type';
|
|||||||
|
|
||||||
export type ReqRank = {
|
export type ReqRank = {
|
||||||
gud: player;
|
gud: player;
|
||||||
|
page?: number;
|
||||||
|
offset?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ResRank = ResOpen[''];
|
export type ResRank = ResOpen[''];
|
13
src/event.ts
13
src/event.ts
@ -307,15 +307,8 @@ EventEmitter.prototype.listeners = function (type) {
|
|||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
EventEmitter.listenerCount = function (emitter, type) {
|
EventEmitter.prototype.debug = function () {
|
||||||
var ret;
|
console.log(this._events);
|
||||||
if (!emitter._events || !emitter._events[type])
|
|
||||||
ret = 0;
|
|
||||||
else if (isFunction(emitter._events[type]))
|
|
||||||
ret = 1;
|
|
||||||
else
|
|
||||||
ret = emitter._events[type].length;
|
|
||||||
return ret;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MyEvent = EventEmitter as any as {
|
export const MyEvent = EventEmitter as any as {
|
||||||
@ -324,4 +317,6 @@ export const MyEvent = EventEmitter as any as {
|
|||||||
once(type: any, callback: any): any;
|
once(type: any, callback: any): any;
|
||||||
off(type: any, callback: any, caller?: any): void;
|
off(type: any, callback: any, caller?: any): void;
|
||||||
emit(type: any, ...args: any[]): void;
|
emit(type: any, ...args: any[]): void;
|
||||||
|
debug(): any;
|
||||||
|
removeAllListeners(type?:any):void;
|
||||||
};
|
};
|
||||||
|
@ -113,7 +113,6 @@ Object.defineProperties(BaseConnection.prototype, {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'gonghui': {
|
'gonghui': {
|
||||||
// ###debug GHManage 对象内同步转异步
|
|
||||||
// 涉及call.conn.gonghui,对应引用变量处需增加await
|
// 涉及call.conn.gonghui,对应引用变量处需增加await
|
||||||
async get(this: BaseConnection): Promise<GH> {
|
async get(this: BaseConnection): Promise<GH> {
|
||||||
// return GHManage.list[this.gud.ghId];
|
// return GHManage.list[this.gud.ghId];
|
||||||
|
@ -105,6 +105,8 @@ class _G {
|
|||||||
once(type: any, callback: any): any;
|
once(type: any, callback: any): any;
|
||||||
off(type: any, callback: any, caller?: any): void;
|
off(type: any, callback: any, caller?: any): void;
|
||||||
emit(type: any, ...args: any[]): void;
|
emit(type: any, ...args: any[]): void;
|
||||||
|
debug(): any;
|
||||||
|
removeAllListeners(type?:any):void;
|
||||||
} {
|
} {
|
||||||
return MyEvent as any;
|
return MyEvent as any;
|
||||||
}
|
}
|
||||||
|
@ -2482,6 +2482,7 @@
|
|||||||
"break": 0,
|
"break": 0,
|
||||||
"mask": 0,
|
"mask": 0,
|
||||||
"content": "zhuanchang",
|
"content": "zhuanchang",
|
||||||
|
"afterGuide": "100_180",
|
||||||
"intr": "转场",
|
"intr": "转场",
|
||||||
"skip": 0
|
"skip": 0
|
||||||
},
|
},
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -658,6 +658,11 @@
|
|||||||
"a": "attr",
|
"a": "attr",
|
||||||
"t": "nexp",
|
"t": "nexp",
|
||||||
"n": 500
|
"n": 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"a": "item",
|
||||||
|
"t": "4",
|
||||||
|
"n": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"pval": 1,
|
"pval": 1,
|
||||||
|
@ -104,7 +104,7 @@ export class JJCFun {
|
|||||||
// 函数内max存在-1操作,查自己需保持min=max
|
// 函数内max存在-1操作,查自己需保持min=max
|
||||||
let rankList = await this.getRankList(rank, rank + 1)
|
let rankList = await this.getRankList(rank, rank + 1)
|
||||||
let rankInfo = rankList[0]
|
let rankInfo = rankList[0]
|
||||||
return rankInfo
|
return rankInfo || {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入新玩家排名
|
// 写入新玩家排名
|
||||||
|
@ -90,17 +90,18 @@ export class PlayerFun {
|
|||||||
static async cutNeed(call: call, val: atn[]) {
|
static async cutNeed(call: call, val: atn[]) {
|
||||||
let needArr = PublicShared.mergePrize(val);
|
let needArr = PublicShared.mergePrize(val);
|
||||||
needArr.forEach(v => v.n *= -1);
|
needArr.forEach(v => v.n *= -1);
|
||||||
|
let all = [];
|
||||||
|
|
||||||
let attr = needArr.filter(atn => atn.a == 'attr' && atn.n != 0);
|
let attr = needArr.filter(atn => atn.a == 'attr' && atn.n != 0);
|
||||||
if (attr.length > 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);
|
let item = needArr.filter(atn => atn.a == 'item' && atn.n != 0);
|
||||||
if (item.length > 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 => {
|
G.emit('USE_ITEM', call.conn.gud, needArr.map(need => {
|
||||||
return {...need, n: Math.abs(need.n)};
|
return {...need, n: Math.abs(need.n)};
|
||||||
}));
|
}));
|
||||||
@ -139,11 +140,15 @@ export class PlayerFun {
|
|||||||
}> | atn[]) {
|
}> | atn[]) {
|
||||||
let change = {};
|
let change = {};
|
||||||
if (val instanceof Array) {
|
if (val instanceof Array) {
|
||||||
|
let all = [];
|
||||||
for (let atn of val) {
|
for (let atn of val) {
|
||||||
change[atn.t] = await this.getAtnNum(call, atn) + atn.n;
|
change[atn.t] = await this.getAtnNum(call, atn) + atn.n;
|
||||||
await this.changeAttr(call.conn.uid, change);
|
all.push( this.changeAttr(call.conn.uid, change) );
|
||||||
await this.upAttr(call, {...atn, n: change[atn.t]});
|
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 {
|
} else {
|
||||||
change = val;
|
change = val;
|
||||||
await this.changeAttr(call.conn.uid, change);
|
await this.changeAttr(call.conn.uid, change);
|
||||||
@ -237,13 +242,22 @@ export class PlayerFun {
|
|||||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
|
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
|
||||||
} else {
|
} else {
|
||||||
if (item.num + atn.n <= 0) {
|
if (item.num + atn.n <= 0) {
|
||||||
await G.redis.del('item', call.uid, atn.t);
|
await Promise.all([
|
||||||
await G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t});
|
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});
|
call.addEventMsg('msg_s2c/ItemChange', atn.t, {num: 0});
|
||||||
} else {
|
} else {
|
||||||
await G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime);
|
await Promise.all([
|
||||||
await G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n);
|
G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime),
|
||||||
await G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
|
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, {
|
call.addEventMsg('msg_s2c/ItemChange', atn.t, {
|
||||||
num: item.num + atn.n,
|
num: item.num + atn.n,
|
||||||
lastTime: upObj.update.$set.lastTime
|
lastTime: upObj.update.$set.lastTime
|
||||||
|
@ -46,9 +46,18 @@ export abstract class Rank {
|
|||||||
abstract getType(): rankType;
|
abstract getType(): rankType;
|
||||||
abstract compare(other: rankInfo, cur: rankInfo): boolean;
|
abstract compare(other: rankInfo, cur: rankInfo): boolean;
|
||||||
abstract compareSort(a: rankInfo, b: rankInfo): number;
|
abstract compareSort(a: rankInfo, b: rankInfo): number;
|
||||||
abstract getRankList(uid: string, gud?: player): Promise<ResOpen['']>;
|
abstract getRankList(uid: string, obj?: {gud?:player, min?: number, max?:number}): Promise<ResOpen['']>;
|
||||||
abstract getValArr(info: rankInfo): number|string; // 运算后的积分值,排名依据
|
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() {
|
get db() {
|
||||||
return G.mongodb.collection('rankList');
|
return G.mongodb.collection('rankList');
|
||||||
}
|
}
|
||||||
@ -99,82 +108,109 @@ export abstract class Rank {
|
|||||||
async getRankData(idKey: string) {
|
async getRankData(idKey: string) {
|
||||||
let key = this.getRedisKey
|
let key = this.getRedisKey
|
||||||
let data = await G.redis.hGet(key, idKey)
|
let data = await G.redis.hGet(key, idKey)
|
||||||
if(!data) {
|
if(!data || data.utime < (G.time - this.utimeTTL)) {
|
||||||
let type = this.getType()
|
let type = this.getType()
|
||||||
let res = await this.db.findOne({isKey: idKey, type})
|
let res = await this.db.findOne({isKey: idKey, type})
|
||||||
|
if(res) {
|
||||||
data = G.mongodb.conversionIdObj(res)
|
data = G.mongodb.conversionIdObj(res)
|
||||||
if(data) this.setRankData(idKey, data)
|
this.setRankData(idKey, data.data)
|
||||||
}
|
}
|
||||||
if(data) data
|
}
|
||||||
|
if(data) return data
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取单个用户的排名 *倒叙
|
// 获取单个用户的排名 *降序
|
||||||
async getRankSortByOne(idKey: string):Promise<number> {
|
async getRankSortByOne(idKey: string):Promise<number> {
|
||||||
let rank = await G.redis.zRevRank(this.getRedisKeySort, idKey)
|
let rank = await G.redis.zRevRank(this.getRedisKeySort, idKey)
|
||||||
return rank || -1;
|
return rank || -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取单个指定排名的用户数据 *降序
|
||||||
|
async getRankSortDataByOne(rank: number): Promise<rankInfo> {
|
||||||
|
let rankList:rankInfo[] = await this.getRankListRange(rank, rank + 1)
|
||||||
|
let rankInfo = rankList && rankList.length > 0 ? rankList[0] : {} as rankInfo
|
||||||
|
return rankInfo
|
||||||
|
}
|
||||||
|
|
||||||
// 获取排名长度
|
// 获取排名长度
|
||||||
async getRankLen() {
|
async getRankLen() {
|
||||||
return await G.redis.hLen(this.getRedisKey)
|
return await G.redis.hLen(this.getRedisKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取指定排名范围的数据 *降序
|
||||||
|
async getRankListRange(min:number = 0, max:number = 50): Promise<rankInfo[]> {
|
||||||
|
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<string[]> {
|
||||||
|
let idKeys = await G.redis.zRevRange(this.getRedisKeySort, min, max - 1)
|
||||||
|
return idKeys || []
|
||||||
|
}
|
||||||
|
|
||||||
// 获取指定类型的全部rank列表,返回为积分排序后的数组
|
// 获取指定类型的全部rank列表,返回为积分排序后的数组
|
||||||
async getRankListAll(): Promise<rankInfo[]> {
|
async getRankListAll(): Promise<rankInfo[]> {
|
||||||
let res = await G.redis.hGetAll(this.getRedisKey)
|
let res = await G.redis.hGetAll(this.getRedisKey)
|
||||||
if(res) {
|
if(res) {
|
||||||
// 如果是用户数据,则比对utime,更新数据
|
// 如果是用户数据,则比对utime,更新数据
|
||||||
let updateUid = []
|
// res = await this.checkData(res)
|
||||||
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])
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return Object.values(res).sort(this.compareSort)
|
return Object.values(res).sort(this.compareSort)
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按排名获取全部的idKey
|
||||||
|
async getRankListIdKeyAll(): Promise<string[]> {
|
||||||
|
let res = this.getRankListIdKeyRange(0, -1)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证数据的过期时间,更新数据
|
||||||
|
async checkData(rankList: rankInfo[]): Promise<rankInfo[]> {
|
||||||
|
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) {
|
async delRankData(idKey:string) {
|
||||||
G.redis.hDel(this.getRedisKey, idKey)
|
G.redis.hDel(this.getRedisKey, idKey)
|
||||||
G.redis.zRem(this.getRedisKeySort, idKey)
|
G.redis.zRem(this.getRedisKeySort, idKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 前50(countMaxNum)名才更新数据(上榜),多余的数据会删除。
|
// 原逻辑前50(countMaxNum)名才更新数据(上榜),多余的数据会删除。
|
||||||
async addNew(info: rankInfo) {
|
async addNew(info: rankInfo) {
|
||||||
this.queue.enqueue(async () => {
|
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)
|
await this.setRankData(info.player[this.findKey], info)
|
||||||
this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true });
|
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名时,删除最后一名(第51名)。
|
// 删除第50名以后的数据,(排名从0开始计算)
|
||||||
let myIndex = rankList.findIndex(li => li.player[this.findKey] == info.player[this.findKey]);
|
let idKeys:string[] = await this.getRankListIdKeyRange(50, -1)
|
||||||
if (myIndex != -1) {
|
idKeys.forEach(idKey => {
|
||||||
rankList[myIndex] = info;
|
this.db.deleteOne({ type: this.type, idKey: idKey });
|
||||||
} else {
|
this.delRankData(idKey)
|
||||||
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])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ export class RankClslCross extends Rank {
|
|||||||
return info?.valArr[0] || 0
|
return info?.valArr[0] || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRankList(uid: string, gud: player) {
|
async getRankList(uid: string, {gud, min, max}) {
|
||||||
let rankList = await this.getRankListAll();
|
let rankList = await this.getRankListRange(min, max);
|
||||||
let rank = await this.getRankSortByOne(uid);
|
let rank = await this.getRankSortByOne(uid);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -39,22 +39,19 @@ export class RankClslCross extends Rank {
|
|||||||
|
|
||||||
async addNew(info: rankInfo) {
|
async addNew(info: rankInfo) {
|
||||||
this.queue.enqueue(async () => {
|
this.queue.enqueue(async () => {
|
||||||
let rankList = await this.getRankListAll()
|
// 积分大于配置的最小参数,更新数据
|
||||||
if (info.valArr[0] >= this.minStar) {
|
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.setRankData(info.player[this.findKey], info)
|
||||||
this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true });
|
this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true });
|
||||||
rankList.sort(this.compareSort);
|
// 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])
|
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.db.deleteOne({ type: this.type, idKey: info.player[this.findKey] });
|
||||||
|
this.delRankData(info.player[this.findKey])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,10 @@ export class RankHbzbJfsLocal extends Rank {
|
|||||||
getValArr(info: rankInfo):number|string {
|
getValArr(info: rankInfo):number|string {
|
||||||
return info?.valArr[0] || 0
|
return info?.valArr[0] || 0
|
||||||
}
|
}
|
||||||
async getRankList(uid: string) {
|
async getRankList(uid: string, {min, max}) {
|
||||||
let conn = G.server.uid_connections[uid];
|
let conn = G.server.uid_connections[uid];
|
||||||
let rankList = await this.getRankListAll();
|
// ###debug
|
||||||
|
let rankList = await this.getRankListRange(min, max);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
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 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 list = callRes.res.rankList;
|
||||||
let myRankIndex = list.findIndex(li => li.player.uid == uid);
|
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 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 list = callRes.res.rankList;
|
||||||
let myRankIndex = list.findIndex(li => li.player.uid == uid);
|
let myRankIndex = list.findIndex(li => li.player.uid == uid);
|
||||||
|
|
||||||
@ -75,27 +76,39 @@ export class RankHbzbJfsCross extends RankHbzbJfsLocal {
|
|||||||
getType(): rankType {
|
getType(): rankType {
|
||||||
return 'hbzbCross';
|
return 'hbzbCross';
|
||||||
}
|
}
|
||||||
|
|
||||||
async addNew(info: rankInfo) {
|
async addNew(info: rankInfo) {
|
||||||
this.allPlayer[info.player.uid] = {
|
let data = {
|
||||||
uid: info.player.uid,
|
|
||||||
jifen: info.valArr[0],
|
|
||||||
data: {
|
|
||||||
player: info.player,
|
player: info.player,
|
||||||
roles: info.roles
|
roles: info.roles
|
||||||
}
|
}
|
||||||
};
|
G.mongodb.collection('hbzb_user_cross').updateOne({ uid: info.player.uid }, { $set: { jifen: info.valArr[0], data: data } }, { upsert: true });
|
||||||
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 });
|
this.setRankData(info.player.uid, info)
|
||||||
Rank.prototype.addNew.call(this, info);
|
Rank.prototype.addNew.call(this, info);
|
||||||
}
|
}
|
||||||
allPlayer: k_v<CollectionHbzbUserCross> = {};
|
|
||||||
|
|
||||||
|
// allPlayer: k_v<CollectionHbzbUserCross> = {};
|
||||||
|
|
||||||
|
// 初始化
|
||||||
async loadAllPlayer() {
|
async loadAllPlayer() {
|
||||||
|
if(await this.getRankLen() > 0) return
|
||||||
let players = await G.mongodb.collection('hbzb_user_cross').find().toArray();
|
let players = await G.mongodb.collection('hbzb_user_cross').find().toArray();
|
||||||
players.forEach(p => {
|
players.forEach(item => {
|
||||||
let { _id, ...ops } = p;
|
if(item.uid && item.data) {
|
||||||
this.allPlayer[ops.uid] = ops;
|
// 格式与其它排行榜不同,同步格式。
|
||||||
});
|
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) {
|
async addJfsLog(uid: string, fightLog: fightResult) {
|
||||||
if (uid.indexOf('npc') != -1) return;
|
if (uid.indexOf('npc') != -1) return;
|
||||||
FightFun.saveLog(uid, 'hbzbJfs', fightLog);
|
FightFun.saveLog(uid, 'hbzbJfs', fightLog);
|
||||||
@ -123,9 +136,8 @@ export class RankHbzbZbsCross extends Rank {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
async changeRank(uid: string, toUid: string) {
|
async changeRank(uid: string, toUid: string) {
|
||||||
let rankList = await this.getRankListAll();
|
let role1 = await this.getRankData(uid);
|
||||||
let role1 = rankList.find(li => li.player.uid == uid);
|
let role2 = await this.getRankData(toUid);
|
||||||
let role2 = rankList.find(li => li.player.uid == toUid);
|
|
||||||
|
|
||||||
if (role1 && role2 && role1.valArr[0] > role2.valArr[0]) {
|
if (role1 && role2 && role1.valArr[0] > role2.valArr[0]) {
|
||||||
let temp = role1.valArr[0];
|
let temp = role1.valArr[0];
|
||||||
@ -136,9 +148,10 @@ export class RankHbzbZbsCross extends Rank {
|
|||||||
this.addNew(role2);
|
this.addNew(role2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async getRankList(uid: string) {
|
async getRankList(uid: string, {min, max}) {
|
||||||
let rankList = await this.getRankListAll();
|
let rankList = await this.getRankListRange(min, max);
|
||||||
let conn = rankList.find(li => li.player.uid == uid);
|
// let conn = rankList.find(li => li.player.uid == uid);
|
||||||
|
let conn = await this.getRankData(uid)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
@ -151,12 +164,13 @@ export class RankHbzbZbsCross extends Rank {
|
|||||||
async addNew(info: rankInfo) {
|
async addNew(info: rankInfo) {
|
||||||
|
|
||||||
this.queue.enqueue(async () => {
|
this.queue.enqueue(async () => {
|
||||||
let rankList = await this.getRankListAll();
|
// 原逻辑排名最高50条,更新ranklist内排名数据,
|
||||||
let myIndex = rankList.findIndex(li => li.player[this.findKey] == info.player[this.findKey]);
|
// let rankList = await this.getRankListRange();
|
||||||
|
// let myIndex = rankList.findIndex(li => li.player[this.findKey] == info.player[this.findKey]);
|
||||||
if (myIndex != -1) {
|
// if (myIndex != -1) {
|
||||||
rankList[myIndex] = info;
|
// rankList[myIndex] = info;
|
||||||
}
|
// }
|
||||||
|
// 当前更新redis相关数据即可
|
||||||
this.setRankData(info.player[this.findKey], info)
|
this.setRankData(info.player[this.findKey], info)
|
||||||
this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true });
|
this.db.updateOne({ type: this.type, idKey: info.player[this.findKey] }, { $set: { data: info } }, { upsert: true });
|
||||||
// rankList.sort(this.compareSort);
|
// rankList.sort(this.compareSort);
|
||||||
|
@ -39,13 +39,14 @@ export class RankKbzz extends Rank {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRankList(uid: string) {
|
async getRankList(uid: string, {min, max}) {
|
||||||
let rankList = await this.getRankListAll();
|
let rankList = await this.getRankListRange(min, max);
|
||||||
|
let gud = await this.getRankData(uid)
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
myRank: {
|
myRank: {
|
||||||
rank: await this.getRankSortByOne(uid),
|
rank: await this.getRankSortByOne(uid),
|
||||||
player: {},
|
player: gud?.player || {},
|
||||||
valArr: [(await G.mongodb.collection('kbzzGroupUser').findOne({ uid: uid }))?.score || 1000]
|
valArr: [(await G.mongodb.collection('kbzzGroupUser').findOne({ uid: uid }))?.score || 1000]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -17,9 +17,9 @@ export class RankPower extends Rank {
|
|||||||
getValArr(info: rankInfo):number|string {
|
getValArr(info: rankInfo):number|string {
|
||||||
return info?.valArr[0] || 0
|
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 conn = G.server.uid_connections[uid];
|
||||||
let rankList = await this.getRankListAll()
|
let rankList = await this.getRankListRange(min, max)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
|
@ -19,9 +19,10 @@ export class RankQjzzd extends Rank {
|
|||||||
return info?.valArr[0] || 0
|
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 conn = G.server.uid_connections[uid];
|
||||||
let rankList = await this.getRankListAll()
|
// debug
|
||||||
|
let rankList = await this.getRankListRange(min, max)
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
myRank: {
|
myRank: {
|
||||||
|
@ -21,9 +21,10 @@ export class RankSlzd1 extends Rank {
|
|||||||
return info?.valArr[0] || 0
|
return info?.valArr[0] || 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRankList(ghid: string): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> {
|
async getRankList(ghid: string, { min, max }): Promise<{ rankList: rankInfo[]; myRank: rankInfo; }> {
|
||||||
let rankList = await this.getRankListAll()
|
let rankList = await this.getRankListRange( min, max )
|
||||||
let li = rankList.find(l => l.player.ghId == ghid);
|
// let li = rankList.find(l => l.player.ghId == ghid); // debug 查询自身数据
|
||||||
|
let li = await this.getRankData(ghid);
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
myRank: {
|
myRank: {
|
||||||
|
@ -17,9 +17,9 @@ export class RankTanXian extends Rank {
|
|||||||
getValArr(info: rankInfo):number|string {
|
getValArr(info: rankInfo):number|string {
|
||||||
return info?.valArr[0] || 0
|
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 conn = G.server.uid_connections[uid];
|
||||||
let rankList = await this.getRankListAll()
|
let rankList = await this.getRankListRange(min, max)
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
myRank: {
|
myRank: {
|
||||||
|
@ -21,9 +21,9 @@ export class RankTujian extends Rank {
|
|||||||
return info?.valArr[0] || 0
|
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 conn = G.server.uid_connections[uid];
|
||||||
let rankList = await this.getRankListAll();
|
let rankList = await this.getRankListRange(min, max);
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
myRank: {
|
myRank: {
|
||||||
|
@ -23,15 +23,13 @@ export class RankWzryCross extends Rank {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getPlayerRank(uid: string): Promise<number> {
|
async getPlayerRank(uid: string): Promise<number> {
|
||||||
let _r = await this.getRankListAll();
|
// 获取用户指定排名
|
||||||
if (!Object.keys(_r).length) {
|
let rank = await this.getRankSortByOne(uid)
|
||||||
return -1
|
return rank + 1; // 原逻辑有+1操作,与其它地点取排名逻辑有差异
|
||||||
}
|
|
||||||
return _r.findIndex(li => li.player.uid == uid) + 1 || -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRankList(uid: string, gud: player) {
|
async getRankList(uid: string, {gud, min, max }) {
|
||||||
let rankList = await this.getRankListAll();
|
let rankList = await this.getRankListRange(min, max);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
|
@ -25,9 +25,9 @@ export class RankXszm extends Rank {
|
|||||||
return res
|
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 conn = G.server.uid_connections[uid];
|
||||||
let rankList = await this.getRankListAll();
|
let rankList = await this.getRankListRange(min, max);
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
myRank: {
|
myRank: {
|
||||||
|
@ -21,9 +21,9 @@ export class RankZccg extends Rank {
|
|||||||
return info?.valArr[0] || 0
|
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 conn = G.server.uid_connections[uid];
|
||||||
let rankList = await this.getRankListAll();
|
let rankList = await this.getRankListRange(min, max);
|
||||||
return {
|
return {
|
||||||
rankList: rankList,
|
rankList: rankList,
|
||||||
myRank: {
|
myRank: {
|
||||||
|
@ -24,7 +24,7 @@ export class SchedulerManage {
|
|||||||
|
|
||||||
static onlyPm2() {
|
static onlyPm2() {
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
Scheduler.schedulers.forEach(s => s.cheak()); // ### debug 方法奖励等定时器检测
|
Scheduler.schedulers.forEach(s => s.cheak());
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ export class Scheduler_hbzb_zbs_local_prize extends Scheduler {
|
|||||||
|
|
||||||
async start() {
|
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] }; }));
|
this.sendEmail(crossRank.map(rank => { return { uid: rank.player.uid, valArr: [...rank.valArr] }; }));
|
||||||
|
|
||||||
// crossRank.length > 0 && ChatFun.newMsg({
|
// crossRank.length > 0 && ChatFun.newMsg({
|
||||||
@ -123,13 +123,10 @@ export class Scheduler_hbzb_zbs_cross_ready extends Scheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
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 zbsRankList = await Rank.list.hbzbZbsCross.getRankListAll()
|
||||||
let top100 = rankList.slice(0, 100);
|
|
||||||
let top100uids = top100.map(t => t.player.uid);
|
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));
|
top100.push(...zbsRankList.filter(l => !top100uids.includes(l.player.uid)).sort((a, b) => b.player.power - a.player.power));
|
||||||
|
|
||||||
zbsRankList = top100.map((v, i) => {
|
zbsRankList = top100.map((v, i) => {
|
||||||
|
@ -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) {
|
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 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, "$where": "return this.pval > this.nval" });
|
||||||
let _unFinish = await this.getFinishByStype(call, stype, {finish: 0});
|
//let _unFinish = await this.getFinishByStype(call, stype, {finish: 0});
|
||||||
_unFinish = _unFinish.filter(x => x.pval > x.nval)
|
//_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;
|
if (_unFinish.length == 0) return;
|
||||||
for (let index = 0; index < _unFinish.length; index++) {
|
for (let index = 0; index < _unFinish.length; index++) {
|
||||||
const _task = _unFinish[index];
|
const _task = _unFinish[index];
|
||||||
@ -138,6 +144,10 @@ export class TaskFun {
|
|||||||
let _setData = {nval: _resVal};
|
let _setData = {nval: _resVal};
|
||||||
let _where = {taskid: _task["taskid"]};
|
let _where = {taskid: _task["taskid"]};
|
||||||
await this.setTask(uid, _where, _setData);
|
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) {
|
static async generateAllTask(call: ApiCall) {
|
||||||
let _r = await G.mongodb.collection(SHUJUKU).findOne({uid: call.uid});
|
let _r = await G.mongodb.collection(SHUJUKU).count({uid: call.uid});
|
||||||
if (_r) return;
|
if (_r > 0) return;
|
||||||
let _taskInfo = [];
|
let _taskInfo = [];
|
||||||
let _con = G.gc.task;
|
let _con = G.gc.task;
|
||||||
for (let _type in _con) {
|
for (let _type in _con) {
|
||||||
@ -320,9 +330,9 @@ export class TaskFun {
|
|||||||
/**生成指定类型任务-初始化 */
|
/**生成指定类型任务-初始化 */
|
||||||
static async reInitTask(call: ApiCall, type: string) {
|
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 = [];
|
let _taskInfo = [];
|
||||||
if (!_r) {
|
if (_r == 0) {
|
||||||
let _con = G.gc.task;
|
let _con = G.gc.task;
|
||||||
// 数据不存在,未初始化,执行初始化
|
// 数据不存在,未初始化,执行初始化
|
||||||
for (let _taskid in _con[type]) {
|
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;
|
return _taskInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,11 +422,17 @@ export class TaskFun {
|
|||||||
const element = Object.keys(_ttype)[index];
|
const element = Object.keys(_ttype)[index];
|
||||||
if ((element == "1" || element == "3") && call.conn.gud.lv < 7) continue;
|
if ((element == "1" || element == "3") && call.conn.gud.lv < 7) continue;
|
||||||
let _values: number[] = _ttype[element];
|
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 taskArr = await G.mongodb.collection(SHUJUKU).find(_where).toArray();
|
||||||
let _tmp = taskArr.filter(x => x.pval <= x.nval)
|
let count = await G.mongodb.collection(SHUJUKU).count(_where);
|
||||||
if (_tmp.length) {
|
//let _tmp = taskArr.filter(x => x.pval <= x.nval)
|
||||||
|
//if (_tmp.length) {
|
||||||
|
if (count > 0) {
|
||||||
_res.show = true;
|
_res.show = true;
|
||||||
_res.val.tasktypes.push(element);
|
_res.val.tasktypes.push(element);
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@ export class WangZheRongYaofun {
|
|||||||
let _con = _tmp.wangzhe.timestatus;
|
let _con = _tmp.wangzhe.timestatus;
|
||||||
let _weekOneTime = PublicShared.getToWeekMondayZeroTime();
|
let _weekOneTime = PublicShared.getToWeekMondayZeroTime();
|
||||||
let _res: wangzherongyao_staus = { // 默认比赛结束状态
|
let _res: wangzherongyao_staus = { // 默认比赛结束状态
|
||||||
status: 8,
|
status: _con[_con.length - 1].status + 1,
|
||||||
stime: _weekOneTime + 7 * 24 * 3600,
|
stime: _weekOneTime + _con[_con.length - 1].etime,
|
||||||
etime: _weekOneTime + 7 * 24 * 3600
|
etime: _weekOneTime + 7 * 24 * 3600
|
||||||
};
|
};
|
||||||
for (let index = 0; index < _con.length; index++) {
|
for (let index = 0; index < _con.length; index++) {
|
||||||
@ -61,7 +61,10 @@ export class WangZheRongYaofun {
|
|||||||
};
|
};
|
||||||
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) {
|
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;
|
return _res;
|
||||||
} else {
|
} else {
|
||||||
delete _mydata._id;
|
delete _mydata._id;
|
||||||
|
@ -91,7 +91,7 @@ export class _redis implements redisJsonFun {
|
|||||||
// this.logMsg = str;
|
// 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 sid = G.config.serverId || 0;
|
||||||
let fmtKey = `${G.config.projectName}_${G.argv.serverType == 'cross' ? `corss${sid}` : sid}_${key}`;
|
let fmtKey = `${G.config.projectName}_${G.argv.serverType == 'cross' ? `corss${sid}` : sid}_${key}`;
|
||||||
state && this.log(state + ' ' + fmtKey, 'start');
|
state && this.log(state + ' ' + fmtKey, 'start');
|
||||||
@ -115,6 +115,16 @@ export class _redis implements redisJsonFun {
|
|||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
return result
|
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() {
|
async hGetAll() {
|
||||||
let _args = Array.from(arguments);
|
let _args = Array.from(arguments);
|
||||||
@ -169,6 +179,15 @@ export class _redis implements redisJsonFun {
|
|||||||
return await this.redis.zRange(this.fromatKey(_args[0], 'zRange'), _args[1], _args[2])
|
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排名
|
* 获取指定key排名
|
||||||
* redis参数
|
* redis参数
|
||||||
@ -559,6 +578,9 @@ export interface redisJsonFun {
|
|||||||
// 变量传key无法通过检测时,不做强制key类型验证。
|
// 变量传key无法通过检测时,不做强制key类型验证。
|
||||||
hGet<key extends string>(key: key, hash:string): Promise<any>;
|
hGet<key extends string>(key: key, hash:string): Promise<any>;
|
||||||
|
|
||||||
|
hmGet<key extends hkeys<hObj1>>(key: key, hash:string[]): Promise<hObj1[key]>;
|
||||||
|
hmGet<key extends string>(key: key, hash:string[]): Promise<any>;
|
||||||
|
|
||||||
/**获取全部的hash数据 */
|
/**获取全部的hash数据 */
|
||||||
hGetAll<key extends hkeys<hObj1>>(key: key):Promise<any>;
|
hGetAll<key extends hkeys<hObj1>>(key: key):Promise<any>;
|
||||||
|
|
||||||
@ -589,6 +611,10 @@ export interface redisJsonFun {
|
|||||||
|
|
||||||
zRange<key extends string>(key: key, min: number, max: number): Promise<string[]>;
|
zRange<key extends string>(key: key, min: number, max: number): Promise<string[]>;
|
||||||
|
|
||||||
|
zRevRange<key extends skeys<sObj1>>(key: key, min: number, max: number): Promise<string[]>;
|
||||||
|
|
||||||
|
zRevRange<key extends string>(key: key, min: number, max: number): Promise<string[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取出指定member排名数据
|
* 取出指定member排名数据
|
||||||
*/
|
*/
|
||||||
|
@ -214,6 +214,7 @@ export class FightControl {
|
|||||||
|
|
||||||
this.winSide = winside as 1 | 0;
|
this.winSide = winside as 1 | 0;
|
||||||
this.record({ act: 'fightEnd', winSide: this.winSide });
|
this.record({ act: 'fightEnd', winSide: this.winSide });
|
||||||
|
this.event.removeAllListeners()
|
||||||
}
|
}
|
||||||
|
|
||||||
eachLiveRoles(callback: (role: Role) => void) {
|
eachLiveRoles(callback: (role: Role) => void) {
|
||||||
|
@ -3,7 +3,7 @@ import { rankInfo } from '../type';
|
|||||||
/**
|
/**
|
||||||
* 排行榜
|
* 排行榜
|
||||||
*/
|
*/
|
||||||
export type ReqOpen = Array<rankType>;
|
export type ReqOpen = rankTypeObj|Array<rankType>;
|
||||||
|
|
||||||
export type ResOpen = {
|
export type ResOpen = {
|
||||||
[type: string]: {
|
[type: string]: {
|
||||||
@ -16,3 +16,9 @@ export type rankType = 'jjc' | 'tanxian' | 'zhanli' | 'qjzzd' | 'hbzbLocal' | 'h
|
|||||||
| 'slzd1' | 'slzd2' | 'slzd3' | 'slzd4' | 'slzd5' | 'slzd6'
|
| 'slzd1' | 'slzd2' | 'slzd3' | 'slzd4' | 'slzd5' | 'slzd6'
|
||||||
| 'kbzz' | 'xszm' | 'clslCross'
|
| 'kbzz' | 'xszm' | 'clslCross'
|
||||||
| 'zccg' | 'gbzl' | 'tujian' | 'wzryCross';
|
| 'zccg' | 'gbzl' | 'tujian' | 'wzryCross';
|
||||||
|
|
||||||
|
export type rankTypeObj = {
|
||||||
|
type?: rankType[],
|
||||||
|
page?: number,
|
||||||
|
offset?: number
|
||||||
|
}
|
@ -18019,11 +18019,59 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
"type": "Interface"
|
"type": "Interface"
|
||||||
},
|
},
|
||||||
"rank/PtlOpen/ReqOpen": {
|
"rank/PtlOpen/ReqOpen": {
|
||||||
|
"type": "Union",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"type": {
|
||||||
|
"type": "Reference",
|
||||||
|
"target": "rank/PtlOpen/rankTypeObj"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"type": {
|
||||||
"type": "Array",
|
"type": "Array",
|
||||||
"elementType": {
|
"elementType": {
|
||||||
"type": "Reference",
|
"type": "Reference",
|
||||||
"target": "rank/PtlOpen/rankType"
|
"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": {
|
"rank/PtlOpen/rankType": {
|
||||||
"type": "Union",
|
"type": "Union",
|
||||||
|
Loading…
Reference in New Issue
Block a user