更新圣诞活动相关代码

This commit is contained in:
yushunrui 2023-12-16 19:05:37 +08:00
parent 5fabfb2c5a
commit 582ac4f7e3
12 changed files with 139 additions and 60 deletions

View File

@ -8,17 +8,24 @@ import {PlayerFun} from "../../../public/player";
export default async function (call: ApiCall<ReqGame, ResGame>) { export default async function (call: ApiCall<ReqGame, ResGame>) {
let initCon = await Christmasfun.getCon(call) let initCon = await Christmasfun.getCon(call)
let need = initCon[call.req.hdid].data.gameneed; 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]; 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) 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 = {} let _setData = {}
_mydata["val"] += addval _mydata["val"] += addval
_setData["val"] = _mydata["val"] _mydata["gamenum"] += 1
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData }) _setData["val"] = _mydata.val
_setData["game"] = _mydata["gamenum"]
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData})
let changedata = { mydata: _mydata} let changedata = { mydata: _mydata}
// 推送红点 // 推送红点
HongDianChange.sendChangeKey(call.uid, ['huodonghd']); HongDianChange.sendChangeKey(call.uid, ['huodonghd']);

View File

@ -22,13 +22,14 @@ export default async function (call: ApiCall<ReqLiBao, ResLiBao>) {
// 判断是否能购买 // 判断是否能购买
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 }) return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 })
} }
const _select = _mydata.select[lbid] || {} let _select = _mydata.select[lbid] || {}
if (Object.keys(_select).length >= _con.dlz.length) { if (Object.keys(_select).length < _con.dlz.length) {
// 判断是否选择奖励了 // 判断是否选择奖励了
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_2 }) 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) { for (let key in _select) {
_prize.push(_con.dlz[parseInt(key)][_select[key]]) _prize.push(_con.dlz[parseInt(key)][_select[key]])
} }

View File

@ -9,6 +9,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
// 无此活动 // 无此活动
return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 }) return call.error('', { code: -1, message: globalThis.lng.huodong_open_1 })
} }
let _mydata = await Christmasfun.getMyData(call, call.req.hdid) let _mydata = await Christmasfun.getMyData(call, call.req.hdid)
let changedata = { mydata: _mydata, hdinfo: _hdinfo } let changedata = { mydata: _mydata, hdinfo: _hdinfo }
call.succ(changedata); call.succ(changedata);

View File

@ -17,7 +17,7 @@ export default async function (call: ApiCall<ReqQianDao, ResQianDao>) {
for(let i = 0; i < _diff; i++) { for(let i = 0; i < _diff; i++) {
if (_mydata.qiandao.includes(i)) continue if (_mydata.qiandao.includes(i)) continue
_mydata.qiandao.push(i) _mydata.qiandao.push(i)
_prize.push(_con[i]) _prize = _prize.concat(_con[i])
} }
if (!_prize){ if (!_prize){

View File

@ -20,12 +20,14 @@ export default async function (call: ApiCall<ReqZhanLingRec, ResZhanLingRec>) {
if (!_mydata.pt.includes(index)){ if (!_mydata.pt.includes(index)){
// 如果普通奖励没有领取 // 如果普通奖励没有领取
_prize.push(_con.pt)
_prize = _prize.concat(_con.pt)
_mydata.pt.push(index) _mydata.pt.push(index)
} }
if (_mydata.pay && !_mydata.gj.includes(index)){ if (_mydata.pay && !_mydata.gj.includes(index)){
// 如果普通奖励没有领取 // 如果普通奖励没有领取
_prize.push(_con.gj) _prize = _prize.concat(_con.gj)
_mydata.gj.push(index) _mydata.gj.push(index)
} }
if (!_prize) { if (!_prize) {

View File

@ -1,11 +1,12 @@
import { strict } from 'assert'; import { strict } from 'assert';
import { ApiCall } from 'tsrpc'; import {ApiCall, BaseConnection} from 'tsrpc';
import { ReqAddHuoDong } from '../../../monopoly/protocols/PtlAddHuoDong'; import { ReqAddHuoDong } from '../../../monopoly/protocols/PtlAddHuoDong';
import { HuoDongFun } from '../../../public/huodongfun'; import { HuoDongFun } from '../../../public/huodongfun';
import { TaskFun } from '../../../public/task'; import { TaskFun } from '../../../public/task';
import { christmas } from '../../../shared/protocols/event/christmas/PtlOpen'; import { christmas } from '../../../shared/protocols/event/christmas/PtlOpen';
import { PublicShared } from '../../../shared/public/public'; import { PublicShared } from '../../../shared/public/public';
import {player} from '../../../shared/protocols/user/type';
import {PlayerFun} from "../../../public/player";
export class Christmasfun { export class Christmasfun {
/**配置 */ /**配置 */
@ -61,6 +62,7 @@ export class Christmasfun {
taskval: await this.getTaskVal(call, hdid), taskval: await this.getTaskVal(call, hdid),
taskfinish: [], taskfinish: [],
refresh: G.time, refresh: G.time,
gamenum: 0,
pt: [], pt: [],
gj: [], gj: [],
pay: false, pay: false,
@ -114,20 +116,49 @@ export class Christmasfun {
return mydata 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) { 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) let hdids = await this.gethdids(call)
if (hdids.length <= 0) return // 活动过期,不计数 if (hdids.length <= 0) return // 活动过期,不计数
let _initCon = await this.getCon(call) let _initCon = await this.getCon(call)
for (let index = 0; index < hdids.length; index++) { for (let index = 0; index < hdids.length; index++) {
const hdid = hdids[index]; const hdid = hdids[index];
let _mydata = await Christmasfun.getMyData(call, hdid) let _mydata = await Christmasfun.getMyData(call, hdid)
let _tasks = _initCon[hdid].data.task let _tasks = _initCon[hdid].data.task
let _setData = { let _setData= {
$inc: {}, $inc: {},
$set: {} $set: {}
} }
@ -165,4 +196,4 @@ export class Christmasfun {
} }

View File

@ -16,6 +16,7 @@ import { player } from './shared/protocols/user/type';
import { PublicShared } from './shared/public/public'; import { PublicShared } from './shared/public/public';
import { setGud } from './public/gud'; import { setGud } from './public/gud';
import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen"; import {checkResetBuyLog} from "./api_s2c/event/zhoumolibao/ApiOpen";
import {Christmasfun} from "./api_s2c/event/christmas/fun";
export type gEventType = { export type gEventType = {
/**玩家断开连接 */ /**玩家断开连接 */
@ -23,7 +24,7 @@ export type gEventType = {
/**玩家修改名字 */ /**玩家修改名字 */
PLAYER_CHANGE_NAME: (gud: player, name: string) => void; 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调用 */
API_CALL: (node: { call: ApiCall, return: ApiReturn<any>; }) => void; API_CALL: (node: { call: ApiCall, return: ApiReturn<any>; }) => 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); let conf: any = await PayFun.getConf(payId, payArgs);
ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n }); ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
ActionLog.addRetainLog(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); if (payId == G.gc.zhanling.payId) payZhanLing(player);
//圣诞节活动充值
Christmasfun.payChristmas(payId, call);
let payEmailConf = G.gc.payEmail[payId] as _gcType['payEmail']['caifutequan']; let payEmailConf = G.gc.payEmail[payId] as _gcType['payEmail']['caifutequan'];
if (payEmailConf?.length > 0) { if (payEmailConf?.length > 0) {
let sendEmailConfs = payEmailConf; let sendEmailConfs = payEmailConf;
@ -202,18 +204,17 @@ export function addListener() {
ActionLog.addRetainLog(gud.uid, { key: 'login_day', val: 1 }); ActionLog.addRetainLog(gud.uid, { key: 'login_day', val: 1 });
ZhanLingTasks.clearLog(gud.uid, 'day'); ZhanLingTasks.clearLog(gud.uid, 'day');
PayFun.checkGiftDayEmail(gud, lastTime, curTime); PayFun.checkGiftDayEmail(gud, lastTime, curTime);
reissuePrize(gud, lastTime, curTime); reissuePrize(gud, lastTime, curTime);
addDay(gud); addDay(gud);
// 任务累计登录天数 // 任务累计登录天数
let call = PayFun.getCall(gud); let call = PayFun.getCall(gud);
G.emit("Class_task_135", 'Class_task_135', call, 1, 0); G.emit("Class_task_135", 'Class_task_135', call, 1, 0);
// 七日登录活动计数 // 七日登录活动计数
qiRiDengLuAddDay(call); qiRiDengLuAddDay(call);
// 周末礼包检测刷新 // 周末礼包检测刷新
checkResetBuyLog(call) checkResetBuyLog(call);
}); });
G.on('API_CALL', node => { G.on('API_CALL', node => {

View File

@ -5,7 +5,7 @@ export default {
/**是否开发模式 */ /**是否开发模式 */
debug: true, debug: true,
/**消息服socket端口*/ /**消息服socket端口*/
msgPort: 7778, msgPort: 7785,
/**http端口 msg服专用*/ /**http端口 msg服专用*/
// httpPort: 7779, // httpPort: 7779,
/**跨服socket端口 */ /**跨服socket端口 */
@ -13,7 +13,7 @@ export default {
/**跨服 ws url */ /**跨服 ws url */
corssWsUrl: "ws://10.0.1.20:10003", corssWsUrl: "ws://10.0.1.20:10003",
/**服务器id */ /**服务器id */
serverId: 0, serverId: 1001,
/**redis url */ /**redis url */
redisUrl: 'redis://:lyMaple525458@10.0.1.20:6379/0', redisUrl: 'redis://:lyMaple525458@10.0.1.20:6379/0',
/**mongodb url */ /**mongodb url */
@ -27,7 +27,7 @@ export default {
/**服务器时间 */ /**服务器时间 */
time: '', time: '',
/**开服时间 */ /**开服时间 */
openTime: '2022-10-10 1:0:0', openTime: '2023-12-11 1:0:0',
/**项目名称 */ /**项目名称 */
projectName: 'heijiao', projectName: 'heijiao',
/**加密key */ /**加密key */

View File

@ -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); G.emit("Class_task_116", 'Class_task_116', call, 1, 0);
} }

View File

@ -23,6 +23,8 @@ export type christmas = {
taskval: { [id: string]: number } taskval: { [id: string]: number }
/**任务领取标识 */ /**任务领取标识 */
taskfinish: string[] taskfinish: string[]
/**小游戏挑战次数 */
gamenum: number
/**普通战令奖励集合 奖励id */ /**普通战令奖励集合 奖励id */
pt: number[] pt: number[]
/**高级战令奖励集合 奖励id */ /**高级战令奖励集合 奖励id */
@ -36,7 +38,7 @@ export type christmas = {
/**装扮值 */ /**装扮值 */
val: number val: number
/**签到标识 */ /**签到标识 */
qiandao:string[], qiandao:number[],
/**刷新时间 */ /**刷新时间 */
refresh: number refresh: number
} }

View File

@ -2,11 +2,11 @@
"hdid" : 91029302193, "hdid" : 91029302193,
"htype" : 8, "htype" : 8,
"stype" : 800, "stype" : 800,
"ttype" : 1, "ttype" : 0,
"stime" : 60, "stime" : 1702396800,
"rtime" : 90, "rtime" : 1703088000,
"etime" : 90, "etime" : 1703088000,
"name" : "xinfupeiyang", "name" : "christmas",
"icon" : "icon_xfdj", "icon" : "icon_xfdj",
"showtime" : "根据玩家注册时间,游戏返回时复写", "showtime" : "根据玩家注册时间,游戏返回时复写",
"data" : { "data" : {
@ -52,24 +52,51 @@
} }
}, },
"gameneed": [{"a": "attr", "t":"jinbi", "n": 1}], "gameneed": [{"a": "attr", "t":"jinbi", "n": 1}],
"game": [0,1,2,3,4,5], "game": [0,1, 2, 3, 4, 5],
"zhanling":[ "gamefree": 3,
{ "zhanling":[{
"val": 1, "val": 1,
"pt": [{"a": "attr", "t":"jinbi", "n": 1}], "pt": [{"a": "attr", "t":"jinbi", "n": 1}],
"gj": [{"a": "attr", "t":"jinbi", "n": 1}] "gj": [{"a": "attr", "t":"jinbi", "n": 1},{"a": "attr", "t":"jinbi", "n": 1}]
}, },
{ {
"val": 2, "val": 2,
"pt": [{"a": "attr", "t":"jinbi", "n": 1}], "pt": [{"a": "attr", "t":"rmbmoney", "n": 100}],
"gj": [{"a": "attr", "t":"jinbi", "n": 1}] "gj": [{"a": "attr", "t":"rmbmoney", "n": 100},{"a": "attr", "t":"jinbi", "n": 1}]
}, },
{ {
"val": 3, "val": 3,
"pt": [{"a": "attr", "t":"jinbi", "n": 1}], "pt": [{"a": "attr", "t":"jinbi", "n": 1}],
"gj": [{"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", "zlpayid":"ycmb_1_1",
"libao": { "libao": {
"1": { "1": {

View File

@ -8642,6 +8642,13 @@ export const serviceProto: ServiceProto<ServiceType> = {
}, },
{ {
"id": 5, "id": 5,
"name": "gamenum",
"type": {
"type": "Number"
}
},
{
"id": 6,
"name": "pt", "name": "pt",
"type": { "type": {
"type": "Array", "type": "Array",
@ -8651,7 +8658,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 6, "id": 7,
"name": "gj", "name": "gj",
"type": { "type": {
"type": "Array", "type": "Array",
@ -8661,14 +8668,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 7, "id": 8,
"name": "pay", "name": "pay",
"type": { "type": {
"type": "Boolean" "type": "Boolean"
} }
}, },
{ {
"id": 8, "id": 9,
"name": "libao", "name": "libao",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -8681,7 +8688,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 9, "id": 10,
"name": "select", "name": "select",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -8700,24 +8707,24 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 10, "id": 11,
"name": "val", "name": "val",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 11, "id": 12,
"name": "qiandao", "name": "qiandao",
"type": { "type": {
"type": "Array", "type": "Array",
"elementType": { "elementType": {
"type": "String" "type": "Number"
} }
} }
}, },
{ {
"id": 12, "id": 13,
"name": "refresh", "name": "refresh",
"type": { "type": {
"type": "Number" "type": "Number"