Compare commits

...

2 Commits

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);
JJCFun.checkUpdatePlayer()
//JJCFun.checkUpdatePlayer()
}

View File

@ -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[]

View File

@ -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数量
*/