Compare commits
4 Commits
60bcf1d794
...
76f9dd1f98
Author | SHA1 | Date | |
---|---|---|---|
![]() |
76f9dd1f98 | ||
![]() |
71c0506a72 | ||
![]() |
1090852522 | ||
![]() |
09b74e3490 |
@ -1,18 +1,23 @@
|
||||
import { ApiCall } from "tsrpc";
|
||||
import { ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser } from "../../cross/protocols/hbzb/PtlUpdateHbzbCrossUser";
|
||||
import {ApiCall} from "tsrpc";
|
||||
import {ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser} from "../../cross/protocols/hbzb/PtlUpdateHbzbCrossUser";
|
||||
|
||||
/**更新跨服数据库里,黑帮争霸的玩家数据 */
|
||||
export default async function (call: ApiCall<ReqUpdateHbzbCrossUser, ResUpdateHbzbCrossUser>) {
|
||||
let setData = {
|
||||
"data":{
|
||||
let setData: any = {
|
||||
"data": {
|
||||
player: call.req.user.player,
|
||||
roles: call.req.user.roles,
|
||||
uid: call.req.uid
|
||||
},
|
||||
"jifen": -999999,
|
||||
"rank": -999999,
|
||||
"zbsgroup":""
|
||||
};
|
||||
G.mongodb.collection('hbzb_user_cross').updateOne({ uid: setData.data.uid }, { $set: setData }, { upsert: true });
|
||||
call.succ({ });
|
||||
if (call.req.isNew) {
|
||||
setData = {
|
||||
...setData,
|
||||
"jifen": -999999,
|
||||
"rank": -999999,
|
||||
"zbsgroup": ""
|
||||
}
|
||||
}
|
||||
G.mongodb.collection('hbzb_user_cross').updateOne({uid: setData.data.uid}, {$set: setData}, {upsert: true});
|
||||
call.succ({});
|
||||
}
|
@ -1,18 +1,16 @@
|
||||
import { ApiCall } from "tsrpc";
|
||||
import { Rank } from '../../../public/rank/rank';
|
||||
import { ReqOpen, ResOpen } from "../../../shared/protocols/hbzb/jfs/PtlOpen";
|
||||
import { PublicShared } from '../../../shared/public/public';
|
||||
import { getHbzbData, getMyRank, getToper200RankUid, updateHbzbCrossUser } from "./fun";
|
||||
import {ApiCall} from "tsrpc";
|
||||
import {Rank} from '../../../public/rank/rank';
|
||||
import {ReqOpen, ResOpen} from "../../../shared/protocols/hbzb/jfs/PtlOpen";
|
||||
import {PublicShared} from '../../../shared/public/public';
|
||||
import {getHbzbData, getMyRank, getToper200RankUid, updateHbzbCrossUser} from "./fun";
|
||||
|
||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
//查看本地数据库里,刷出来的玩家数据
|
||||
let dbData = await getHbzbData(call.uid );
|
||||
let dbData = await getHbzbData(call.uid);
|
||||
let data: typeof dbData.data = dbData?.data || {} as any;
|
||||
|
||||
if (dbData == null) {
|
||||
//如果没有,则同步到跨服
|
||||
await updateHbzbCrossUser(await call.conn.getDefaultFightData(), true);
|
||||
}
|
||||
//如果没有,则同步到跨服
|
||||
await updateHbzbCrossUser(await call.conn.getDefaultFightData(), dbData == null);
|
||||
|
||||
if (!data.refreshTime || data.refreshTime < PublicShared.getToDayZeroTime()) {
|
||||
data.winNum = 0;
|
||||
@ -26,19 +24,21 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
//积分赛时的排行榜,是本服积分排序
|
||||
data.jifen = 0;
|
||||
//但是刷出来的对手,是跨服的玩家
|
||||
let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', { uid: call.uid, auto: true });
|
||||
if (!callRes.isSucc){
|
||||
let callRes = await G.clientCross.callApi('hbzb/jfs/GetEnemy', {uid: call.uid, auto: true});
|
||||
if (!callRes.isSucc) {
|
||||
//todo 健壮性处理
|
||||
return call.errorCode(-4)
|
||||
}
|
||||
if (callRes.res.enemy.length)
|
||||
data.enemy = callRes.res.enemy.map(e => { return { ...e, result: null }; });
|
||||
data.enemy = callRes.res.enemy.map(e => {
|
||||
return {...e, result: null};
|
||||
});
|
||||
}
|
||||
|
||||
G.mongodb.cPlayerInfo('hbzb').updateOne(
|
||||
{ uid: call.uid, type: 'hbzb' },
|
||||
{ $set: { data: data } },
|
||||
{ upsert: true }
|
||||
{uid: call.uid, type: 'hbzb'},
|
||||
{$set: {data: data}},
|
||||
{upsert: true}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,34 +21,7 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
color[heroCon[v.heroId].colour] += 1;
|
||||
});
|
||||
|
||||
// 修复配件数据
|
||||
let peijianids = [];
|
||||
Object.values(list).map(hero => {
|
||||
hero.peijian && Object.values(hero.peijian).map(
|
||||
i => peijianids.push(G.mongodb.conversionId(PeijianShared.fmt(i)._id))
|
||||
)
|
||||
});
|
||||
|
||||
let peijians = (await G.mongodb.collection("peijian").find(
|
||||
{uid: call.uid, _id: {$in: peijianids}}, {projection: {_id: 1}}
|
||||
).toArray()).map(temp => G.mongodb.conversionId(temp._id));
|
||||
|
||||
let changes = {};
|
||||
Object.values(list).map(hero => {
|
||||
for (let pos in hero.peijian) {
|
||||
if (!peijians.includes(PeijianShared.fmt(hero.peijian[pos])._id)) {
|
||||
hero.peijian[pos] = "";
|
||||
changes[hero._id] = hero.peijian;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
for (let oid in changes) {
|
||||
// 修复数据
|
||||
G.mongodb.collection("hero").updateOne(
|
||||
G.mongodb.conversionIdObj({_id: oid}), {$set: {peijian: changes[oid]}}
|
||||
)
|
||||
}
|
||||
await checkDataAndFix(call, list)
|
||||
|
||||
// 记录玩家最大等级,颜色相关数据 注册任务用
|
||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'},
|
||||
@ -68,4 +41,64 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
lshd: heros || {},
|
||||
gbzj: (await G.mongodb.cPlayerInfo('gbzj').findOne({uid: call.uid, type: 'gbzj'}))?.rec || {}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 修复玩家出现的饰品和配件数据错误导致的进不去游戏
|
||||
* @param call
|
||||
* @param list
|
||||
*/
|
||||
async function checkDataAndFix(call: ApiCall, list: ResGetList['list']) {
|
||||
try {
|
||||
// 修复配件数据
|
||||
let peijianids = [];
|
||||
Object.values(list).map(hero => {
|
||||
hero.peijian && Object.values(hero.peijian).map(
|
||||
i => peijianids.push(G.mongodb.conversionId(PeijianShared.fmt(i)._id))
|
||||
)
|
||||
});
|
||||
|
||||
let peijians = (await G.mongodb.collection("peijian").find(
|
||||
{uid: call.uid, _id: {$in: peijianids}}, {projection: {_id: 1}}
|
||||
).toArray()).map(temp => G.mongodb.conversionId(temp._id));
|
||||
|
||||
let shiwuIds = R.flatten(R.values(list).map(hero => R.values(hero.shiwu).map(i => G.mongodb.conversionId(i._id))))
|
||||
|
||||
let shiwus = (await G.mongodb.collection("shiwu").find(
|
||||
{uid: call.uid, _id: {$in: shiwuIds}}, {projection: {_id: 1}}
|
||||
).toArray()).map(i => G.mongodb.conversionId(i._id));
|
||||
|
||||
let peijianChanges = {};
|
||||
let shiwuChanges = {};
|
||||
Object.values(list).map(hero => {
|
||||
for (let pos in hero.peijian) {
|
||||
if (!peijians.includes(PeijianShared.fmt(hero.peijian[pos])._id)) {
|
||||
hero.peijian[pos] = "";
|
||||
peijianChanges[hero._id] = hero.peijian;
|
||||
}
|
||||
}
|
||||
for (let pos in hero.shiwu) {
|
||||
if (!shiwus.includes(hero.shiwu[pos]._id)) {
|
||||
hero.shiwu = R.omit([pos], hero.shiwu)
|
||||
shiwuChanges[hero._id] = hero.shiwu;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
for (let oid in peijianChanges) {
|
||||
// 修复数据
|
||||
G.mongodb.collection("hero").updateOne(
|
||||
G.mongodb.conversionIdObj({_id: oid}), {$set: {peijian: peijianChanges[oid]}}
|
||||
)
|
||||
}
|
||||
|
||||
for (let oid in shiwuChanges) {
|
||||
// 修复数据
|
||||
G.mongodb.collection("hero").updateOne(
|
||||
G.mongodb.conversionIdObj({_id: oid}), {$set: {shiwu: shiwuChanges[oid]}}
|
||||
)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('======修复英雄配件和饰物报错====',e)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user