Merge branch 'feature/huangqijiuguan' into release

This commit is contained in:
xichaoyin 2024-01-12 03:30:23 +08:00
commit f79f341998
11 changed files with 46 additions and 40 deletions

View File

@ -14,7 +14,7 @@ export default async function (call: ApiCall<ReqDuiHuan, ResDuiHuan>) {
let need = [];
let prize = [];
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
for (let id in call.req.dh) {
let con = hd.data.duihuan.filter(x => x.id == Number(id))[0];

View File

@ -14,7 +14,7 @@ export default async function (call: ApiCall<ReqFight, ResFight>) {
}
// 个人活动信息
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
// 开始战斗
let result: fightResult = await FightFun.fightNpc(call, hd.data.boss.npcId, 'hqjg');

View File

@ -15,7 +15,7 @@ export default async function (call: ApiCall<ReqGiftRec, ResGiftRec>) {
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
if ((mydata.giftbuy[call.req.giftid] || { num: 0 }).num + 1 > gift.buynum) {
return call.error("", { code: -2, message: globalThis.lng.hqjgtips_28 })
}

View File

@ -20,7 +20,7 @@ export default async function (call: ApiCall<ReqGiftSelect, ResGiftSelect>) {
}
}
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
if (!mydata.giftbuy[call.req.giftid]) {
mydata.giftbuy[call.req.giftid] = {
num: 0, select: call.req.seletc

View File

@ -9,7 +9,7 @@ export default async (call: ApiCall<ReqOpen, ResOpen>) => {
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
call.succ({ data: mydata })
}

View File

@ -14,7 +14,7 @@ export default async function (call: ApiCall<ReqRecDpsPrize, ResRecDpsPrize>) {
let data = hd.data as Data
// 个人活动信息
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
// 领取伤害奖励
let prize = [];

View File

@ -18,7 +18,7 @@ export default async function (call: ApiCall<ReqTaskRec, ResTaskRec>) {
let prize = [];
let taskday = `day${call.req.day}`
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
for (let id of call.req.taskid) {
let con = hd.data.task[taskday][id];
@ -36,17 +36,17 @@ export default async function (call: ApiCall<ReqTaskRec, ResTaskRec>) {
}
prize = prize.concat(con.prize);
mydata.task.rec[taskday] = (mydata.task.rec[taskday] || []).push(id)
mydata.task.rec[taskday] = (mydata.task.rec[taskday] || []).concat(id);
}
if (prize.length <= 0) {
return call.error("", { code: -2, message: globalThis.lng.hqjgtips_28 })
return call.error('', { code: -3, message: lng.hqjgtips_28 });
}
// 发送奖励
await PlayerFun.sendPrize(call, prize);
// 设置领取记录
await HQJGFun.setMyData(call.uid, call.req.hdid, mydata);
await HQJGFun.setMyData(call.uid, call.req.hdid, {task: mydata.task});
call.succ({ data: mydata, prize: prize });

View File

@ -17,7 +17,7 @@ export default async function (call: ApiCall<ReqZhaoMu, ResZhaoMu>) {
await PlayerFun.checkNeedIsMeet(call, need);
let prize = [];
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
for (let n = 1; n <= call.req.num; n++) {
let num = mydata.zhaomu.num + n;

View File

@ -11,7 +11,7 @@ export default async function (call: ApiCall<ReqZhaoMuPrizeRec, ResZhaoMuPrizeRe
}
let prize = [];
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
let mydata = await HQJGFun.getMydata(call, hd);
for (let rec of call.req.recid) {
let con = hd.data.choukajiangli[rec.idx];

View File

@ -83,9 +83,6 @@ export interface PlayerData {
// 今日奖励领取记录
recdpstask: number[]
}
// 最后修改数据时间
lasttime: number
}
export default class HQJGFun {
@ -116,7 +113,6 @@ export default class HQJGFun {
todaydps: {},
recdpstask: []
},
lasttime: 0
}
}
@ -174,36 +170,46 @@ export default class HQJGFun {
/** 获取我的数据 */
static async getMydata(call: ApiCall, hdid?: number) {
if (!hdid) {
hdid = (await HQJGFun.HdInfo(call)).hdid;
static async getMydata(call: ApiCall, hd?: ReqAddHuoDong) {
if (!hd) {
hd = await HQJGFun.HdInfo(call);
}
let data = await G.mongodb.cEvent(this.dataType(hdid)).findOne({
uid: call.uid, type: this.dataType(hdid)
let data = await G.mongodb.cEvent(this.dataType(hd.hdid)).findOne({
uid: call.uid, type: this.dataType(hd.hdid)
}, { projection: { _id: 0 } });
if (!data) {
data = (await G.mongodb.cEvent(this.dataType(hdid)).findOneAndUpdate({
uid: call.uid, type: this.dataType(hdid)
data = (await G.mongodb.cEvent(this.dataType(hd.hdid)).findOneAndUpdate({
uid: call.uid, type: this.dataType(hd.hdid)
}, {
$set: this.defaultData
}, { upsert: true, returnDocument: 'after', projection: { _id: 0 } })).value;
}
let today = this.today(hd);
if (!data.task.val[`day${today}`]) {
data.task.val[`day${today}`] = {};
let tasks = hd.data.task[`day${today}`];
for (let taskid in tasks) {
let taskcon = tasks[taskid];
data.task.val[`day${today}`][taskid] = await TaskFun.getTaskNval(call, taskcon);
}
await G.mongodb.collection('event').updateOne(
{ uid: call.uid, type: this.dataType(hd.hdid) },
{ $set: { [`task.val.day${today}`]: data.task.val[`day${today}`] } }
);
}
return data
}
/** 设置我的数据 */
static async setMyData(uid: string, hdid: number, update: { [k in keyof Partial<PlayerData>]: PlayerData[k] }) {
if (!update.lasttime) {
update.lasttime = G.time;
}
let res = await G.mongodb.cEvent(this.dataType(hdid)).updateOne(
{ uid: uid, type: this.dataType(hdid) }, { $set: update }
);
if (res.upsertedCount <= 0) {
if (res.modifiedCount <= 0) {
await G.mongodb.cEvent(this.dataType(hdid)).updateOne(
{ uid: uid, type: this.dataType(hdid) }, { $set: Object.assign(this.defaultData, update) }
);
@ -370,7 +376,7 @@ export default class HQJGFun {
if (!tasks) return
let mydata = await this.getMydata(call, hd.hdid);
let mydata = await this.getMydata(call, hd);
let isset = 0;
if (!mydata.task.val[`day${today}`]) {
@ -459,7 +465,7 @@ export default class HQJGFun {
let hdid = hd.hdid;
let hddata = hd.data as Data;
mydata = mydata || await this.getMydata(call, hdid);
mydata = mydata || await this.getMydata(call, hd);
// 当黄旗招募存在可领取的可选奖励时
for (let i = 0; i < hddata.choukajiangli.length; i++) {
let ele = hddata.choukajiangli[i];

View File

@ -350,18 +350,18 @@ class Lng {
event_kfkh_12 = "event_kfkh_12";
event_kfkh_13 = "event_kfkh_13";
qingxiandenglu: "qingxiandenglu";
wuciwanjia: "wuciwanjia";
huoqupaihang: "huoqupaihang";
wucigonghui: "wucigonghui";
nameyicunzai: "nameyicunzai";
ljlibaotips_8: "ljlibaotips_8";
qingxiandenglu = "qingxiandenglu";
wuciwanjia = "wuciwanjia";
huoqupaihang = "huoqupaihang";
wucigonghui = "wucigonghui";
nameyicunzai = "nameyicunzai";
ljlibaotips_8 = "ljlibaotips_8";
weiwang_12: "weiwang_12";
weiwang_12 = "weiwang_12";
hqjgtips_27: "hqjgtips_27";
hqjgtips_28: "hqjgtips_28";
hqjgtips_29: "hqjgtips_29";
hqjgtips_27 = "hqjgtips_27";
hqjgtips_28 = "hqjgtips_28";
hqjgtips_29 = "hqjgtips_29";
"11111" = "globalThis.lng.chat_1"
// return call.error('', { code: -3, message: globalThis.lng.chat_2 });