去掉无效刷新

This commit is contained in:
ciniao 2024-01-09 22:30:35 +08:00
parent 0c26c6d5bb
commit 0ddd611c59
3 changed files with 67 additions and 30 deletions

View File

@ -30,6 +30,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
}); });
UserFun.activeHeadFrame(call.uid, 'jjc_rank', data["rank"] + 1); UserFun.activeHeadFrame(call.uid, 'jjc_rank', data["rank"] + 1);
JJCFun.checkUpdatePlayer() //JJCFun.checkUpdatePlayer()
} }

View File

@ -94,37 +94,37 @@ export class JJCFun {
* @param uTimeOffset * @param uTimeOffset
* @param isUpdate * @param isUpdate
*/ */
static async checkUpdatePlayer(min: number = 0, max: number = 1000, uTimeOffset: number = 600, isUpdate: boolean = true) { // static async checkUpdatePlayer(min: number = 0, max: number = 1000, uTimeOffset: number = 600, isUpdate: boolean = true) {
// 获取指定排名用户uid // // 获取指定排名用户uid
let sortInfo = await this.getRankListUid(min, max) // let sortInfo = await this.getRankListUid(min, max)
if (!sortInfo.length) return [] // if (!sortInfo.length) return []
let updateArr = [] // 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++) { // for (let i = 0; i < sortInfo.length; i++) {
let uid = sortInfo[i] // let uid = sortInfo[i]
let rankInfo = users[uid] // let rankInfo = users[uid]
if (!rankInfo?.player) continue // if (!rankInfo?.player) continue
// 比对utime判断是否更新数据 // // 比对utime判断是否更新数据
if (!rankInfo.player.isNpc) { // if (!rankInfo.player.isNpc) {
if (!rankInfo.utime || (rankInfo.utime && rankInfo.utime < (G.time - uTimeOffset))) { // if (!rankInfo.utime || (rankInfo.utime && rankInfo.utime < (G.time - uTimeOffset))) {
updateArr.push(rankInfo) // updateArr.push(rankInfo)
} // }
} // }
} // }
// 更新数据 // // 更新数据
if (isUpdate && updateArr.length > 0) { // if (isUpdate && updateArr.length > 0) {
let playerArrInfo = await G.mongodb.collection("user").find({uid: {$in: updateArr.map(i => i.uid)}}).toArray() // let playerArrInfo = await G.mongodb.collection("user").find({uid: {$in: updateArr.map(i => i.uid)}}).toArray()
for (let i = 0; i < playerArrInfo.length; i++) { // for (let i = 0; i < playerArrInfo.length; i++) {
let playerInfo = playerArrInfo[i] // let playerInfo = playerArrInfo[i]
let index = updateArr.findIndex(x => x.player.uid == playerInfo.uid) // let index = updateArr.findIndex(x => x.player.uid == playerInfo.uid)
updateArr[index].player = playerInfo // updateArr[index].player = playerInfo
updateArr[index].utime = G.time // updateArr[index].utime = G.time
this.updatePlayerData(playerInfo.uid, updateArr[index]); // this.updatePlayerData(playerInfo.uid, updateArr[index]);
} // }
} // }
} // }
/** /**
* uid[] * uid[]

View File

@ -19,6 +19,8 @@ import {getGud, setGud} from './gud';
import {addGameLog} from "../gameLog"; import {addGameLog} from "../gameLog";
import {PushGiftFun} from "./pushgift"; import {PushGiftFun} from "./pushgift";
import { ActionLog } from './actionLog/actionLog'; import { ActionLog } from './actionLog/actionLog';
import { roleDataType } from '../shared/fightControl/fightType';
import { PlayerShared } from '../shared/public/player';
export type call = { export type call = {
@ -41,6 +43,41 @@ export type call = {
}; };
export class PlayerFun { 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数量 * atn数量
*/ */