From 582ac4f7e3aeb59dcc8fad86eb99868b07ab5baf Mon Sep 17 00:00:00 2001 From: yushunrui <364203175@qq.com> Date: Sat, 16 Dec 2023 19:05:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=9C=A3=E8=AF=9E=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/christmas/ApiGame.ts | 19 +++-- src/api_s2c/event/christmas/ApiLiBao.ts | 7 +- src/api_s2c/event/christmas/ApiOpen.ts | 1 + src/api_s2c/event/christmas/ApiQianDao.ts | 2 +- src/api_s2c/event/christmas/ApiZhanLingRec.ts | 6 +- src/api_s2c/event/christmas/fun.ts | 43 +++++++++-- src/globalListener.ts | 13 ++-- src/localConfig.ts | 6 +- src/public/pay.ts | 2 +- .../protocols/event/christmas/PtlOpen.ts | 4 +- .../protocols/event/christmas/huodong.json | 73 +++++++++++++------ src/shared/protocols/serviceProto.ts | 23 ++++-- 12 files changed, 139 insertions(+), 60 deletions(-) diff --git a/src/api_s2c/event/christmas/ApiGame.ts b/src/api_s2c/event/christmas/ApiGame.ts index e3cd097..25486ab 100644 --- a/src/api_s2c/event/christmas/ApiGame.ts +++ b/src/api_s2c/event/christmas/ApiGame.ts @@ -8,17 +8,24 @@ import {PlayerFun} from "../../../public/player"; export default async function (call: ApiCall) { let initCon = await Christmasfun.getCon(call) let need = initCon[call.req.hdid].data.gameneed; + let freenum = initCon[call.req.hdid].data.gamefree let addval = initCon[call.req.hdid].data.game[call.req.index]; - // 判断消耗是否满足 - await PlayerFun.checkNeedIsMeet(call, need); - // 扣除消耗 - await PlayerFun.cutNeed(call, need); let _mydata = await Christmasfun.getMyData(call, call.req.hdid) + // 判断是否有免费配置 + if (_mydata.gamenum >= freenum) { + // 判断消耗是否满足 + await PlayerFun.checkNeedIsMeet(call, need); + // 扣除消耗 + await PlayerFun.cutNeed(call, need); + } + let _setData = {} _mydata["val"] += addval - _setData["val"] = _mydata["val"] - await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData }) + _mydata["gamenum"] += 1 + _setData["val"] = _mydata.val + _setData["game"] = _mydata["gamenum"] + await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData}) let changedata = { mydata: _mydata} // 推送红点 HongDianChange.sendChangeKey(call.uid, ['huodonghd']); diff --git a/src/api_s2c/event/christmas/ApiLiBao.ts b/src/api_s2c/event/christmas/ApiLiBao.ts index 0c5163c..ad070db 100644 --- a/src/api_s2c/event/christmas/ApiLiBao.ts +++ b/src/api_s2c/event/christmas/ApiLiBao.ts @@ -22,13 +22,14 @@ export default async function (call: ApiCall) { // 判断是否能购买 return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 }) } - const _select = _mydata.select[lbid] || {} - if (Object.keys(_select).length >= _con.dlz.length) { + let _select = _mydata.select[lbid] || {} + if (Object.keys(_select).length < _con.dlz.length) { // 判断是否选择奖励了 return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 }) } - let _prize: atn[] = _con.prize + let _prize: atn[] = _con.basep + for (let key in _select) { _prize.push(_con.dlz[parseInt(key)][_select[key]]) } diff --git a/src/api_s2c/event/christmas/ApiOpen.ts b/src/api_s2c/event/christmas/ApiOpen.ts index 9fb038b..7473002 100644 --- a/src/api_s2c/event/christmas/ApiOpen.ts +++ b/src/api_s2c/event/christmas/ApiOpen.ts @@ -9,6 +9,7 @@ export default async function (call: ApiCall) { // 无此活动 return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 }) } + let _mydata = await Christmasfun.getMyData(call, call.req.hdid) let changedata = { mydata: _mydata, hdinfo: _hdinfo } call.succ(changedata); diff --git a/src/api_s2c/event/christmas/ApiQianDao.ts b/src/api_s2c/event/christmas/ApiQianDao.ts index 41f5742..5eb2830 100644 --- a/src/api_s2c/event/christmas/ApiQianDao.ts +++ b/src/api_s2c/event/christmas/ApiQianDao.ts @@ -17,7 +17,7 @@ export default async function (call: ApiCall) { for(let i = 0; i < _diff; i++) { if (_mydata.qiandao.includes(i)) continue _mydata.qiandao.push(i) - _prize.push(_con[i]) + _prize = _prize.concat(_con[i]) } if (!_prize){ diff --git a/src/api_s2c/event/christmas/ApiZhanLingRec.ts b/src/api_s2c/event/christmas/ApiZhanLingRec.ts index 66bc07f..42a460f 100644 --- a/src/api_s2c/event/christmas/ApiZhanLingRec.ts +++ b/src/api_s2c/event/christmas/ApiZhanLingRec.ts @@ -20,12 +20,14 @@ export default async function (call: ApiCall) { if (!_mydata.pt.includes(index)){ // 如果普通奖励没有领取 - _prize.push(_con.pt) + + _prize = _prize.concat(_con.pt) _mydata.pt.push(index) } if (_mydata.pay && !_mydata.gj.includes(index)){ // 如果普通奖励没有领取 - _prize.push(_con.gj) + _prize = _prize.concat(_con.gj) + _mydata.gj.push(index) } if (!_prize) { diff --git a/src/api_s2c/event/christmas/fun.ts b/src/api_s2c/event/christmas/fun.ts index 6d37072..c516ca2 100644 --- a/src/api_s2c/event/christmas/fun.ts +++ b/src/api_s2c/event/christmas/fun.ts @@ -1,11 +1,12 @@ import { strict } from 'assert'; -import { ApiCall } from 'tsrpc'; +import {ApiCall, BaseConnection} from 'tsrpc'; import { ReqAddHuoDong } from '../../../monopoly/protocols/PtlAddHuoDong'; import { HuoDongFun } from '../../../public/huodongfun'; import { TaskFun } from '../../../public/task'; import { christmas } from '../../../shared/protocols/event/christmas/PtlOpen'; import { PublicShared } from '../../../shared/public/public'; - +import {player} from '../../../shared/protocols/user/type'; +import {PlayerFun} from "../../../public/player"; export class Christmasfun { /**配置 */ @@ -61,6 +62,7 @@ export class Christmasfun { taskval: await this.getTaskVal(call, hdid), taskfinish: [], refresh: G.time, + gamenum: 0, pt: [], gj: [], pay: false, @@ -114,20 +116,49 @@ export class Christmasfun { return mydata } + static async payChristmas(payid, call: ApiCall) { + let _hd = await HuoDongFun.gethdList(call, 8) + for (let index = 0; index < _hd.length; index++) { + const hdinfo = _hd[index]; + const _hdid = hdinfo.hdid + if (payid == hdinfo.data.zlpayid){ + let _mydata = await Christmasfun.getMyData(call, _hdid) + if (_mydata.pay) continue + await this.setMyData(call.uid, _hdid, { $set: { pay: true} }) + let _prize = hdinfo.data.zlpayprize + await PlayerFun.sendPrize(call, _prize); + } + else{ + const libaos = hdinfo.data.libao + for (let index = 0; index < Object.keys(libaos).length; index++){ + const lbid = Object.keys(libaos)[index]; + let _tmp = libaos[lbid] + if (_tmp['payid'] != payid) continue + let _mydata = await Christmasfun.getMyData(call, _hdid) + let _buyNum = _mydata.libao[lbid] || 0 + if (_buyNum >= _tmp["buynum"]) continue + _mydata.libao[lbid] = _buyNum + 1 + this.setMyData(call.uid, _hdid, { $set: { libao: _mydata.libao} }) + break + + } + } + } + } + + /**设置任务 */ static async setTaskVal(call: ApiCall, stype: number, val: number, chkCall: Function, chkval: number = 0, isinc: number = 0, alchangeVal: Function, arg) { let hdids = await this.gethdids(call) if (hdids.length <= 0) return // 活动过期,不计数 let _initCon = await this.getCon(call) - - for (let index = 0; index < hdids.length; index++) { const hdid = hdids[index]; let _mydata = await Christmasfun.getMyData(call, hdid) let _tasks = _initCon[hdid].data.task - let _setData = { + let _setData= { $inc: {}, $set: {} } @@ -165,4 +196,4 @@ export class Christmasfun { -} \ No newline at end of file +} diff --git a/src/globalListener.ts b/src/globalListener.ts index 1db7530..9300f46 100644 --- a/src/globalListener.ts +++ b/src/globalListener.ts @@ -16,6 +16,7 @@ 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"; export type gEventType = { /**玩家断开连接 */ @@ -23,7 +24,7 @@ export type gEventType = { /**玩家修改名字 */ PLAYER_CHANGE_NAME: (gud: player, name: string) => void; /**玩家充值 */ - PLAYER_PAY: (gud: player, payId: string, type: 'user' | 'system') => void; + PLAYER_PAY: (gud: player, payId: string, type: 'user' | 'system', call) => void; /**玩家发生api调用 */ API_CALL: (node: { call: ApiCall, return: ApiReturn; }) => void; /**玩家每日首次登陆 */ @@ -166,13 +167,14 @@ export function addListener() { } }); - G.on('PLAYER_PAY', async (player, payId, payArgs) => { + 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 }); if (payId == G.gc.zhanling.payId) payZhanLing(player); - + //圣诞节活动充值 + Christmasfun.payChristmas(payId, call); let payEmailConf = G.gc.payEmail[payId] as _gcType['payEmail']['caifutequan']; if (payEmailConf?.length > 0) { let sendEmailConfs = payEmailConf; @@ -202,18 +204,17 @@ export function addListener() { ActionLog.addRetainLog(gud.uid, { key: 'login_day', val: 1 }); ZhanLingTasks.clearLog(gud.uid, 'day'); PayFun.checkGiftDayEmail(gud, lastTime, curTime); - reissuePrize(gud, lastTime, curTime); addDay(gud); // 任务累计登录天数 let call = PayFun.getCall(gud); - G.emit("Class_task_135", 'Class_task_135', call, 1, 0); // 七日登录活动计数 qiRiDengLuAddDay(call); // 周末礼包检测刷新 - checkResetBuyLog(call) + checkResetBuyLog(call); + }); G.on('API_CALL', node => { diff --git a/src/localConfig.ts b/src/localConfig.ts index 5a384b7..cfb411f 100644 --- a/src/localConfig.ts +++ b/src/localConfig.ts @@ -5,7 +5,7 @@ export default { /**是否开发模式 */ debug: true, /**消息服socket端口*/ - msgPort: 7778, + msgPort: 7785, /**http端口 msg服专用*/ // httpPort: 7779, /**跨服socket端口 */ @@ -13,7 +13,7 @@ export default { /**跨服 ws url */ corssWsUrl: "ws://10.0.1.20:10003", /**服务器id */ - serverId: 0, + serverId: 1001, /**redis url */ redisUrl: 'redis://:lyMaple525458@10.0.1.20:6379/0', /**mongodb url */ @@ -27,7 +27,7 @@ export default { /**服务器时间 */ time: '', /**开服时间 */ - openTime: '2022-10-10 1:0:0', + openTime: '2023-12-11 1:0:0', /**项目名称 */ projectName: 'heijiao', /**加密key */ diff --git a/src/public/pay.ts b/src/public/pay.ts index 8c48aa5..665a3cd 100644 --- a/src/public/pay.ts +++ b/src/public/pay.ts @@ -271,7 +271,7 @@ export class PayFun { } }); - G.emit('PLAYER_PAY', player, payId, payArgs); + G.emit('PLAYER_PAY', player, payId, payArgs, call); G.emit("Class_task_116", 'Class_task_116', call, 1, 0); } diff --git a/src/shared/protocols/event/christmas/PtlOpen.ts b/src/shared/protocols/event/christmas/PtlOpen.ts index f0129c6..1dc8168 100644 --- a/src/shared/protocols/event/christmas/PtlOpen.ts +++ b/src/shared/protocols/event/christmas/PtlOpen.ts @@ -23,6 +23,8 @@ export type christmas = { taskval: { [id: string]: number } /**任务领取标识 */ taskfinish: string[] + /**小游戏挑战次数 */ + gamenum: number /**普通战令奖励集合 奖励id */ pt: number[] /**高级战令奖励集合 奖励id */ @@ -36,7 +38,7 @@ export type christmas = { /**装扮值 */ val: number /**签到标识 */ - qiandao:string[], + qiandao:number[], /**刷新时间 */ refresh: number } \ No newline at end of file diff --git a/src/shared/protocols/event/christmas/huodong.json b/src/shared/protocols/event/christmas/huodong.json index 2f9d42e..cea9f66 100644 --- a/src/shared/protocols/event/christmas/huodong.json +++ b/src/shared/protocols/event/christmas/huodong.json @@ -2,11 +2,11 @@ "hdid" : 91029302193, "htype" : 8, "stype" : 800, - "ttype" : 1, - "stime" : 60, - "rtime" : 90, - "etime" : 90, - "name" : "xinfupeiyang", + "ttype" : 0, + "stime" : 1702396800, + "rtime" : 1703088000, + "etime" : 1703088000, + "name" : "christmas", "icon" : "icon_xfdj", "showtime" : "根据玩家注册时间,游戏返回时复写", "data" : { @@ -52,24 +52,51 @@ } }, "gameneed": [{"a": "attr", "t":"jinbi", "n": 1}], - "game": [0,1,2,3,4,5], - "zhanling":[ - { - "val": 1, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1}] - }, - { - "val": 2, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1}] - }, - { - "val": 3, - "pt": [{"a": "attr", "t":"jinbi", "n": 1}], - "gj": [{"a": "attr", "t":"jinbi", "n": 1}] - } - ], + "game": [0,1, 2, 3, 4, 5], + "gamefree": 3, + "zhanling":[{ + "val": 1, + "pt": [{"a": "attr", "t":"jinbi", "n": 1}], + "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] + }, + { + "val": 2, + "pt": [{"a": "attr", "t":"rmbmoney", "n": 100}], + "gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}] + }, + { + "val": 3, + "pt": [{"a": "attr", "t":"jinbi", "n": 1}], + "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] + },{ + "val": 4, + "pt": [{"a": "attr", "t":"jinbi", "n": 1}], + "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] + }, + { + "val": 5, + "pt": [{"a": "attr", "t":"rmbmoney", "n": 100}], + "gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}] + }, + { + "val": 6, + "pt": [{"a": "attr", "t":"jinbi", "n": 1}], + "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] + },{ + "val": 7, + "pt": [{"a": "attr", "t":"jinbi", "n": 1}], + "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] + }, + { + "val": 8, + "pt": [{"a": "attr", "t":"rmbmoney", "n": 100}], + "gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}] + }, + { + "val": 9, + "pt": [{"a": "attr", "t":"jinbi", "n": 1}], + "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}] + }], "zlpayid":"ycmb_1_1", "libao": { "1": { diff --git a/src/shared/protocols/serviceProto.ts b/src/shared/protocols/serviceProto.ts index c984c1b..a0a7e9f 100644 --- a/src/shared/protocols/serviceProto.ts +++ b/src/shared/protocols/serviceProto.ts @@ -8642,6 +8642,13 @@ export const serviceProto: ServiceProto = { }, { "id": 5, + "name": "gamenum", + "type": { + "type": "Number" + } + }, + { + "id": 6, "name": "pt", "type": { "type": "Array", @@ -8651,7 +8658,7 @@ export const serviceProto: ServiceProto = { } }, { - "id": 6, + "id": 7, "name": "gj", "type": { "type": "Array", @@ -8661,14 +8668,14 @@ export const serviceProto: ServiceProto = { } }, { - "id": 7, + "id": 8, "name": "pay", "type": { "type": "Boolean" } }, { - "id": 8, + "id": 9, "name": "libao", "type": { "type": "Interface", @@ -8681,7 +8688,7 @@ export const serviceProto: ServiceProto = { } }, { - "id": 9, + "id": 10, "name": "select", "type": { "type": "Interface", @@ -8700,24 +8707,24 @@ export const serviceProto: ServiceProto = { } }, { - "id": 10, + "id": 11, "name": "val", "type": { "type": "Number" } }, { - "id": 11, + "id": 12, "name": "qiandao", "type": { "type": "Array", "elementType": { - "type": "String" + "type": "Number" } } }, { - "id": 12, + "id": 13, "name": "refresh", "type": { "type": "Number"