Compare commits

...

12 Commits

24 changed files with 392 additions and 132 deletions

12
oneKeyStartPm2.sh Normal file
View File

@ -0,0 +1,12 @@
git fetch --all && git reset --hard origin/dev && git pull
npm run build_linux
cp src/config.json dist/
pm2 del heijiao_msg_s0
cd dist && pm2 start js_pm2.config.js
pm2 save

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,
@ -110,24 +112,54 @@ export class Christmasfun {
mydata.taskfinish = [] mydata.taskfinish = []
mydata.taskval = await this.getTaskVal(call, hdid) mydata.taskval = await this.getTaskVal(call, hdid)
mydata.refresh = G.time mydata.refresh = G.time
await this.setMyData(call.uid, hdid, { $set: { refresh: mydata.refresh, taskfinish: mydata.taskfinish, taskval: mydata.taskval } }) mydata.gamenum = 0
await this.setMyData(call.uid, hdid, { $set: { refresh: mydata.refresh, taskfinish: mydata.taskfinish, taskval: mydata.taskval, gamenum: mydata.gamenum} })
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 +197,4 @@ export class Christmasfun {
} }

View File

@ -2,6 +2,7 @@ import {ApiCall} from "tsrpc";
import {ReqReceive, ResReceive} from "../../../shared/protocols/event/zhoumolibao/PtlReceive"; import {ReqReceive, ResReceive} from "../../../shared/protocols/event/zhoumolibao/PtlReceive";
import {HuoDongFun} from "../../../public/huodongfun"; import {HuoDongFun} from "../../../public/huodongfun";
import {PlayerFun} from "../../../public/player"; import {PlayerFun} from "../../../public/player";
import {HongDianChange} from "../../hongdian/fun";
export default async function (call: ApiCall<ReqReceive, ResReceive>) { export default async function (call: ApiCall<ReqReceive, ResReceive>) {
// 查询活动是否有当前领奖的免费选项 // 查询活动是否有当前领奖的免费选项
@ -18,7 +19,9 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
await G.mongodb.cEvent('zhoumolibao').updateOne({uid: call.uid, type: 'zhoumolibao'}, { await G.mongodb.cEvent('zhoumolibao').updateOne({uid: call.uid, type: 'zhoumolibao'}, {
$inc: {[`record.${gift.id}`]: 1}, $inc: {[`record.${gift.id}`]: 1},
},{ upsert: true }) }, {upsert: true})
call.succ({}) call.succ({})
HongDianChange.sendChangeKey(call.uid, ['zhoumolibao']);
} }

View File

@ -1,25 +1,25 @@
import { ApiCall } from "tsrpc"; import {ApiCall} from "tsrpc";
import { DiXiaQianZhuangFun } from "../../public/dixiaqianzhuang"; import {DiXiaQianZhuangFun} from "../../public/dixiaqianzhuang";
import { DxltFun } from "../../public/dxlt"; import {DxltFun} from "../../public/dxlt";
import { GongHuiFun } from "../../public/gonghui/gonghui"; import {GongHuiFun} from "../../public/gonghui/gonghui";
import { JJCFun } from "../../public/jjc"; import {JJCFun} from "../../public/jjc";
import { KuangDongfun } from "../../public/kuangdong"; import {KuangDongfun} from "../../public/kuangdong";
import { LingZhuLaiXifun } from "../../public/lingzhulaixi"; import {LingZhuLaiXifun} from "../../public/lingzhulaixi";
import { SignFun } from "../../public/sign"; import {SignFun} from "../../public/sign";
import { TaskFun } from "../../public/task"; import {TaskFun} from "../../public/task";
import { WangZheRongYaofun } from "../../public/wzry"; import {WangZheRongYaofun} from "../../public/wzry";
import { XstaskFun } from "../../public/xstask"; import {XstaskFun} from "../../public/xstask";
import { ReqGet, ResGet, hongdianKey } from "../../shared/protocols/hongdian/PtlGet"; import {ReqGet, ResGet, hongdianKey} from "../../shared/protocols/hongdian/PtlGet";
import { PublicShared } from '../../shared/public/public'; import {PublicShared} from '../../shared/public/public';
import { getShouChongRedPoint } from '../event/shouchong/ApiReceive'; import {getShouChongRedPoint} from '../event/shouchong/ApiReceive';
import { md_redPoint } from '../gongyu/mingdao/ApiOpen'; import {md_redPoint} from '../gongyu/mingdao/ApiOpen';
import { HongDianFun, HuoDongHongDianFun } from "./fun"; import {HongDianFun, HuoDongHongDianFun} from "./fun";
import { FunWeiXiuChang } from "../../public/weixiuchang"; import {FunWeiXiuChang} from "../../public/weixiuchang";
const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd', const defaultKeys: hongdianKey[] = ['jiuba', 'jiaotang', 'shouchong', 'clslhd', 'dixiaqianzhuanghd', 'gonghuihd', 'hbzbhd', 'jjchd', 'taskhd',
'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd', 'xstaskhd', 'lingzhulaixihd', 'dxlthd', 'wzcjhd', 'slzdhd', 'qjzzdhd', 'kuangdonghd', 'qiandaohd', 'kaifukuanghuanhd', 'jijinhd', 'zhuishalinghd',
'yibaichouhd', 'huobanzhaomuhd', 'qirileichonghd', 'jierihd', 'kbzzhd', 'wzryhd', 'yuedujijin', 'mingdao', 'patahd', 'yibaichouhd', 'huobanzhaomuhd', 'qirileichonghd', 'jierihd', 'kbzzhd', 'wzryhd', 'yuedujijin', 'mingdao', 'patahd',
'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai']; 'heishihd', 'huodonghd', 'renown', 'weixiuchang', 'kaifujingsai', 'zhoumolibao'];
export default async function (call: ApiCall<ReqGet, ResGet>) { export default async function (call: ApiCall<ReqGet, ResGet>) {
@ -28,13 +28,13 @@ export default async function (call: ApiCall<ReqGet, ResGet>) {
let toDayZeroTime = PublicShared.getToDayZeroTime(); let toDayZeroTime = PublicShared.getToDayZeroTime();
//正常跑完引导的等级 //正常跑完引导的等级
if(call.conn.gud.lv >= 7){ if (call.conn.gud.lv >= 7) {
for (let key of keys) { for (let key of keys) {
switch (key) { switch (key) {
case 'jiuba': case 'jiuba':
case 'jiaotang': case 'jiaotang':
let db = await G.mongodb.collection('playerInfo', key).findOne({ uid: call.uid, type: key }); let db = await G.mongodb.collection('playerInfo', key).findOne({uid: call.uid, type: key});
res[key] = { show: (!db || toDayZeroTime >= db.freeTime) ? true : false }; res[key] = {show: (!db || toDayZeroTime >= db.freeTime) ? true : false};
break; break;
case 'shouchong': case 'shouchong':
res[key] = await getShouChongRedPoint(call); res[key] = await getShouChongRedPoint(call);
@ -160,6 +160,9 @@ export default async function (call: ApiCall<ReqGet, ResGet>) {
case 'kaifujingsai': case 'kaifujingsai':
res[key] = await HongDianFun.kaifujingsai(call); res[key] = await HongDianFun.kaifujingsai(call);
break; break;
case 'zhoumolibao':
res[key] = await HongDianFun.zhoumolibao(call);
break;
} }
} }
} }

View File

@ -20,7 +20,7 @@ import {PlayerFun} from "../../public/player";
import kfjsFun from "../../public/kaifujingsai"; import kfjsFun from "../../public/kaifujingsai";
import {RankKfjs} from "../../public/rank/rank_kfjs"; import {RankKfjs} from "../../public/rank/rank_kfjs";
import {ShopFun} from "../../public/shop"; import {ShopFun} from "../../public/shop";
import { Christmasfun } from '../event/christmas/fun'; import {Christmasfun} from '../event/christmas/fun';
export class HongDianFun { export class HongDianFun {
/**黑榜争霸红点 */ /**黑榜争霸红点 */
@ -301,6 +301,18 @@ export class HongDianFun {
return {show: true, val: canGet} return {show: true, val: canGet}
} }
/**周末礼包 */
static async zhoumolibao(call: ApiCall): Promise<hongdianVal> {
let _hd = (await HuoDongFun.gethdList(call, 9))[0]
let gift = _hd?.data?.gift?.find(i => i.free)
if (!gift) return {show: false}
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
let rec = data?.record?.[gift.id]
if (rec && rec >= gift?.buyNum) return {show: false}
return {show: true}
}
} }
@ -708,10 +720,11 @@ export class HuoDongHongDianFun {
if (_buyNum < _tmp.buynum) { if (_buyNum < _tmp.buynum) {
_res.show = true; _res.show = true;
return _res; return _res;
}} }
}
let _diff = PublicShared.getDiff(stime) let _diff = PublicShared.getDiff(stime)
// 循环判断是否有可以领取的 // 循环判断是否有可以领取的
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
_res.show = true; _res.show = true;
return _res; return _res;
@ -724,15 +737,15 @@ export class HuoDongHongDianFun {
return _res; return _res;
} }
let zhanling = _hdCon.zhanling let zhanling = _hdCon.zhanling
for (let indexzhanling = 0; indexzhanling < zhanling.length; indexzhanling++){ for (let indexzhanling = 0; indexzhanling < zhanling.length; indexzhanling++) {
if (!_mydata.pt.includes(indexzhanling)){ if (!_mydata.pt.includes(indexzhanling)) {
_res.show = true; _res.show = true;
return _res; return _res;
} }
if (_mydata.pay && !_mydata.gj.includes(indexzhanling)){ if (_mydata.pay && !_mydata.gj.includes(indexzhanling)) {
_res.show = true; _res.show = true;
return _res; return _res;
} }
} }
return _res; return _res;

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

@ -7,16 +7,43 @@ import {HeroShared} from '../shared/public/hero';
import {PlayerShared} from '../shared/public/player'; import {PlayerShared} from '../shared/public/player';
import {HeroFun} from './hero'; import {HeroFun} from './hero';
import {UserFun} from './user'; import {UserFun} from './user';
import {re} from "mathjs"; import {re, string} from "mathjs";
import {getGud} from './gud'; import {getGud} from './gud';
import {PushGiftFun} from "./pushgift"; import {PushGiftFun} from "./pushgift";
type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross'; type fightType = 'tanxian' | 'pata' | 'jjc' | 'gbtx' | 'qjzzd' | 'meirishilian' | 'wzrycross';
let fights:{[key:string]:FightControl} = {
};
function clearFights (){
//定时清理战斗
setInterval(()=>{
let now = Date.now();
for (let key in fights){
if (now - fights[key].startTime > 30000){
console.log("清理战斗",key);
try{
fights[key].release();
}catch(e){
console.error(e);
}
delete fights[key];
}
}
},5000);
}
clearFights();
export class FightFun { export class FightFun {
static fightIndex:number = 0;
static fight(data: joinFightData[], maxRoundNums = 30, fightType: "pvp" | "pve" = 'pvp') { static fight(data: joinFightData[], maxRoundNums = 30, fightType: "pvp" | "pve" = 'pvp') {
return new FightControl(data, maxRoundNums, fightType).getResult(); this.fightIndex++;
fights[this.fightIndex] = new FightControl(data, maxRoundNums, fightType);
return fights[this.fightIndex].getResult();
} }
/**获取玩家数据 */ /**获取玩家数据 */

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

@ -5,6 +5,7 @@ import * as BuffClass from './fightBuff/buffExtends';
import { FightControl } from "./fightCntrol"; import { FightControl } from "./fightCntrol";
import { getSkillConf, randNumber, randomSkill } from "./fightFun"; import { getSkillConf, randNumber, randomSkill } from "./fightFun";
import { buffDataType, dpsinfoType, joinFightData, modifyHpType, roleDataType } from "./fightType"; import { buffDataType, dpsinfoType, joinFightData, modifyHpType, roleDataType } from "./fightType";
import { PassiveSkillBase } from "./passiveSkill/passiveSkillBase";
import { runPassiveSkillBase } from "./passiveSkill/runPassiveSkill"; import { runPassiveSkillBase } from "./passiveSkill/runPassiveSkill";
import { SkillBase } from "./skill/skillBase"; import { SkillBase } from "./skill/skillBase";
@ -24,6 +25,23 @@ export class Player {
get lockHp() { return false; } get lockHp() { return false; }
get rolePlayer() { return this } get rolePlayer() { return this }
release(){
for(let buffid in this.buffs){
this.buffs[buffid].release();
}
for(let passiveid in this.passiveSkills){
this.passiveSkills[passiveid].release();
}
this.curAtkSkill?.release();
this.curAtkSkill = null;
this.skillTargets = null;
this.lastSkillTargets = null;
this.lastSkillId = null;
this.lastHitMe = null;
this.buffs = null;
this.passiveSkills = null;
}
skillIdx = 0; skillIdx = 0;
skillLv = 1; skillLv = 1;
hudunzhi = 0; hudunzhi = 0;

View File

@ -20,6 +20,7 @@ import {
import {runPassiveSkillBase} from "./passiveSkill/runPassiveSkill"; import {runPassiveSkillBase} from "./passiveSkill/runPassiveSkill";
import {SkillBase} from "./skill/skillBase"; import {SkillBase} from "./skill/skillBase";
import { PublicShared } from "../public/public"; import { PublicShared } from "../public/public";
import { PassiveSkillBase } from "./passiveSkill/passiveSkillBase";
export class Role { export class Role {
rid: string; rid: string;
@ -37,6 +38,23 @@ export class Role {
hudunzhi = 0; hudunzhi = 0;
addpkNum = 0; addpkNum = 0;
release(){
for(let buffid in this.buffs){
this.buffs[buffid].release();
}
for(let passiveid in this.passiveSkills){
this.passiveSkills[passiveid].release();
}
this.curAtkSkill?.release();
this.curAtkSkill = null;
this.skillTargets = null;
this.lastSkillTargets = null;
this.lastSkillId = null;
this._lastHitMe = null;
this.buffs = null;
this.passiveSkills = null;
}
get skillId() { get skillId() {
let heroId = this.roleData.heroId; let heroId = this.roleData.heroId;
let jieji = this.roleData.jieji || 0; let jieji = this.roleData.jieji || 0;
@ -102,6 +120,8 @@ export class Role {
// fromRole行动的角色 // fromRole行动的角色
// skillConf 使用的技能 // skillConf 使用的技能
// toRole 目标 // toRole 目标
//上一个指针release
this.curAtkSkill?.release();
this.curAtkSkill = this.runSkillClass(); this.curAtkSkill = this.runSkillClass();
this.bloodReturn(); this.bloodReturn();
this.debug(() => { this.debug(() => {

View File

@ -17,6 +17,13 @@ export class BuffBase {
this._BuffId = 'BuffId_' + idx; this._BuffId = 'BuffId_' + idx;
this.startRound = this.role.fightControl.roundNums; this.startRound = this.role.fightControl.roundNums;
} }
release(){
this.clear('release');
this.altAttr = null;
this.role = null;
}
start() { start() {
let skillConf = this.data.skillConf; let skillConf = this.data.skillConf;
this.remainingRounds = skillConf.round; this.remainingRounds = skillConf.round;
@ -119,17 +126,19 @@ export class BuffBase {
buffType = Object.keys(this.data.skillConf.xiaoguocanshu).join(','); buffType = Object.keys(this.data.skillConf.xiaoguocanshu).join(',');
} }
// 字符串以逗号分隔转换为数组 // 字符串以逗号分隔转换为数组
let buffTypeArr = buffType.split(',') if(when != "release"){
buffTypeArr.forEach(buffTypeStr => { let buffTypeArr = buffType.split(',')
this.role.fightControl.record({ buffTypeArr.forEach(buffTypeStr => {
act: 'delBuff', this.role.fightControl.record({
fromRole: this.role.rid, act: 'delBuff',
skillId: this.data.buffid, fromRole: this.role.rid,
buffType: buffTypeStr, skillId: this.data.buffid,
buffId: this._BuffId, buffType: buffTypeStr,
why: when buffId: this._BuffId,
}); why: when
}) });
})
}
this.willClear(); this.willClear();
// this.role.fightControl.event.emit('fight_buffClear', this.data); // this.role.fightControl.event.emit('fight_buffClear', this.data);
let buffid = this.data.buffid; let buffid = this.data.buffid;

View File

@ -6,9 +6,10 @@ import { Player } from "./Player";
import { Role } from "./Role"; import { Role } from "./Role";
export class FightControl { export class FightControl {
//所有战斗成员 startTime: number = Date.now();
//所有战斗成员,包含双方的所有“伙伴”
fightRoles: k_v<Role> = {}; fightRoles: k_v<Role> = {};
//所有战斗对象,包含了双方的“伙伴”和“主角”
fightRolesArr: FightObj[] = []; fightRolesArr: FightObj[] = [];
fightOver = false; fightOver = false;
roundNums = 0; roundNums = 0;
@ -18,6 +19,7 @@ export class FightControl {
initial: joinFightData[]; initial: joinFightData[];
winSide: number; winSide: number;
totalDamage = { "0": 0, "1": 0 }; totalDamage = { "0": 0, "1": 0 };
//战斗统计
fightStatistics: { [k: string]: { [k: string]: number; }; } = {}; fightStatistics: { [k: string]: { [k: string]: number; }; } = {};
player_0: FightObj = null; player_0: FightObj = null;
player_1: FightObj = null; player_1: FightObj = null;
@ -29,6 +31,26 @@ export class FightControl {
this.startTurnRound(); this.startTurnRound();
} }
/**
*
*/
release(){
this.fightRolesArr.map( obj =>{
obj?.release();
});
this.fightRoles = null;
this.fightRolesArr = null;
this.recordData = null;
this.event.removeAllListeners();
this.event = null;
this.initial = null;
this.fightStatistics = null;
this.player_0 = null;
this.player_1 = null;
this.recordSkillDps = null;
this.DATA = null;
}
initControl() { initControl() {
// this.event.setMaxListeners(1000); // this.event.setMaxListeners(1000);
} }

View File

@ -103,6 +103,11 @@ export class PassiveSkillBase {
this._passiveId = 'passiveSkill_' + idx; this._passiveId = 'passiveSkill_' + idx;
this.skillConf = this.skillInfo.skillConf; this.skillConf = this.skillInfo.skillConf;
} }
release(){
this.clear('release');
this.skillConf = null;
this._timers = null;
}
start() { start() {
this._initEvent(); this._initEvent();
@ -112,10 +117,10 @@ export class PassiveSkillBase {
_initEvent() { _initEvent() {
let _when = this.skillConf.chkdata.when; let _when = this.skillConf.chkdata.when;
let toRole = this.skillInfo.toRole; let toRole = this.skillInfo.toRole;
if (_when == 'ontime') { // if (_when == 'ontime') {
//定时触发 或者 频率触发 // //定时触发 或者 频率触发
this._whenOntime(); // this._whenOntime();
} else { // } else {
this._checkFunc = (emitData) => { this._checkFunc = (emitData) => {
toRole.debug(() => { toRole.debug(() => {
console.log('### passiveskill checkEmit', 'fightEvent_' + _when, this.skillConf.skillid); console.log('### passiveskill checkEmit', 'fightEvent_' + _when, this.skillConf.skillid);
@ -123,7 +128,7 @@ export class PassiveSkillBase {
this.checkEmit(emitData); this.checkEmit(emitData);
}; };
toRole.fightControl.event.on('fightEvent_' + _when, this._checkFunc.bind(this), this); toRole.fightControl.event.on('fightEvent_' + _when, this._checkFunc.bind(this), this);
} //}
} }
checkEmit(emitData: EmitDataType) { checkEmit(emitData: EmitDataType) {
@ -161,21 +166,22 @@ export class PassiveSkillBase {
this.remainingRounds--; this.remainingRounds--;
} }
_whenOntime() { //不能也不应该有这样的逻辑,这是个回合制游戏!
let time = this.skillConf.chkdata.time; // _whenOntime() {
if (!time) return; // let time = this.skillConf.chkdata.time;
this._timers.push(setTimeout(() => { // if (!time) return;
this.doAtk(); // this._timers.push(setTimeout(() => {
}, time)); // this.doAtk();
} // }, time));
// }
_doNextOntime() { // _doNextOntime() {
let pinlvtime = this.skillConf.chkdata.pinlvtime; // let pinlvtime = this.skillConf.chkdata.pinlvtime;
if (!pinlvtime) return; // if (!pinlvtime) return;
this._timers.push(setTimeout(() => { // this._timers.push(setTimeout(() => {
this.doAtk(); // this.doAtk();
}, pinlvtime)); // }, pinlvtime));
} // }
/** 清除执行次数限制的被动 */ /** 清除执行次数限制的被动 */
_clearOnceSkill() { _clearOnceSkill() {
@ -188,7 +194,7 @@ export class PassiveSkillBase {
doAtk(emitData?: EmitDataType) { doAtk(emitData?: EmitDataType) {
this._triggerCount++; this._triggerCount++;
this._clearOnceSkill(); this._clearOnceSkill();
this._doNextOntime(); //this._doNextOntime();
} }
clear(why: string) { clear(why: string) {

View File

@ -11,6 +11,11 @@ export class SkillBase {
this.checkAtk(); this.checkAtk();
} }
release(){
this.clear();
this.toRole = null;
}
onRoleClear(why?: string) { onRoleClear(why?: string) {
} }

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

@ -1,5 +1,3 @@
/** /**
* *
*/ */
@ -13,10 +11,47 @@ export const conf = {
timeIntervalLimit: 0 timeIntervalLimit: 0
}; };
export type hongdianKey = 'jiuba' | 'jiaotang' | 'shouchong' | 'dixiaqianzhuanghd' | 'taskhd' | 'xstaskhd' | 'gonghuihd' | 'jjchd' | 'hbzbhd' | export type hongdianKey =
'clslhd' | 'lingzhulaixihd' | 'dxlthd' | 'wzcjhd' | 'slzdhd' | 'qjzzdhd' | 'kuangdonghd' | 'qiandaohd' | 'kaifukuanghuanhd' | 'jijinhd' | 'zhuishalinghd' | 'jiuba'
'yibaichouhd' | 'huobanzhaomuhd' | 'qirileichonghd' | 'jierihd' | 'kbzzhd' | 'wzryhd' | 'yuedujijin' | 'patahd' | | 'jiaotang'
'mingdao' | 'heishihd' |'jitianhaoli'| 'huodonghd' | 'renown' | 'heishiMrjx' | 'weixiuchang' | 'kaifujingsai'; | 'shouchong'
| 'dixiaqianzhuanghd'
| 'taskhd'
| 'xstaskhd'
| 'gonghuihd'
| 'jjchd'
| 'hbzbhd'
|
'clslhd'
| 'lingzhulaixihd'
| 'dxlthd'
| 'wzcjhd'
| 'slzdhd'
| 'qjzzdhd'
| 'kuangdonghd'
| 'qiandaohd'
| 'kaifukuanghuanhd'
| 'jijinhd'
| 'zhuishalinghd'
|
'yibaichouhd'
| 'huobanzhaomuhd'
| 'qirileichonghd'
| 'jierihd'
| 'kbzzhd'
| 'wzryhd'
| 'yuedujijin'
| 'patahd'
|
'mingdao'
| 'heishihd'
| 'jitianhaoli'
| 'huodonghd'
| 'renown'
| 'heishiMrjx'
| 'weixiuchang'
| 'kaifujingsai'
| 'zhoumolibao';
export type hongdianVal = { export type hongdianVal = {

View File

@ -8652,6 +8652,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",
@ -8661,7 +8668,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 6, "id": 7,
"name": "gj", "name": "gj",
"type": { "type": {
"type": "Array", "type": "Array",
@ -8671,14 +8678,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",
@ -8691,7 +8698,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 9, "id": 10,
"name": "select", "name": "select",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -8710,24 +8717,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"
@ -14904,6 +14911,13 @@ export const serviceProto: ServiceProto<ServiceType> = {
"type": "Literal", "type": "Literal",
"literal": "kaifujingsai" "literal": "kaifujingsai"
} }
},
{
"id": 36,
"type": {
"type": "Literal",
"literal": "zhoumolibao"
}
} }
] ]
}, },