diff --git a/src/api_s2c/event/huangqijiuguan/fun.ts b/src/api_s2c/event/huangqijiuguan/fun.ts index 9df04e9..b6e8c0a 100644 --- a/src/api_s2c/event/huangqijiuguan/fun.ts +++ b/src/api_s2c/event/huangqijiuguan/fun.ts @@ -1,11 +1,11 @@ -import { ApiCall } from "tsrpc" -import { ReqAddHuoDong } from "../../../monopoly/protocols/PtlAddHuoDong" -import { HuoDongFun } from "../../../public/huodongfun" -import { PublicShared } from "../../../shared/public/public" -import { EmailFun } from "../../../public/email" -import { playerInfo } from "../../../shared/protocols/user/PtlLogin" -import { PlayerFun } from "../../../public/player" -import { TaskFun } from "../../../public/task" +import {ApiCall} from "tsrpc" +import {ReqAddHuoDong} from "../../../monopoly/protocols/PtlAddHuoDong" +import {HuoDongFun} from "../../../public/huodongfun" +import {PublicShared} from "../../../shared/public/public" +import {EmailFun} from "../../../public/email" +import {playerInfo} from "../../../shared/protocols/user/PtlLogin" +import {PlayerFun} from "../../../public/player" +import {TaskFun} from "../../../public/task" // hddata.data export interface Data { @@ -119,24 +119,24 @@ export default class HQJGFun { static today(hdinfo: ReqAddHuoDong) { /** * 获取活动开启到第几天 从1开始 - */ + */ return PublicShared.getDiff(hdinfo.stime, G.time) } /** * 获取排行榜 - */ + */ static async getRankList(hdid: number) { let uids = await G.mongodb.collection("event").find( - { type: this.dataType(hdid), "bossres.maxdps": { $gt: 0 } }, + {type: this.dataType(hdid), "bossres.maxdps": {$gt: 0}}, { - sort: { "bossres.maxdps": -1, "bossres.zhanli": -1 }, - projection: { uid: 1, bossres: 1 } + sort: {"bossres.maxdps": -1, "bossres.zhanli": -1}, + projection: {uid: 1, bossres: 1} } ).limit(50).toArray(); let userinfo = await G.mongodb.collection('user').find( - { uid: { $in: uids.map(v => v.uid) } }, + {uid: {$in: uids.map(v => v.uid)}}, ).toArray(); let res = []; @@ -144,7 +144,7 @@ export default class HQJGFun { let uid = uids[rank - 1].uid; let user = userinfo.find(v => v.uid == uid); if (user) { - res.push({ rank, ...user, valArr: [uids[rank - 1].bossres.maxdps] }); + res.push({rank, ...user, valArr: [uids[rank - 1].bossres.maxdps]}); } } @@ -176,14 +176,14 @@ export default class HQJGFun { } let data = await G.mongodb.cEvent(this.dataType(hd.hdid)).findOne({ uid: call.uid, type: this.dataType(hd.hdid) - }, { projection: { _id: 0 } }); + }, {projection: {_id: 0}}); if (!data) { 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; + }, {upsert: true, returnDocument: 'after', projection: {_id: 0}})).value; } let today = this.today(hd); @@ -195,8 +195,8 @@ export default class HQJGFun { 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}`] } } + {uid: call.uid, type: this.dataType(hd.hdid)}, + {$set: {[`task.val.day${today}`]: data.task.val[`day${today}`]}} ); } @@ -206,12 +206,13 @@ export default class HQJGFun { /** 设置我的数据 */ static async setMyData(uid: string, hdid: number, update: { [k in keyof Partial]: PlayerData[k] }) { let res = await G.mongodb.cEvent(this.dataType(hdid)).updateOne( - { uid: uid, type: this.dataType(hdid) }, { $set: update } + {uid: uid, type: this.dataType(hdid)}, {$set: update} ); if (res.modifiedCount <= 0) { + console.log("===>", uid, hdid, update); await G.mongodb.cEvent(this.dataType(hdid)).updateOne( - { uid: uid, type: this.dataType(hdid) }, { $set: Object.assign(this.defaultData, update) } + {uid: uid, type: this.dataType(hdid)}, {$set: Object.assign(this.defaultData, update)} ); } } @@ -225,8 +226,8 @@ export default class HQJGFun { ) // 取stime小于当前时间的最后一条数据 let hdinfo = await G.mongodb.collection("hdinfo").find({ - htype: this.htype, stime: { $lte: time } - }, { sort: { stime: -1 } }).limit(1).toArray(); + htype: this.htype, stime: {$lte: time} + }, {sort: {stime: -1}}).limit(1).toArray(); // 没有活动数 if (hdinfo.length <= 0) { @@ -241,7 +242,7 @@ export default class HQJGFun { } let today = PublicShared.getDiff(hd.stime, G.time - 300); - G.mongodb.collection("event").find({ type: `huangqijiuguan_${hdid}` }).toArray().then(datas => { + G.mongodb.collection("event").find({type: `huangqijiuguan_${hdid}`}).toArray().then(datas => { let hddata = hd.data as Data; for (let i = 0; i < datas.length; i++) { let data = datas[i]; @@ -277,7 +278,7 @@ export default class HQJGFun { /** * 最大伤害排行奖励结算 - */ + */ static async endDpsRankPrize(time: number) { console.log( "黄旗酒馆 最大伤害排行奖励结算 开始执行。。。" @@ -287,7 +288,7 @@ export default class HQJGFun { // 查询昨天23:59:00或者今天00:00:00结束的活动 let hdinfo = await G.mongodb.collection("hdinfo").find({ - htype: this.htype, rtime: { $gt: yesterday, $lte: today } + htype: this.htype, rtime: {$gt: yesterday, $lte: today} }).toArray(); // 没有活动数 或者发奖标识已设置 @@ -303,10 +304,10 @@ export default class HQJGFun { } let uids = await G.mongodb.collection("event").find( - { type: this.dataType(hdid) }, + {type: this.dataType(hdid)}, { - sort: { "bossres.maxdps": -1, "bossres.zhanli": -1 }, - projection: { uid: 1, bossres: 1 } + sort: {"bossres.maxdps": -1, "bossres.zhanli": -1}, + projection: {uid: 1, bossres: 1} } ).toArray(); @@ -327,7 +328,7 @@ export default class HQJGFun { } // 标记已发送 await G.mongodb.collection("hdinfo").updateOne( - { hdid: hdid }, { $set: { "data.sendrank": true } } + {hdid: hdid}, {$set: {"data.sendrank": true}} ); // 货币兑换 G.mongodb.collection("user").find().toArray().then(async (users) => { @@ -408,7 +409,7 @@ export default class HQJGFun { // 设置任务 if (isset == 1) { - await G.mongodb.collection('event').updateOne({ uid: call.uid, type: this.dataType(hd.hdid) }, { + await G.mongodb.collection('event').updateOne({uid: call.uid, type: this.dataType(hd.hdid)}, { $set: { [`task.val.day${today}`]: mydata.task.val[`day${today}`] } @@ -435,13 +436,13 @@ export default class HQJGFun { let mydata = await this.getMydata(call, hd); if (!mydata.giftbuy[gift.id]) { - mydata.giftbuy[gift.id] = { num: 0, select: [] }; + mydata.giftbuy[gift.id] = {num: 0, select: []}; } let prize: atn[] = []; if (mydata.giftbuy[gift.id].num + 1 > gift.buynum) { let pay = G.gc.pay[payId]; - prize.push({ a: "attr", t: "rmbmoney", n: pay.payExp[0].n }) + prize.push({a: "attr", t: "rmbmoney", n: pay.payExp[0].n}) } else { prize = gift.prize; for (let i = 0; i < gift.dlz.length; i++) { @@ -458,7 +459,7 @@ export default class HQJGFun { mydata.giftbuy[gift.id].num++; // 发送奖励 await PlayerFun.sendPrize(call, prize, true); - await this.setMyData(call.uid, hd.hdid, { giftbuy: mydata.giftbuy }); + await this.setMyData(call.uid, hd.hdid, {giftbuy: mydata.giftbuy}); } static async getHongDian(call: ApiCall, hd: ReqAddHuoDong, mydata?: PlayerData) { @@ -470,14 +471,14 @@ export default class HQJGFun { for (let i = 0; i < hddata.choukajiangli.length; i++) { let ele = hddata.choukajiangli[i]; if (mydata.zhaomu.num >= ele.num && !mydata.zhaomu.prize.includes(i)) { - return { show: true } + return {show: true} } } let today = this.today(hd); // 当今日没有进行boss挑战时 if (!mydata.bossres.todaydps[today]) { - return { show: true } + return {show: true} } // 当每日任务界面存在可领取的任务奖励时 @@ -485,7 +486,7 @@ export default class HQJGFun { for (let taskid in hddata.task[`day${day}`]) { let task = hddata.task[`day${day}`][taskid]; if (mydata.task.val[`day${day}`]?.[taskid] >= task.pval && !(mydata.task.rec?.[`day${day}`] || []).includes(Number(taskid))) { - return { show: true } + return {show: true} } } } @@ -493,17 +494,17 @@ export default class HQJGFun { // 当干部挑战界面存在可领取的挑战任务奖励时 for (let mb of hddata.bossTask) { if (mb.need <= mydata.bossres.maxdps && !mydata.bossres.recdpstask.includes(mb.id)) { - return { show: true } + return {show: true} } } // 当存在可以领取的免费礼包时 for (let gift of hddata.gift) { if (gift.free && (mydata.giftbuy[gift.id]?.num || 0) < gift.buynum) { - return { show: true } + return {show: true} } } - return { show: false } + return {show: false} } } \ No newline at end of file