Compare commits
2 Commits
666b7e51c5
...
f1963d2e53
Author | SHA1 | Date | |
---|---|---|---|
f1963d2e53 | |||
0ddd611c59 |
@ -30,6 +30,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
});
|
||||
|
||||
UserFun.activeHeadFrame(call.uid, 'jjc_rank', data["rank"] + 1);
|
||||
JJCFun.checkUpdatePlayer()
|
||||
//JJCFun.checkUpdatePlayer()
|
||||
|
||||
}
|
@ -94,37 +94,37 @@ export class JJCFun {
|
||||
* @param uTimeOffset
|
||||
* @param isUpdate 是否更新数据
|
||||
*/
|
||||
static async checkUpdatePlayer(min: number = 0, max: number = 1000, uTimeOffset: number = 600, isUpdate: boolean = true) {
|
||||
// 获取指定排名用户uid
|
||||
let sortInfo = await this.getRankListUid(min, max)
|
||||
if (!sortInfo.length) return []
|
||||
let updateArr = []
|
||||
// static async checkUpdatePlayer(min: number = 0, max: number = 1000, uTimeOffset: number = 600, isUpdate: boolean = true) {
|
||||
// // 获取指定排名用户uid
|
||||
// let sortInfo = await this.getRankListUid(min, max)
|
||||
// if (!sortInfo.length) return []
|
||||
// let updateArr = []
|
||||
|
||||
let users = await G.redis.hGetAll('rank:jjc:data')
|
||||
// let users = await G.redis.hGetAll('rank:jjc:data')
|
||||
|
||||
for (let i = 0; i < sortInfo.length; i++) {
|
||||
let uid = sortInfo[i]
|
||||
let rankInfo = users[uid]
|
||||
if (!rankInfo?.player) continue
|
||||
// 比对utime,判断是否更新数据
|
||||
if (!rankInfo.player.isNpc) {
|
||||
if (!rankInfo.utime || (rankInfo.utime && rankInfo.utime < (G.time - uTimeOffset))) {
|
||||
updateArr.push(rankInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 更新数据
|
||||
if (isUpdate && updateArr.length > 0) {
|
||||
let playerArrInfo = await G.mongodb.collection("user").find({uid: {$in: updateArr.map(i => i.uid)}}).toArray()
|
||||
for (let i = 0; i < playerArrInfo.length; i++) {
|
||||
let playerInfo = playerArrInfo[i]
|
||||
let index = updateArr.findIndex(x => x.player.uid == playerInfo.uid)
|
||||
updateArr[index].player = playerInfo
|
||||
updateArr[index].utime = G.time
|
||||
this.updatePlayerData(playerInfo.uid, updateArr[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (let i = 0; i < sortInfo.length; i++) {
|
||||
// let uid = sortInfo[i]
|
||||
// let rankInfo = users[uid]
|
||||
// if (!rankInfo?.player) continue
|
||||
// // 比对utime,判断是否更新数据
|
||||
// if (!rankInfo.player.isNpc) {
|
||||
// if (!rankInfo.utime || (rankInfo.utime && rankInfo.utime < (G.time - uTimeOffset))) {
|
||||
// updateArr.push(rankInfo)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 更新数据
|
||||
// if (isUpdate && updateArr.length > 0) {
|
||||
// let playerArrInfo = await G.mongodb.collection("user").find({uid: {$in: updateArr.map(i => i.uid)}}).toArray()
|
||||
// for (let i = 0; i < playerArrInfo.length; i++) {
|
||||
// let playerInfo = playerArrInfo[i]
|
||||
// let index = updateArr.findIndex(x => x.player.uid == playerInfo.uid)
|
||||
// updateArr[index].player = playerInfo
|
||||
// updateArr[index].utime = G.time
|
||||
// this.updatePlayerData(playerInfo.uid, updateArr[index]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取指定范围排名的用户,仅返回uid[]
|
||||
|
@ -19,6 +19,8 @@ import {getGud, setGud} from './gud';
|
||||
import {addGameLog} from "../gameLog";
|
||||
import {PushGiftFun} from "./pushgift";
|
||||
import { ActionLog } from './actionLog/actionLog';
|
||||
import { roleDataType } from '../shared/fightControl/fightType';
|
||||
import { PlayerShared } from '../shared/public/player';
|
||||
|
||||
|
||||
export type call = {
|
||||
@ -41,6 +43,41 @@ export type call = {
|
||||
};
|
||||
|
||||
export class PlayerFun {
|
||||
/**
|
||||
* 通过uid获取战斗数据
|
||||
* @param uid
|
||||
* @returns
|
||||
*/
|
||||
static async getDefaultFightDataByUid(uid:string){
|
||||
let gud = await getGud(uid);
|
||||
let posObj = gud.heroPos;
|
||||
let roles: k_v<roleDataType> = {};
|
||||
if (gud.selectMatrix && gud.matrixPos) {
|
||||
posObj = gud.matrixPos[gud.selectMatrix];
|
||||
}
|
||||
let heros = await HeroFun.getHeros({uid:uid}, Object.values(posObj).filter(_id => _id != '') as string[]);
|
||||
let otherBuff = UserFun.getOtherBuff(gud)
|
||||
|
||||
Object.entries(posObj).forEach(obj => {
|
||||
let pos = obj[0];
|
||||
let _id = obj[1];
|
||||
let hero = heros.filter(h => h._id == _id)[0];
|
||||
|
||||
if (hero) {
|
||||
roles[pos] = {
|
||||
...hero,
|
||||
attr: {
|
||||
...HeroShared.getHeroBasicAttr(hero, { ...otherBuff, allBuff: HeroShared.getAllBuff(heros) }, Number(pos))
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
player: { ...gud, buff: PlayerShared.getBuff(gud) },
|
||||
roles: roles
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 获取玩家atn数量
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user