diff --git a/src/api_s2c/event/huangqijiuguan/ApiZhaoMu.ts b/src/api_s2c/event/huangqijiuguan/ApiZhaoMu.ts index b672a94..0b22e98 100644 --- a/src/api_s2c/event/huangqijiuguan/ApiZhaoMu.ts +++ b/src/api_s2c/event/huangqijiuguan/ApiZhaoMu.ts @@ -19,7 +19,7 @@ export default async function (call: ApiCall) { let prize = []; let mydata = await HQJGFun.getMydata(call, call.req.hdid); - for (let n = 0; n < call.req.num; n++) { + for (let n = 1; n <= call.req.num; n++) { let num = mydata.zhaomu.num + n; let baodi = hd.data.baodi.filter(x => x.num == num); if (baodi.length > 0) { diff --git a/src/api_s2c/event/huangqijiuguan/fun.ts b/src/api_s2c/event/huangqijiuguan/fun.ts index 1ee383d..abf61a9 100644 --- a/src/api_s2c/event/huangqijiuguan/fun.ts +++ b/src/api_s2c/event/huangqijiuguan/fun.ts @@ -214,10 +214,13 @@ export default class HQJGFun { /** * 每日伤害等级奖励结算 */ - static async dayDpsLvPrize() { + static async dayDpsLvPrize(time: number) { + console.log( + "黄旗酒馆 每日伤害等级奖励结算 开始执行。。。" + ) // 取stime小于当前时间的最后一条数据 let hdinfo = await G.mongodb.collection("hdinfo").find({ - htype: this.htype, stime: { $lte: G.time } + htype: this.htype, stime: { $lte: time } }, { sort: { stime: -1 } }).limit(1).toArray(); // 没有活动数 @@ -227,6 +230,7 @@ export default class HQJGFun { let hd = hdinfo[0]; let hdid = hdinfo[0].hdid; + // 活动结束 if (hd.etime < G.time - 300) { return } @@ -260,17 +264,26 @@ export default class HQJGFun { contentInsertArr: [lvprize.lv], }) } + console.log( + "黄旗酒馆 每日伤害等级奖励结算 执行完成!!!" + ) }) } /** * 最大伤害排行奖励结算 */ - static async endDpsRankPrize() { - // 取stime小于当前时间的最后一条数据 + static async endDpsRankPrize(time: number) { + console.log( + "黄旗酒馆 最大伤害排行奖励结算 开始执行。。。" + ) + let today = PublicShared.getToDayZeroTime(time + 300); + let yesterday = PublicShared.getToDayZeroTime(time - 300); + + // 查询昨天23:59:00或者今天00:00:00结束的活动 let hdinfo = await G.mongodb.collection("hdinfo").find({ - htype: this.htype, stime: { $lte: G.time } - }, { sort: { stime: -1 } }).limit(1).toArray(); + htype: this.htype, rtime: { $gt: yesterday, $lte: today } + }).toArray(); // 没有活动数 if (hdinfo.length <= 0) { @@ -279,7 +292,7 @@ export default class HQJGFun { let hd = hdinfo[0]; let hdid = hdinfo[0].hdid; - if (hd.etime < G.time - 300) { + if (hd.data.sendrank) { return } @@ -306,5 +319,16 @@ export default class HQJGFun { contentInsertArr: [rank], }) } + // 标记已发送 + await G.mongodb.collection("hdinfo").updateOne( + { hdid: hdid }, { $set: { "data.sendrank": true } } + ); + + console.log( + "黄旗酒馆 最大伤害排行奖励结算 执行结束!!!" + ) } } + +G.on("NEW_DAY", HQJGFun.dayDpsLvPrize.bind(HQJGFun)); +G.on("NEW_DAY", HQJGFun.endDpsRankPrize.bind(HQJGFun)); \ No newline at end of file diff --git a/src/globalListener.ts b/src/globalListener.ts index 57fee50..d396c76 100644 --- a/src/globalListener.ts +++ b/src/globalListener.ts @@ -15,13 +15,14 @@ import { ZhanLingTasks } from './public/zhanling'; import { player } from './shared/protocols/user/type'; import { PublicShared } from './shared/public/public'; import { setGud } from './public/gud'; -import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen"; -import {Christmasfun} from "./api_s2c/event/christmas/fun"; -import {PushGiftFun} from "./public/pushgift"; -import {LeiChongLiBaoBuyGift} from "./api_s2c/event/leichonglibao/ApiReceive"; +import { checkResetBuyLog } from "./api_s2c/event/zhoumolibao/ApiOpen"; +import { PushGiftFun } from "./public/pushgift"; +import { LeiChongLiBaoBuyGift } from "./api_s2c/event/leichonglibao/ApiReceive"; import { HongDianChange } from './api_s2c/hongdian/fun'; export type gEventType = { + /**新的一天 */ + NEW_DAY: (time: number) => void; /**玩家断开连接 */ PLAYER_DISCONNECT: (uid: string) => void; /**玩家修改名字 */ @@ -165,7 +166,7 @@ export function addListener() { XstaskFun.uidTask[uid] = null; delete XstaskFun.uidTask[uid]; } - setGud(uid,{ logoutTime: G.time }); + setGud(uid, { logoutTime: G.time }); G.mongodb.collection('user').updateOne({ uid: uid }, { $set: { logoutTime: G.time } }); }); @@ -177,7 +178,7 @@ export function addListener() { } }); - G.on('PLAYER_PAY', async (player, payId, payArgs,call) => { + G.on('PLAYER_PAY', async (player, payId, payArgs, call) => { let conf: any = await PayFun.getConf(payId, payArgs); ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n }); ActionLog.addRetainLog(player.uid, { key: 'pay', val: conf.payExp[0].n }); diff --git a/src/public/scheduler/scheduler_newDay.ts b/src/public/scheduler/scheduler_newDay.ts index 2e6598a..253adcc 100644 --- a/src/public/scheduler/scheduler_newDay.ts +++ b/src/public/scheduler/scheduler_newDay.ts @@ -59,6 +59,9 @@ export class SchedulerNewDayLocalCtor extends Scheduler { } } })() + + // 转点刷新事件 + G.emit('NEW_DAY', G.time); }) let users = Object.values(G.server.uid_connections)