feat:黄旗酒馆

This commit is contained in:
xichaoyin 2024-01-10 20:50:03 +08:00
parent d30f62f6c5
commit 206e87d64c
7 changed files with 608 additions and 333 deletions

View File

@ -0,0 +1,42 @@
import { ApiCall } from "tsrpc";
import { ReqGiftRec, ResGiftRec } from "../../../shared/protocols/event/huangqijiuguan/PtlGiftRec";
import HQJGFun from "./fun";
export default async function (call: ApiCall<ReqGiftRec, ResGiftRec>) {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd || Object.keys(hd).length <= 0) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let gift = hd.data.gift.filter(i => i.id == call.req.giftid)[0];
if (!gift || !gift.free) {
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
if ((mydata.giftbuy[call.req.giftid] || { num: 0 }).num + 1 > gift.buynum) {
return call.error("", { code: -2, message: globalThis.lng.hqjgtips_28 })
}
let prize: atn[] = [].concat(gift.prize);
if (!mydata.giftbuy[call.req.giftid]) {
mydata.giftbuy[call.req.giftid] = { num: 0, select: [] };
}
if (gift.dlz) {
for (let i = 0; i < gift.dlz.length; i++) {
if (!mydata.giftbuy[call.req.giftid].select[i]) {
let ids = Object.keys(gift.dlz[i])
prize.push(gift.dlz[i][ids[0]]);
mydata.giftbuy[call.req.giftid].select[i] = Number(ids[0]);
} else {
prize.push(gift.dlz[i][mydata.giftbuy.select[i]]);
}
}
}
mydata.giftbuy[call.req.giftid].num++;
await HQJGFun.setMyData(call.uid, call.req.hdid, { giftbuy: mydata.giftbuy });
call.succ({ data: mydata, prize: prize })
}

View File

@ -0,0 +1,35 @@
import { ApiCall } from "tsrpc";
import { ReqGiftSelect, ResGiftSelect } from "../../../shared/protocols/event/huangqijiuguan/PtlGiftSelect";
import HQJGFun from "./fun";
export default async function (call: ApiCall<ReqGiftSelect, ResGiftSelect>) {
let hd = await HQJGFun.HdInfo(call, call.req.hdid);
if (!hd || Object.keys(hd).length <= 0) {
// 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
let gift = hd.data.gift[call.req.giftid];
if (!gift || !gift.dlz) {
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
for (let i = 0; i < call.req.seletc.length; i++) {
if (!gift.dlz[i] || !gift.dlz[i][call.req.seletc[i]]) {
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
}
}
let mydata = await HQJGFun.getMydata(call, call.req.hdid);
if (!mydata.giftbuy[call.req.giftid]) {
mydata.giftbuy[call.req.giftid] = {
num: 0, select: call.req.seletc
}
} else {
mydata.giftbuy[call.req.giftid].select = call.req.seletc;
}
await HQJGFun.setMyData(call.uid, call.req.hdid, { giftbuy: mydata.giftbuy });
call.succ({ data: mydata });
}

View File

@ -3,6 +3,7 @@ import { ReqAddHuoDong } from "../../../monopoly/protocols/PtlAddHuoDong"
import { HuoDongFun } from "../../../public/huodongfun" import { HuoDongFun } from "../../../public/huodongfun"
import { PublicShared } from "../../../shared/public/public" import { PublicShared } from "../../../shared/public/public"
import { EmailFun } from "../../../public/email" import { EmailFun } from "../../../public/email"
import { playerInfo } from "../../../shared/protocols/user/PtlLogin"
// hddata.data // hddata.data
export interface Data { export interface Data {
@ -33,7 +34,7 @@ export interface Data {
baodi: { num: number, prize: any[] }[] baodi: { num: number, prize: any[] }[]
gift: { id: number, free: boolean, payId: string, buynum: number, prize: atn[] }[] gift: { id: number, free: boolean, payId: string, buynum: number, prize: atn[], dlz?: { [k: string]: atn }[] }[]
duihuan: { id: number, need: atn[], prize: atn[], buyNum: number }[] duihuan: { id: number, need: atn[], prize: atn[], buyNum: number }[]
@ -203,17 +204,6 @@ export default class HQJGFun {
} }
} }
static async buy(call: ApiCall, payId: string) {
let hddata = await this.HdInfo(call);
if (!hddata) { // 活动不存在
return
}
let mydata = await this.getMydata(call);
await this.setMyData(call.uid, (await this.HdInfo(call)).hdid, mydata);
}
/** /**
* *
*/ */
@ -347,7 +337,8 @@ export default class HQJGFun {
$set: {} $set: {}
}; };
let tasks = hd.data.task[`day${today}`]; let tasks = hd.data.task[`day${today}`];
for (let taskCon of Object.values(tasks)) { for (let taskid of Object.keys(tasks)) {
let taskCon = tasks[taskid];
if (taskCon.stype != stype) continue if (taskCon.stype != stype) continue
// 不符合任务要求 // 不符合任务要求
@ -358,9 +349,9 @@ export default class HQJGFun {
isset = 1 isset = 1
if (isinc == 1) { // 累加 if (isinc == 1) { // 累加
setData["$inc"][`task.val.day${today}`] = val setData["$inc"][`task.val.day${today}.${taskid}`] = val
} else { } else {
setData["$set"][`task.val.day${today}`] = val setData["$set"][`task.val.day${today}.${taskid}`] = val
} }
} }
@ -369,7 +360,43 @@ export default class HQJGFun {
await G.mongodb.collection('event').updateOne({ uid: call.uid, type: this.dataType(hd.hdid) }, setData) await G.mongodb.collection('event').updateOne({ uid: call.uid, type: this.dataType(hd.hdid) }, setData)
} }
} }
}
// G.on("NEW_DAY", HQJGFun.dayDpsLvPrize.bind(HQJGFun)); static async buy(player: playerInfo, payId: string, payArgs: any, call: ApiCall) {
// G.on("NEW_DAY", HQJGFun.endDpsRankPrize.bind(HQJGFun)); let hd = await this.HdInfo(call);
if (!hd) { // 活动不存在
return
}
// 判断购买次数
let gift = hd.data.gift.filter(x => x.payId == payId)[0];
if (!gift) {
return
}
let mydata = await this.getMydata(call);
if (!mydata.giftbuy[gift.id]) {
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 })
} else {
prize = gift.prize;
for (let i = 0; i < gift.dlz.length; i++) {
if (!mydata.giftbuy[call.req.giftid].select[i]) {
let ids = Object.keys(gift.dlz[i])
prize.push(gift.dlz[i][ids[0]]);
mydata.giftbuy[call.req.giftid].select[i] = Number(ids[0]);
} else {
prize.push(gift.dlz[i][mydata.giftbuy.select[i]]);
}
}
}
mydata.giftbuy[gift.id].num++;
await this.setMyData(call.uid, hd.hdid, { giftbuy: mydata.giftbuy });
}
}

View File

@ -19,6 +19,7 @@ import { checkResetBuyLog } from "./api_s2c/event/zhoumolibao/ApiOpen";
import { PushGiftFun } from "./public/pushgift"; import { PushGiftFun } from "./public/pushgift";
import { LeiChongLiBaoBuyGift } from "./api_s2c/event/leichonglibao/ApiReceive"; import { LeiChongLiBaoBuyGift } from "./api_s2c/event/leichonglibao/ApiReceive";
import { HongDianChange } from './api_s2c/hongdian/fun'; import { HongDianChange } from './api_s2c/hongdian/fun';
import HQJGFun from './api_s2c/event/huangqijiuguan/fun';
export type gEventType = { export type gEventType = {
/**新的一天 */ /**新的一天 */
@ -261,4 +262,9 @@ export function addListener() {
let call = PayFun.getCall(gud); let call = PayFun.getCall(gud);
G.emit("Class_task_134", 'Class_task_134', call, 1, 0, items); G.emit("Class_task_134", 'Class_task_134', call, 1, 0, items);
}); });
// 黄旗酒馆
G.on("NEW_DAY", HQJGFun.dayDpsLvPrize.bind(HQJGFun));
G.on("NEW_DAY", HQJGFun.endDpsRankPrize.bind(HQJGFun));
G.on("PLAYER_PAY", HQJGFun.buy.bind(HQJGFun));
} }

View File

@ -0,0 +1,11 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun"
export interface ReqGiftRec {
hdid: number
giftid: number
}
export interface ResGiftRec {
data: PlayerData
prize: { a: string, t: string, n: number }[]
}

View File

@ -0,0 +1,11 @@
import { PlayerData } from "../../../../api_s2c/event/huangqijiuguan/fun"
export interface ReqGiftSelect {
hdid: number
giftid: number
seletc: number[]
}
export interface ResGiftSelect {
data: PlayerData
}

File diff suppressed because it is too large Load Diff