Compare commits

..

4 Commits

Author SHA1 Message Date
yushunrui
48d512a3a6 Merge branch 'bugfix' into dev
# Conflicts:
#	src/api_s2c/event/chuanshuozhilu/ApiOpen.ts
2024-01-10 21:26:19 +08:00
yushunrui
b80263ed16 fix:竞技场第一名头像特殊处理,可以用道具直接解锁 2024-01-10 21:17:04 +08:00
yushunrui
363787fb39 Revert "fix:竞技场第一名头像特殊处理,可以用道具直接解锁"
This reverts commit 0a94965e30.
2024-01-10 21:16:13 +08:00
yushunrui
0a94965e30 fix:竞技场第一名头像特殊处理,可以用道具直接解锁 2024-01-10 21:14:10 +08:00

View File

@ -12,11 +12,38 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
// 无此活动
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 _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({
info: db?.info || {},
info: _info,
hdinfo: _hdinfo
});
}