fix:处理强化伙伴活动初始没有任务进度的逻辑
This commit is contained in:
parent
452f5f3d14
commit
a26aa7dab3
@ -12,11 +12,37 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
// 无此活动
|
// 无此活动
|
||||||
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
|
||||||
}
|
}
|
||||||
|
|
||||||
let db = await G.mongodb.cEvent(`chuanshuozhilu${call.req.hdid}`).findOne({ uid: call.uid, type: `chuanshuozhilu${call.req.hdid}` });
|
let db = await G.mongodb.cEvent(`chuanshuozhilu${call.req.hdid}`).findOne({ uid: call.uid, type: `chuanshuozhilu${call.req.hdid}` });
|
||||||
|
let _info = db?.info || {}
|
||||||
|
// 如果初始没有数据,就判断玩家是否有活动对应的影响,生成一下初始化数据
|
||||||
|
if (!db) {
|
||||||
|
|
||||||
|
let _dbType: `chuanshuozhilu${number}` = `chuanshuozhilu${call.req.hdid}`
|
||||||
|
const hid = _hdinfo.data.hid
|
||||||
|
let heros = await G.mongodb.collection("hero").find({uid: call.uid, heroId: hid})
|
||||||
|
.sort({ "zhanli": -1 }).limit(1).toArray();
|
||||||
|
|
||||||
|
if (heros) {
|
||||||
|
let hero = heros[0]
|
||||||
|
const lv = hero.lv || 0
|
||||||
|
const jieji = hero.jieji || 0
|
||||||
|
let setInfo = {"lv": lv, "jieji": jieji}
|
||||||
|
await G.mongodb.cEvent(_dbType).updateOne(
|
||||||
|
{ uid: call.uid, type: _dbType },
|
||||||
|
{ $set: G.mongodb.createTreeObj({ key: `info.${hid}`, val: setInfo})},
|
||||||
|
{ upsert: true}
|
||||||
|
)
|
||||||
|
if (!cache[call.uid]) cache[call.uid] = {hid:{}};
|
||||||
|
if (!cache[call.uid][hid]) cache[call.uid][hid] = setInfo;
|
||||||
|
_info[hid] = setInfo
|
||||||
|
G.server.sendMsgByUid(call.uid, 'msg_s2c/HongDianChange', ['huodonghd']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
info: db?.info || {},
|
info: _info,
|
||||||
hdinfo: _hdinfo
|
hdinfo: _hdinfo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user