修复玩家出现的饰品和配件数据错误导致的进不去游戏
This commit is contained in:
parent
09b74e3490
commit
1090852522
@ -21,34 +21,7 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
|||||||
color[heroCon[v.heroId].colour] += 1;
|
color[heroCon[v.heroId].colour] += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 修复配件数据
|
checkDataAndFix(call, list)
|
||||||
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 G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'},
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'},
|
||||||
@ -69,3 +42,63 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
|||||||
gbzj: (await G.mongodb.cPlayerInfo('gbzj').findOne({uid: call.uid, type: 'gbzj'}))?.rec || {}
|
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