diff --git a/src/api_s2c/jjc/ApiOpen.ts b/src/api_s2c/jjc/ApiOpen.ts index 700ada3..0d6b0ee 100644 --- a/src/api_s2c/jjc/ApiOpen.ts +++ b/src/api_s2c/jjc/ApiOpen.ts @@ -30,6 +30,6 @@ export default async function (call: ApiCall) { }); UserFun.activeHeadFrame(call.uid, 'jjc_rank', data["rank"] + 1); - JJCFun.checkUpdatePlayer() + //JJCFun.checkUpdatePlayer() } \ No newline at end of file diff --git a/src/public/jjc.ts b/src/public/jjc.ts index d571417..67726f1 100644 --- a/src/public/jjc.ts +++ b/src/public/jjc.ts @@ -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[] diff --git a/src/public/player.ts b/src/public/player.ts index 2647bce..1cf7ef2 100644 --- a/src/public/player.ts +++ b/src/public/player.ts @@ -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 = {}; + 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数量 */