fix:
1.下限保底,拉去英雄列表时,检测英雄穿戴的peijian是否存在,不存在就置空
This commit is contained in:
parent
8247613c27
commit
7e24671983
@ -1,11 +1,12 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { RedisCollections2 } from '../../module/redis';
|
import {RedisCollections2} from '../../module/redis';
|
||||||
import { ReqGetList, ResGetList } from "../../shared/protocols/hero/PtlGetList";
|
import {ReqGetList, ResGetList} from "../../shared/protocols/hero/PtlGetList";
|
||||||
|
import {PeijianShared} from "../../shared/public/peijian";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||||
let list: ResGetList['list'] = {};
|
let list: ResGetList['list'] = {};
|
||||||
//let kvList: k_v<RedisCollections2['hero']> = {};
|
//let kvList: k_v<RedisCollections2['hero']> = {};
|
||||||
let arrList = await G.mongodb.collection('hero').find({ uid: call.uid }).toArray();
|
let arrList = await G.mongodb.collection('hero').find({uid: call.uid}).toArray();
|
||||||
|
|
||||||
let heroCon = G.gc.hero;
|
let heroCon = G.gc.hero;
|
||||||
let color = {};
|
let color = {};
|
||||||
@ -19,14 +20,47 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
|||||||
if (!color[heroCon[v.heroId].colour]) color[heroCon[v.heroId].colour] = 0;
|
if (!color[heroCon[v.heroId].colour]) color[heroCon[v.heroId].colour] = 0;
|
||||||
color[heroCon[v.heroId].colour] += 1;
|
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 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'},
|
||||||
{ $set: { maxherolv: maxherolv, herocolor: color } }, { upsert: true });
|
{$set: {maxherolv: maxherolv, herocolor: color}}, {upsert: true});
|
||||||
|
|
||||||
//G.redis.set('hero', call.uid, kvList);
|
//G.redis.set('hero', call.uid, kvList);
|
||||||
|
|
||||||
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_hero').findOne({ uid: call.conn.uid, type: 'lshd_hero' });
|
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_hero').findOne({
|
||||||
let { uid, _id, type, ...heros } = (recLshd || {});
|
uid: call.conn.uid,
|
||||||
|
type: 'lshd_hero'
|
||||||
|
});
|
||||||
|
let {uid, _id, type, ...heros} = (recLshd || {});
|
||||||
|
|
||||||
|
|
||||||
call.conn.lshd.hero = heros || {};
|
call.conn.lshd.hero = heros || {};
|
||||||
@ -34,6 +68,6 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
|||||||
list: list,
|
list: list,
|
||||||
pos: call.conn.heroPos,
|
pos: call.conn.heroPos,
|
||||||
lshd: heros || {},
|
lshd: heros || {},
|
||||||
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 || {}
|
||||||
});
|
});
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user