diff --git a/src/api_s2c/event/huangqijiuguan/fun.ts b/src/api_s2c/event/huangqijiuguan/fun.ts index ec907e8..1e4a6bc 100644 --- a/src/api_s2c/event/huangqijiuguan/fun.ts +++ b/src/api_s2c/event/huangqijiuguan/fun.ts @@ -9,7 +9,7 @@ export interface Data { show: 1 task: { [k: `day${number}`]: { - [k: string]: { pval: number, stype: string, cond: string[], tiaozhuan: number, prize: atn[], des: string } + [k: string]: { pval: number, stype: number, cond: string[], tiaozhuan: number, prize: atn[], des: string } } } @@ -331,6 +331,44 @@ export default class HQJGFun { "黄旗酒馆 最大伤害排行奖励结算 执行结束!!!" ) } + + /**设置任务 */ + static async setTaskVal(call: ApiCall, stype: number, val: number, chkCall: Function, chkval: number = 0, isinc: number = 0, alchangeVal: Function, arg) { + // 活动过期,不计数 + let hd = await this.HdInfo(call) + if (!hd) return + + let today = this.today(hd); + await this.getMydata(call, hd.hdid) + + let isset = 0; + let setData = { + $inc: {}, + $set: {} + }; + let tasks = hd.data.task[`day${today}`]; + for (let taskCon of Object.values(tasks)) { + if (taskCon.stype != stype) continue + + // 不符合任务要求 + if (!(await chkCall(taskCon["cond"], chkval, arg))) continue + + // 根据需求改写 + val = await alchangeVal(call, taskCon, val, arg) + + isset = 1 + if (isinc == 1) { // 累加 + setData["$inc"][`task.val.day${today}`] = val + } else { + setData["$set"][`task.val.day${today}`] = val + } + } + + // 设置任务 + if (isset == 1) { + await G.mongodb.collection('event').updateOne({ uid: call.uid, type: this.dataType(hd.hdid) }, setData) + } + } } G.on("NEW_DAY", HQJGFun.dayDpsLvPrize.bind(HQJGFun)); diff --git a/src/public/taskclass.ts b/src/public/taskclass.ts index 878a7a2..88ad56f 100644 --- a/src/public/taskclass.ts +++ b/src/public/taskclass.ts @@ -1,19 +1,20 @@ -import {ApiCall} from "tsrpc" -import {YangChengMuBiaofun} from "../api_s2c/event/yangchengmubiao/fun" -import {Christmasfun} from "../api_s2c/event/christmas/fun" +import { ApiCall } from "tsrpc" +import { YangChengMuBiaofun } from "../api_s2c/event/yangchengmubiao/fun" +import { Christmasfun } from "../api_s2c/event/christmas/fun" // import { YangChengMuBiaofun } from "../api_s2c/event/yangchengmubiao/fun" -import {Wjjl} from "../module/collection_wjjl" -import {PublicShared} from "../shared/public/public" -import {PayFun} from "./pay" -import {TaskFun} from "./task" -import {CollectionWanted} from "../module/collection_wanted"; -import {TanXianFun} from "./tanxian"; -import {PataFun} from "./pata"; -import {weixiuchangType} from "../shared/protocols/weixiuchang/type"; -import {FunWeiXiuChang} from "./weixiuchang"; -import {JJCFun} from "./jjc"; -import {getGud} from "./gud"; -import {Yuandanfun} from "../api_s2c/event/yuandan/fun"; +import { Wjjl } from "../module/collection_wjjl" +import { PublicShared } from "../shared/public/public" +import { PayFun } from "./pay" +import { TaskFun } from "./task" +import { CollectionWanted } from "../module/collection_wanted"; +import { TanXianFun } from "./tanxian"; +import { PataFun } from "./pata"; +import { weixiuchangType } from "../shared/protocols/weixiuchang/type"; +import { FunWeiXiuChang } from "./weixiuchang"; +import { JJCFun } from "./jjc"; +import { getGud } from "./gud"; +import { Yuandanfun } from "../api_s2c/event/yuandan/fun"; +import HQJGFun from "../api_s2c/event/huangqijiuguan/fun" let _classNameFunc = {} /** @@ -72,13 +73,15 @@ export module manager { // 设置数据 async setVal(call: ApiCall, val: number, chkval, arg) { - TaskFun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg) + TaskFun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg); // 养成目标任务计数 - YangChengMuBiaofun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg) + YangChengMuBiaofun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg); // 圣诞活动任务计数 - Christmasfun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg) + Christmasfun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg); // 元旦活动任务计数 - Yuandanfun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg) + Yuandanfun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg); + // 黄旗酒馆 + HQJGFun.setTaskVal(call, this.stype, val, this.chkCall, chkval, this.isinc, this.alchangeVal, arg); } // 任务数值, 和检测值,看情况需要上层复写 @@ -167,12 +170,12 @@ export module manager { async initVal(call: ApiCall, con) { let _chk = parseInt(con.cond[0]) - return await G.mongodb.collection('hero').countDocuments({uid: call.uid, lv: {$gte: _chk}}) || 0 + return await G.mongodb.collection('hero').countDocuments({ uid: call.uid, lv: { $gte: _chk } }) || 0 } async alchangeVal(call: ApiCall, con, val: number) { let _chk = parseInt(con.cond[0]) - return await G.mongodb.collection('hero').countDocuments({uid: call.uid, lv: {$gte: _chk}}) || 0 + return await G.mongodb.collection('hero').countDocuments({ uid: call.uid, lv: { $gte: _chk } }) || 0 } } @@ -194,13 +197,13 @@ export module manager { async initVal(call: ApiCall, con) { let _chk = parseInt(con.cond[0]) - let _num = await G.mongodb.collection('hero').countDocuments({uid: call.uid, jieji: {$gte: _chk}}) || 0 + let _num = await G.mongodb.collection('hero').countDocuments({ uid: call.uid, jieji: { $gte: _chk } }) || 0 return _num } async alchangeVal(call: ApiCall, con, val: number) { let _chk = parseInt(con.cond[0]) - let _num = await G.mongodb.collection('hero').countDocuments({uid: call.uid, jieji: {$gte: _chk}}) || 0 + let _num = await G.mongodb.collection('hero').countDocuments({ uid: call.uid, jieji: { $gte: _chk } }) || 0 return _num } } @@ -256,13 +259,13 @@ export module manager { async initVal(call: ApiCall, con) { let _chk = parseInt(con.cond[0]) - let _num = await G.mongodb.collection('equip').countDocuments({uid: call.uid, lv: {$gte: _chk}}) || 0 + let _num = await G.mongodb.collection('equip').countDocuments({ uid: call.uid, lv: { $gte: _chk } }) || 0 return _num } async alchangeVal(call: ApiCall, con, val: number) { let _chk = parseInt(con.cond[0]) - let _num = await G.mongodb.collection('equip').countDocuments({uid: call.uid, lv: {$gte: _chk}}) || 0 + let _num = await G.mongodb.collection('equip').countDocuments({ uid: call.uid, lv: { $gte: _chk } }) || 0 return _num } } @@ -426,7 +429,7 @@ export module manager { isinc = 1 async initVal(call: ApiCall, con) { - let myData = await G.mongodb.cPlayerInfo('meirishilian').findOne({uid: call.uid, type: 'meirishilian'}); + let myData = await G.mongodb.cPlayerInfo('meirishilian').findOne({ uid: call.uid, type: 'meirishilian' }); if (myData.data.refreshTime > PublicShared.getToDayZeroTime()) { return R.compose(R.sum(), R.map(i => i[0].useFightNum), R.values())(myData.data.numInfo) || 0 } @@ -446,7 +449,7 @@ export module manager { isinc = 1 async initVal(call: ApiCall, con) { - let myData = await G.mongodb.cPlayerInfo('qjzzd').findOne({uid: call.uid, type: 'qjzzd'}); + let myData = await G.mongodb.cPlayerInfo('qjzzd').findOne({ uid: call.uid, type: 'qjzzd' }); if (myData?.refreFightTime > PublicShared.getToDayZeroTime()) { return myData?.useFightNum || 0 } @@ -505,7 +508,7 @@ export module manager { isinc = 1 async initVal(call: ApiCall, con) { - let data: Partial = await G.mongodb.collection('wanted').findOne({uid: call.uid}) || {}; + let data: Partial = await G.mongodb.collection('wanted').findOne({ uid: call.uid }) || {}; if (data.refreshTime > PublicShared.getToDayZeroTime()) { return data.toDayUseNum || 0 } @@ -608,12 +611,12 @@ export module manager { async initVal(call: ApiCall, con) { let _chk = parseInt(con.cond[0]) - return await G.mongodb.collection('peijian').countDocuments({uid: call.uid, lv: {$gte: _chk}}) || 0 + return await G.mongodb.collection('peijian').countDocuments({ uid: call.uid, lv: { $gte: _chk } }) || 0 } async alchangeVal(call: ApiCall, con, val: number) { let _chk = parseInt(con.cond[0]) - return await G.mongodb.collection('peijian').countDocuments({uid: call.uid, lv: {$gte: _chk}}) || 0 + return await G.mongodb.collection('peijian').countDocuments({ uid: call.uid, lv: { $gte: _chk } }) || 0 } } @@ -675,11 +678,11 @@ export module manager { isinc = 0 async initVal(call: ApiCall, con) { - return await G.mongodb.collection('equip').countDocuments({uid: call.uid, wearaId: {$ne: ""}}) || 0 + return await G.mongodb.collection('equip').countDocuments({ uid: call.uid, wearaId: { $ne: "" } }) || 0 } async alchangeVal(call: ApiCall, con, val: number) { - return await G.mongodb.collection('equip').countDocuments({uid: call.uid, wearaId: {$ne: ""}}) || 0 + return await G.mongodb.collection('equip').countDocuments({ uid: call.uid, wearaId: { $ne: "" } }) || 0 } }