Merge branch 'master' into feature/json

This commit is contained in:
dy 2023-12-22 15:00:23 +08:00
commit a135acbc93
40 changed files with 3843 additions and 351 deletions

View File

@ -11,4 +11,6 @@ WORKDIR /app
RUN npm config set registry http://registry.npm.taobao.org/ && npm install pm2@5.2.2 -g RUN npm config set registry http://registry.npm.taobao.org/ && npm install pm2@5.2.2 -g
RUN rm -rf node_modules/tsbuffer-validator/index.js && cp tsbufferIndex.js node_modules/tsbuffer-validator/index.js
CMD cd /app && sh zoeninfo.sh "Asia/Tokyo" && pm2-runtime start js_pm2.config.js -- ${Param} CMD cd /app && sh zoeninfo.sh "Asia/Tokyo" && pm2-runtime start js_pm2.config.js -- ${Param}

View File

@ -60,6 +60,8 @@ const localApps = [
instances: instancesNum, instances: instancesNum,
// 传递给脚本的参数 // 传递给脚本的参数
args: '-serverType msg', args: '-serverType msg',
//允许强制gc
node_args: '--expose-gc',
// 是否启用监控模式默认是false。如果设置成true当应用程序变动时pm2会自动重载。这里也可以设置你要监控的文件。 // 是否启用监控模式默认是false。如果设置成true当应用程序变动时pm2会自动重载。这里也可以设置你要监控的文件。
watch: false, watch: false,
// 不用监听的文件 // 不用监听的文件
@ -86,6 +88,8 @@ const crossApps = [
cwd: './', cwd: './',
// 传递给脚本的参数 // 传递给脚本的参数
args: '-serverType cross', args: '-serverType cross',
//允许强制gc
node_args: '--expose-gc',
// 是否启用监控模式默认是false。如果设置成true当应用程序变动时pm2会自动重载。这里也可以设置你要监控的文件。 // 是否启用监控模式默认是false。如果设置成true当应用程序变动时pm2会自动重载。这里也可以设置你要监控的文件。
watch: false, watch: false,
// 不用监听的文件 // 不用监听的文件

1823
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,9 @@
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "tsrpc-cli dev", "dev": "tsrpc-cli dev",
"build": "tsrpc-cli build && copy js_pm2.config.js dist && copy zoeninfo.sh dist && mkdir dist\\json && xcopy src\\json dist\\json /e ", "build": "tsrpc-cli build && copy js_pm2.config.js dist && copy zoeninfo.sh dist && copy tsbufferIndex.js dist && mkdir dist\\json && xcopy src\\json dist\\json /e ",
"build_win": "tsrpc-cli build && copy js_pm2.config.js dist && copy zoeninfo.sh dist && mkdir dist\\json && xcopy src\\json dist\\json /e ", "build_win": "tsrpc-cli build && copy js_pm2.config.js dist && copy zoeninfo.sh dist && copy tsbufferIndex.js dist && mkdir dist\\json && xcopy src\\json dist\\json /e ",
"build_linux": "tsrpc-cli build && cp js_pm2.config.js dist && cp zoeninfo.sh dist && cp src/json/ -a dist ", "build_linux": "tsrpc-cli build && cp js_pm2.config.js dist && cp zoeninfo.sh dist && cp tsbufferIndex.js dist && cp src/json/ -a dist ",
"build_docker_win": "npm run build_win && cd dist && npm i --omit=dev", "build_docker_win": "npm run build_win && cd dist && npm i --omit=dev",
"build_docker_linux": "npm run build_linux && cd dist && npm i --omit=dev", "build_docker_linux": "npm run build_linux && cd dist && npm i --omit=dev",
"doc": "tsrpc-cli doc && node js_uploadDoc.js", "doc": "tsrpc-cli doc && node js_uploadDoc.js",
@ -37,10 +37,12 @@
"axios": "^1.4.0", "axios": "^1.4.0",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"express": "^4.18.2", "express": "^4.18.2",
"heapdump": "^0.3.15",
"ioredis": "^5.3.2", "ioredis": "^5.3.2",
"json5": "^2.2.3", "json5": "^2.2.3",
"mathjs": "^11.4.0", "mathjs": "^11.4.0",
"mongodb": "^4.17.1", "mongodb": "^4.17.1",
"node-gyp": "^10.0.1",
"ramda": "^0.29.1", "ramda": "^0.29.1",
"redis": "^4.3.1", "redis": "^4.3.1",
"shelljs": "^0.8.5", "shelljs": "^0.8.5",

View File

@ -1,23 +1,29 @@
import {ApiCall} from "tsrpc"; import {ApiCall} from "tsrpc";
import {ReqRank, ResRank} from "../../cross/protocols/wzry/PtlRank"; import {ReqRank, ResRank} from "../../cross/protocols/wzry/PtlRank";
import {player} from "../../shared/protocols/user/type"; import {player} from "../../shared/protocols/user/type";
import {FindOptions} from "mongodb"; import {Filter, FindOptions, OptionalId} from "mongodb";
import { CollectionRankList } from "../../module/collection_rank";
export async function getRankList(limit?: number, projection?: any) { export async function getRankList(limit?: number, projection?: any, _where?:any) {
let option: FindOptions = { let option: FindOptions = {
sort: { sort: {
'data.valArr': -1, 'data.valArr': -1,
'data.player.power': -1 'data.player.power': -1
} }
} }
let filter:Filter<OptionalId<CollectionRankList>> = {type: 'wzryCross'};
if (limit != null) { if (limit != null) {
option.limit = limit; option.limit = limit;
} }
if (projection != null) { if (projection != null) {
option.projection = projection; option.projection = projection;
} }
if (_where != null) {
Object.assign(filter, _where);
}
let listArr = await G.mongodb.collection('rankList').find({type: 'wzryCross'}, option).toArray(); let listArr = await G.mongodb.collection('rankList').find(filter, option).toArray();
let list = listArr.map(l => l.data); let list = listArr.map(l => l.data);
return list; return list;

View File

@ -0,0 +1,23 @@
import { ApiCall } from "tsrpc";
import { Reqheapdump, Resheapdump } from "../../monopoly/protocols/games/Ptlheapdump";
var heapdump = require('heapdump');
export default async function (call: ApiCall<Reqheapdump, Resheapdump>) {
if(call.req.act == "heapdump"){
let name = Date.now() + '.heapsnapshot'
heapdump.writeSnapshot(name);
call.succ({
code:200,
data:name
})
}
if(call.req.act == "gc"){
global.gc();
call.succ({
code:200,
data:"gc..."
})
}
}

View File

@ -39,15 +39,15 @@ export default async function (call: ApiCall<ReqSyncBtn, ResSyncBtn>) {
} }
break; break;
case 'christmas': case 'christmas':
//领完消失 //领完消失
if (!data[key]) { data[key] = {active: false};
let _hdList = await HuoDongFun.gethdList(call, 8) change[key] = data[key];
if (_hdList) { let _hdList = await HuoDongFun.gethdList(call, 8)
// 无此活动 if (_hdList.length > 0) {
data[key] = {active: true}; // 无此活动
change[key] = data[key]; data[key] = {active: true};
} change[key] = data[key];
} }
break; break;
case 'dayjijin': case 'dayjijin':
case 'dengjijijin': case 'dengjijijin':

View File

@ -27,7 +27,6 @@ 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 })
} }
let _prize: atn[] = _con.basep let _prize: atn[] = _con.basep
for (let key in _select) { for (let key in _select) {

View File

@ -19,17 +19,23 @@ export default async function (call: ApiCall<ReqQianDao, ResQianDao>) {
_mydata.qiandao.push(i) _mydata.qiandao.push(i)
_prize = _prize.concat(_con[i]) _prize = _prize.concat(_con[i])
} }
if (_prize.length <= 0){
if (!_prize){
// 没有奖励可以领取 // 没有奖励可以领取
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 }) return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
} }
let _setData = {} let _setData = {}
let _addVal = 0
// 懒得喊后台和前端修改了直接取prize里面的对应的经验字段去添加zhanling经验
for (const p of _prize) {
// 战令经验
if (p.t == "shengdanExp") {
_addVal += p.n
}
}
_mydata["val"] += _addVal
_setData["val"] = _mydata.val
_setData["qiandao"] = _mydata.qiandao _setData["qiandao"] = _mydata.qiandao
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData }) await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
await PlayerFun.sendPrize(call, _prize); await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize} let changedata = { mydata: _mydata, prize: _prize}
// 推送红点 // 推送红点

View File

@ -22,11 +22,14 @@ export default async function (call: ApiCall<ReqTaskRec, ResTaskRec>) {
return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_4 }) return call.error('', { code: -3, message: globalThis.lng.yangchengmubiao_4 })
} }
_mydata.taskfinish.push(taskid) _mydata.taskfinish.push(taskid)
let _addval = _con.addval
let _setData = {} let _setData = {}
_mydata["val"] += _addval
_setData["val"] = _mydata.val
_setData["taskfinish"] = _mydata.taskfinish _setData["taskfinish"] = _mydata.taskfinish
await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData }) await Christmasfun.setMyData(call.uid, call.req.hdid, { $set: _setData })
let _prize = _con.prize let _prize = _con.prize
await PlayerFun.sendPrize(call, _prize); await PlayerFun.sendPrize(call, _prize);
let changedata = { mydata: _mydata, prize: _prize} let changedata = { mydata: _mydata, prize: _prize}
// 推送红点 // 推送红点

View File

@ -30,7 +30,7 @@ export default async function (call: ApiCall<ReqZhanLingRec, ResZhanLingRec>) {
_mydata.gj.push(index) _mydata.gj.push(index)
} }
if (!_prize) { if (_prize.length <= 0) {
// 没有奖励可以领取 // 没有奖励可以领取
return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 }) return call.error('', { code: -1, message: globalThis.lng.yangchengmubiao_2 })
} }

View File

@ -113,11 +113,17 @@ export class Christmasfun {
mydata.taskval = await this.getTaskVal(call, hdid) mydata.taskval = await this.getTaskVal(call, hdid)
mydata.refresh = G.time mydata.refresh = G.time
mydata.gamenum = 0 mydata.gamenum = 0
await this.setMyData(call.uid, hdid, { $set: { refresh: mydata.refresh, taskfinish: mydata.taskfinish, taskval: mydata.taskval, gamenum: mydata.gamenum} }) mydata.libao = {}
await this.setMyData(call.uid, hdid, { $set: {
refresh: mydata.refresh,
taskfinish: mydata.taskfinish,
taskval: mydata.taskval,
gamenum: mydata.gamenum,
libao:mydata.libao} })
return mydata return mydata
} }
static async payChristmas(payid, call: ApiCall) { static async payChristmas(payid, call: any) {
let _hd = await HuoDongFun.gethdList(call, 8) let _hd = await HuoDongFun.gethdList(call, 8)
for (let index = 0; index < _hd.length; index++) { for (let index = 0; index < _hd.length; index++) {
const hdinfo = _hd[index]; const hdinfo = _hd[index];
@ -126,8 +132,8 @@ export class Christmasfun {
let _mydata = await Christmasfun.getMyData(call, _hdid) let _mydata = await Christmasfun.getMyData(call, _hdid)
if (_mydata.pay) continue if (_mydata.pay) continue
await this.setMyData(call.uid, _hdid, { $set: { pay: true} }) await this.setMyData(call.uid, _hdid, { $set: { pay: true} })
let _prize = hdinfo.data.zlpayprize // let _prize = hdinfo.data.zlpayprize
await PlayerFun.sendPrize(call, _prize); // await PlayerFun.sendPrize(call, _prize);
} }
else{ else{
const libaos = hdinfo.data.libao const libaos = hdinfo.data.libao
@ -140,6 +146,12 @@ export class Christmasfun {
if (_buyNum >= _tmp["buynum"]) continue if (_buyNum >= _tmp["buynum"]) continue
_mydata.libao[lbid] = _buyNum + 1 _mydata.libao[lbid] = _buyNum + 1
this.setMyData(call.uid, _hdid, { $set: { libao: _mydata.libao} }) this.setMyData(call.uid, _hdid, { $set: { libao: _mydata.libao} })
let _select = _mydata.select[lbid] || {}
let _prize: atn[] = _tmp["basep"]
for (let key in _select) {
_prize.push(_tmp["dlz"][parseInt(key)][_select[key]])
}
await PlayerFun.sendPrize(call, _prize);
break break
} }

View File

@ -50,19 +50,44 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
call.succ(db as any); call.succ(db as any);
} }
export async function refreshEnemys(call: ApiCall) { let lastRefreshTime: number
let section = [call.conn.gud.mapId - 8, call.conn.gud.mapId + 8]; let enemyObject: object = {}
//let allUser = Object.values(await G.redis.get('user')).filter(u => u.mapId >= section[0] && u.mapId <= section[1] && u.uid != call.uid);
//let dbUser = await G.mongodb.collection('wanted').find({uid: {$in: allUser.map(u => u.uid)}}).toArray();
let allUser = await G.mongodb.find('user', { /**
$and: [ * 30308080100
{mapId: {$gte: section[0]}}, */
{mapId: {$lte: section[1]}}, async function checkAndRefreshEnemy() {
{uid: {$ne: call.uid}} if (lastRefreshTime + 3600 > G.time) return
] lastRefreshTime = G.time
}, ['uid']); for (let i = 3; i <= 8; i++) {
let dbUser = await G.mongodb.find('wanted', {uid: {$in: allUser.map(u => u.uid)}}, ['uid', 'wanted']); let users = await G.mongodb.collection('user').aggregate([
{
$match: {
$and: [
{lv: {$gte: i * 10}},
{lv: {$lt: i == 8 ? 101 : (i + 1) * 10}},
]
}
},
{
$project: {uid: 1}
},
{
$sample: {size: 100}
}
]).toArray()
let dbUser = await G.mongodb.find('wanted', {uid: {$in: users.map(u => u.uid)}}, ['uid', 'wanted']);
enemyObject[i] = dbUser || []
}
}
export async function refreshEnemys(call: ApiCall) {
if (!lastRefreshTime) await checkAndRefreshEnemy()
let lvDw = Math.floor(call.conn.gud.lv / 10 > 8 ? 8 : call.conn.gud.lv / 10)
let dbUser = enemyObject[lvDw] || []
let enemys: joinFightData[] = []; let enemys: joinFightData[] = [];
@ -74,7 +99,6 @@ export async function refreshEnemys(call: ApiCall) {
let filter = dbUser.filter(u => conf.need <= u.wanted && u.wanted < needMax); let filter = dbUser.filter(u => conf.need <= u.wanted && u.wanted < needMax);
let uids = filter.map(f => f.uid); let uids = filter.map(f => f.uid);
dbUser.remove(u => uids.includes(u.uid)); dbUser.remove(u => uids.includes(u.uid));
let a = configs[0].npc.random()
let enemy = uids.length > 0 ? await FightFun.getPlayerFightData(uids.random()) : formatNpcData(configs[0].npc.random()); let enemy = uids.length > 0 ? await FightFun.getPlayerFightData(uids.random()) : formatNpcData(configs[0].npc.random());
if (!enemy) enemy = formatNpcData(configs[0].npc.random()) if (!enemy) enemy = formatNpcData(configs[0].npc.random())
if (enemy.player.isNpc) enemy.player.name = G.gc.gonglukuangbiao.npcname.random() if (enemy.player.isNpc) enemy.player.name = G.gc.gonglukuangbiao.npcname.random()
@ -83,7 +107,7 @@ export async function refreshEnemys(call: ApiCall) {
PublicShared.randomNum(G.gc.gonglukuangbiao.wanted[0].wanted[0], G.gc.gonglukuangbiao.wanted[0].wanted[1]) PublicShared.randomNum(G.gc.gonglukuangbiao.wanted[0].wanted[0], G.gc.gonglukuangbiao.wanted[0].wanted[1])
enemys.push(enemy); enemys.push(enemy);
} }
checkAndRefreshEnemy()
return enemys.reverse(); return enemys.reverse();
} }

View File

@ -364,6 +364,10 @@ export class HuoDongHongDianFun {
// 检测 htype 6 七日登录活动红点 // 检测 htype 6 七日登录活动红点
ishd = await this.qiridengluHongDian(call, element) ishd = await this.qiridengluHongDian(call, element)
} }
if (element.htype == 8) {
// 检测 htype 8 圣诞活动红点
ishd = await this.christmasHongDian(call, element)
}
// 此活动有红点 // 此活动有红点
if (ishd.show) { if (ishd.show) {
@ -704,7 +708,7 @@ export class HuoDongHongDianFun {
for (let indextask = 0; indextask < Object.keys(_tasks).length; indextask++) { for (let indextask = 0; indextask < Object.keys(_tasks).length; indextask++) {
const elementtask = Object.keys(_tasks)[indextask]; const elementtask = Object.keys(_tasks)[indextask];
let _tmp = _tasks[elementtask]; let _tmp = _tasks[elementtask];
if (_tmp.pval <= (_mydata.taskval[elementtask] || 0) && !_mydata.taskfinsih.includes(elementtask)) { if (_tmp.pval <= (_mydata.taskval[elementtask] || 0) && !_mydata.taskfinish.includes(elementtask)) {
// 任务完成且没有领取 // 任务完成且没有领取
_res.show = true; _res.show = true;
return _res; return _res;

View File

@ -6,7 +6,7 @@ import {PublicShared} from '../../shared/public/public';
import {TanXianShared} from '../../shared/public/tanxian'; import {TanXianShared} from '../../shared/public/tanxian';
import {event_dldh_addPrize} from '../event/diaoluoduihuan/ApiOpen'; import {event_dldh_addPrize} from '../event/diaoluoduihuan/ApiOpen';
import {getEventPrize} from '../tanxian/ApiEvent'; import {getEventPrize} from '../tanxian/ApiEvent';
import { getItemByItemId } from "../../public/item"; import {getItemByItemId} from "../../public/item";
const iType = { const iType = {
3: 'hero', 3: 'hero',
@ -15,10 +15,10 @@ const iType = {
}; };
export default async function (call: ApiCall<ReqUse, ResUse>) { export default async function (call: ApiCall<ReqUse, ResUse>) {
//ȥ<><C8A5>item Redis<69><73><EFBFBD> //ȥ<><C8A5>item Redis<69><73><EFBFBD>
let itemInfo = await getItemByItemId(call.uid,call.req.itemId); //call.conn.item[call.req.itemId]; let itemInfo = await getItemByItemId(call.uid, call.req.itemId); //call.conn.item[call.req.itemId];
if(!itemInfo[call.req.itemId]) return call.error(globalThis.lng.item_1); if (!itemInfo[call.req.itemId]) return call.error(globalThis.lng.item_1);
let item = itemInfo[call.req.itemId]; let item = itemInfo[call.req.itemId];
let useNum = call.req.useNum; let useNum = call.req.useNum;
@ -105,8 +105,9 @@ export default async function (call: ApiCall<ReqUse, ResUse>) {
n: useNum n: useNum
} }
]; ];
} else if ([7, 8].includes(itemConf.type)) { } else if ([6, 7, 8].includes(itemConf.type)) {
if (useNum > item.num) return call.error(globalThis.lng.item_3); if (useNum > item.num) return call.error(globalThis.lng.item_3);
if (itemConf.type == 6) UserFun.activeModel(call.uid, itemConf.diaoluo.toString(), useNum);
if (itemConf.type == 7) UserFun.activeHeadFrame(call.uid, itemConf.diaoluo.toString(), useNum); if (itemConf.type == 7) UserFun.activeHeadFrame(call.uid, itemConf.diaoluo.toString(), useNum);
if (itemConf.type == 8) UserFun.activeChatFrame(call.uid, itemConf.diaoluo.toString(), useNum); if (itemConf.type == 8) UserFun.activeChatFrame(call.uid, itemConf.diaoluo.toString(), useNum);

View File

@ -1,16 +1,27 @@
import { ApiCall } from "tsrpc"; import {ApiCall} from "tsrpc";
import { PlayerFun } from '../../public/player'; import {PlayerFun} from '../../public/player';
import { ReqChangeInfo, ResChangeInfo } from "../../shared/protocols/user/PtlChangeInfo"; import {ReqChangeInfo, ResChangeInfo} from "../../shared/protocols/user/PtlChangeInfo";
import { ResLogin } from '../../shared/protocols/user/PtlLogin'; import {ResLogin} from '../../shared/protocols/user/PtlLogin';
import { UserShared } from '../../shared/public/user'; import {UserShared} from '../../shared/public/user';
export default async function (call: ApiCall<ReqChangeInfo, ResChangeInfo>) { export default async function (call: ApiCall<ReqChangeInfo, ResChangeInfo>) {
if (call.req.type == 'model' && !call.req.pos) return call.error(globalThis.lng.shiwu_6); // if (call.req.type == 'model' && !call.req.pos) return call.error(globalThis.lng.shiwu_6);
const active = (await G.mongodb.collection('playerInfo', 'playerInfo').findOne({ uid: call.uid, type: 'playerInfo' }))?.active || {}; let active = (await G.mongodb.collection('playerInfo', 'playerInfo').findOne({
const fmtId = UserShared.getInfoId(call.req.type, call.req.id, call.req.pos || ''); uid: call.uid,
const isMeet = UserShared.chechIsActive(fmtId, { lv: call.conn.gud.lv, vip: call.conn.gud.vip, lsyx: call.conn.lshd.hero, active: active }); type: 'playerInfo'
}))?.active || {};
const fmtId = UserShared.getInfoId(call.req.type, call.req.id);
if (R.values(active).length == 0) active = UserShared.getActive(fmtId, call.conn.gud, call.req.type, call.req.id)
const isMeet = UserShared.chechIsActive(fmtId, {
lv: call.conn.gud.lv,
vip: call.conn.gud.vip,
lsyx: call.conn.lshd.hero,
model: call.conn.gud.model,
active: active
});
if (!isMeet && call.req.type != 'headFrame' && call.req.type != 'chatFrame') return call.error(globalThis.lng.user_1); if (!isMeet && call.req.type != 'headFrame' && call.req.type != 'chatFrame') return call.error(globalThis.lng.user_1);
@ -18,10 +29,12 @@ export default async function (call: ApiCall<ReqChangeInfo, ResChangeInfo>) {
if (call.req.type == 'model') { if (call.req.type == 'model') {
let d = JSON.parse(JSON.stringify(call.conn.gud.model)); let d = JSON.parse(JSON.stringify(call.conn.gud.model));
d[call.req.pos] = { let changeItem = {
id: call.req.id, id: call.req.id,
time: active[fmtId] || -1 time: active[fmtId] || -1
}; }
d[call.req.id] = changeItem
change.upModel = changeItem
change.model = d; change.model = d;
} else { } else {
change[call.req.type] = { change[call.req.type] = {

View File

@ -2,13 +2,14 @@ import {RedisClientType, createClient} from "redis";
import {redisClient} from "./setRedis"; import {redisClient} from "./setRedis";
import {ConnectionStatus, WsServer} from "tsrpc"; import {ConnectionStatus, WsServer} from "tsrpc";
import cluster from 'cluster'; import cluster from 'cluster';
import { clusterFun } from "./clusterFunction"; import {clusterFun} from "./clusterFunction";
//维护当前uid和pid的对应关系 //维护当前uid和pid的对应关系
let uid2processId = {}; let uid2processId = {};
//订阅redis //订阅redis
let subscribeRedis: RedisClientType let subscribeRedis: RedisClientType
let firstPid = null; let firstPid = null;
//发布和可写redis复用原 setRedis 里的redisClient //发布和可写redis复用原 setRedis 里的redisClient
@ -20,10 +21,10 @@ let firstPid = null;
*/ */
export function clusterSubscribe(key: string, callback: Function) { export function clusterSubscribe(key: string, callback: Function) {
subscribeRedis.subscribe(G.redis.fromatKey(key), function (msg) { subscribeRedis.subscribe(G.redis.fromatKey(key), function (msg) {
try{ try {
callback(msg); callback(msg);
}catch(e){ } catch (e) {
console.error("clusterSubscribe error",e); console.error("clusterSubscribe error", e);
} }
}); });
} }
@ -43,14 +44,19 @@ export function clusterPublish(key: string, data: any) {
* N个进程中使 * N个进程中使
*/ */
export function clusterRunOnce(fun) { export function clusterRunOnce(fun) {
console.log(`${process.pid}环境变量pm_id===>${process.env.pm_id}`);
if (process.env.pm_id == null || process.env.pm_id === '0') { if (process.env.pm_id == null || process.env.pm_id === '0') {
//非pm2启动的或是pm2下启动的第一个进程 //非pm2启动的或是pm2下启动的第一个进程
console.log("run clusterRunOnce1 ===>", process.pid)
fun(); fun();
return; return;
} }
if(firstPid == process.pid){ if(G.config.isG123)return;
if (firstPid == process.pid) {
//pm2的其中一个进程 //pm2的其中一个进程
console.log("run clusterRunOnce2 ===>", process.pid)
fun(); fun();
return; return;
} }
@ -60,16 +66,16 @@ export function clusterRunOnce(fun) {
* *
* uid所在的进程执行fun方法uid不在任何进程的话 * uid所在的进程执行fun方法uid不在任何进程的话
*/ */
export function clusterFunctionRunAtUidProcess(uid:string, fun:string, ...arg:any[]) { export function clusterFunctionRunAtUidProcess(uid: string, fun: string, ...arg: any[]) {
if(!uid2processId[uid] || uid2processId[uid] == process.pid){ if (!uid2processId[uid] || uid2processId[uid] == process.pid) {
clusterFun[ fun ].call(this, ...arg); clusterFun[fun].call(this, ...arg);
return; return;
} }
clusterPublish("RunclusterFunction", JSON.stringify({ clusterPublish("RunclusterFunction", JSON.stringify({
"uid": uid, "uid": uid,
"fun": fun, "fun": fun,
"arg" : arg "arg": arg
})) }))
} }
@ -159,17 +165,17 @@ async function initSubscribeRedis() {
clusterSubscribe('broadcastClusterMsg', function (msg) { clusterSubscribe('broadcastClusterMsg', function (msg) {
let data = JSON.parse(msg); let data = JSON.parse(msg);
if(!data.filter){ if (!data.filter) {
//如果不是有条件发送的话 //如果不是有条件发送的话
G.server.broadcastMsg(data.msgName, data.msg); G.server.broadcastMsg(data.msgName, data.msg);
}else { } else {
//但是如果是有条件发送的话 //但是如果是有条件发送的话
//条件里可能需要进程内的信息,则需要每个进程都分别筛选后执行 //条件里可能需要进程内的信息,则需要每个进程都分别筛选后执行
if (data.filter.ghId != null) { if (data.filter.ghId != null) {
//指定公会 //指定公会
let conns = G.server.connections; let conns = G.server.connections;
conns = conns.filter(c => c?.gud?.ghId == data.filter.ghId); conns = conns.filter(c => c?.gud?.ghId == data.filter.ghId);
conns.length>0 && G.server.broadcastMsg(data.msgName, data.msg, conns); conns.length > 0 && G.server.broadcastMsg(data.msgName, data.msg, conns);
} }
} }
}); });
@ -178,7 +184,7 @@ async function initSubscribeRedis() {
clusterSubscribe('RunclusterFunction', function (msg) { clusterSubscribe('RunclusterFunction', function (msg) {
let data = JSON.parse(msg); let data = JSON.parse(msg);
if (uid2processId[data.uid] == process.pid) { if (uid2processId[data.uid] == process.pid) {
clusterFun[ data.fun ].call(this, ...data.arg); clusterFun[data.fun].call(this, ...data.arg);
} }
}); });
} }
@ -193,8 +199,8 @@ export async function clusterMain() {
}); });
//初始化订阅redis //初始化订阅redis
await initSubscribeRedis(); await initSubscribeRedis();
if(process.env.pm_id != null){ if (process.env.pm_id != null) {
//pm2启动的设置key为我的pid //pm2启动的设置key为我的pid
firstPid = await redisClient.get(G.redis.fromatKey("firstPid")); firstPid = await redisClient.get(G.redis.fromatKey("firstPid"));
if (!firstPid) { if (!firstPid) {
@ -207,7 +213,7 @@ export async function clusterMain() {
redisClient.del(G.redis.fromatKey("uid2processId")); redisClient.del(G.redis.fromatKey("uid2processId"));
}); });
} }
//初始化玩家pid信息 //初始化玩家pid信息
await initUid2processId(); await initUid2processId();

View File

@ -875,6 +875,29 @@ export const serviceProto: ServiceProto<ServiceType> = {
}, },
{ {
"id": 5, "id": 5,
"name": "upModel",
"type": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "id",
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "time",
"type": {
"type": "Number"
}
}
]
}
},
{
"id": 6,
"name": "model", "name": "model",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -903,14 +926,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 6, "id": 7,
"name": "renown", "name": "renown",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 7, "id": 8,
"name": "wxcLv", "name": "wxcLv",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -936,14 +959,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 8, "id": 9,
"name": "mapId", "name": "mapId",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 9, "id": 10,
"name": "shoucangping", "name": "shoucangping",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -956,14 +979,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 10, "id": 11,
"name": "useTujianLvPoint", "name": "useTujianLvPoint",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 11, "id": 12,
"name": "skills", "name": "skills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -976,7 +999,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 12, "id": 13,
"name": "fightSkills", "name": "fightSkills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -989,7 +1012,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 13, "id": 14,
"name": "heroPos", "name": "heroPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -1002,21 +1025,21 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 14, "id": 15,
"name": "ghId", "name": "ghId",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 15, "id": 16,
"name": "ghName", "name": "ghName",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 16, "id": 17,
"name": "ghLevel", "name": "ghLevel",
"type": { "type": {
"type": "Reference", "type": "Reference",
@ -1024,7 +1047,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 17, "id": 18,
"name": "ghwz", "name": "ghwz",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -1038,7 +1061,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 18, "id": 19,
"name": "ghExitTime", "name": "ghExitTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1046,7 +1069,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 19, "id": 20,
"name": "loginTime", "name": "loginTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1054,7 +1077,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 20, "id": 21,
"name": "logoutTime", "name": "logoutTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1062,7 +1085,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 21, "id": 22,
"name": "cTime", "name": "cTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1070,7 +1093,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 22, "id": 23,
"name": "loginDays", "name": "loginDays",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1078,7 +1101,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 23, "id": 24,
"name": "serverName", "name": "serverName",
"type": { "type": {
"type": "String" "type": "String"
@ -1086,7 +1109,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 24, "id": 25,
"name": "sid", "name": "sid",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1094,7 +1117,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 25, "id": 26,
"name": "onlineTime", "name": "onlineTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1102,7 +1125,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 26, "id": 27,
"name": "newonlinetime", "name": "newonlinetime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1110,7 +1133,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 27, "id": 28,
"name": "isNpc", "name": "isNpc",
"type": { "type": {
"type": "Boolean" "type": "Boolean"
@ -1118,7 +1141,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 28, "id": 29,
"name": "matrix", "name": "matrix",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -1132,7 +1155,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 29, "id": 30,
"name": "matrixPos", "name": "matrixPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -1152,7 +1175,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 30, "id": 31,
"name": "selectMatrix", "name": "selectMatrix",
"type": { "type": {
"type": "String" "type": "String"
@ -1160,7 +1183,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 31, "id": 32,
"name": "fightHeros", "name": "fightHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -1171,7 +1194,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 32, "id": 33,
"name": "helpHeros", "name": "helpHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -1248,7 +1271,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 33, "id": 34,
"name": "changeNameNum", "name": "changeNameNum",
"type": { "type": {
"type": "Number" "type": "Number"
@ -1256,7 +1279,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 34, "id": 35,
"name": "peijianUnlock", "name": "peijianUnlock",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -1270,7 +1293,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 35, "id": 36,
"name": "headFrames", "name": "headFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -1284,7 +1307,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 36, "id": 37,
"name": "chatFrames", "name": "chatFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",

View File

@ -0,0 +1,27 @@
import {ctor} from "../global";
import {initMongoDB} from "../setMongodb";
async function start() {
await initMongoDB()
// 刷新活动配置
console.log(`删除错误活动数据开始...`);
await G.mongodb.collection("hdinfo").deleteOne({hdid: 8000})
console.log(`删除错误活动数据完成...`);
}
ctor();
start().then(() => {
let s = 0;
setInterval(() => {
s += 1;
console.log(new Date().format("MM-dd hh:mm:ss"));
if (s >= 3) process.exit(1);
}, 1000)
console.log("逻辑执行完成...等待退出!!!");
});

View File

@ -143,6 +143,10 @@ export type gEventType = {
Class_task_154: (eventname, call, val, chkVal) => void; Class_task_154: (eventname, call, val, chkVal) => void;
/**每日任务宝箱领取 */ /**每日任务宝箱领取 */
Class_task_155: (eventname, call, val, chkVal) => void; Class_task_155: (eventname, call, val, chkVal) => void;
/**每日钻石消耗 */
Class_task_156: (eventname, call, val, chkVal) => void;
/**每日获取vip经验 */
Class_task_157: (eventname, call, val, chkVal) => void;
}; };
export function addListener() { export function addListener() {
@ -177,8 +181,6 @@ export function addListener() {
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;

View File

@ -1032,7 +1032,7 @@ type gc_playerLv = k_v<{
'tujianlv': number 'tujianlv': number
}>; }>;
type gc_playerModel = k_v<k_v<{ type gc_playerModel = k_v<{
/** 类型 */ /** 类型 */
'type': number 'type': number
/** id */ /** id */
@ -1057,7 +1057,7 @@ type gc_playerModel = k_v<k_v<{
'mwSpine': string 'mwSpine': string
/** 战斗半身像 */ /** 战斗半身像 */
'fireHead': string 'fireHead': string
}>>; }>;
type gc_pmd = { "get_hero_star5_pmd": string, "glkb_pmd": string, "jinjie_peijian": string, "guild_pmd": string, "tlsd_pmd": string, "hbzb_pmd1": string, "hbzb_pmd2": string, "hbzb_pmd3": string, [x: string]: any } type gc_pmd = { "get_hero_star5_pmd": string, "glkb_pmd": string, "jinjie_peijian": string, "guild_pmd": string, "tlsd_pmd": string, "hbzb_pmd1": string, "hbzb_pmd2": string, "hbzb_pmd3": string, [x: string]: any }

View File

@ -0,0 +1,18 @@
import { StringTypeSchema } from "tsbuffer-schema";
/**
*
*/
export type Reqheapdump = {
act:string,
data:any
};
export type Resheapdump = {
/**
*
*/
code: number
data: any;
};

View File

@ -1,6 +1,7 @@
import { ServiceProto } from 'tsrpc-proto'; import { ServiceProto } from 'tsrpc-proto';
import { Reqsendemail, Ressendemail } from './email/Ptlsendemail'; import { Reqsendemail, Ressendemail } from './email/Ptlsendemail';
import { Reqdeploy, Resdeploy } from './games/Ptldeploy'; import { Reqdeploy, Resdeploy } from './games/Ptldeploy';
import { Reqheapdump, Resheapdump } from './games/Ptlheapdump';
import { Reqmetrics, Resmetrics } from './games/Ptlmetrics'; import { Reqmetrics, Resmetrics } from './games/Ptlmetrics';
import { Reqnotification, Resnotification } from './games/Ptlnotification'; import { Reqnotification, Resnotification } from './games/Ptlnotification';
import { Reqopen, Resopen } from './games/Ptlopen'; import { Reqopen, Resopen } from './games/Ptlopen';
@ -31,6 +32,10 @@ export interface ServiceType {
req: Reqdeploy, req: Reqdeploy,
res: Resdeploy res: Resdeploy
}, },
"games/heapdump": {
req: Reqheapdump,
res: Resheapdump
},
"games/metrics": { "games/metrics": {
req: Reqmetrics, req: Reqmetrics,
res: Resmetrics res: Resmetrics
@ -127,96 +132,101 @@ export const serviceProto: ServiceProto<ServiceType> = {
}, },
{ {
"id": 2, "id": 2,
"name": "games/metrics", "name": "games/heapdump",
"type": "api" "type": "api"
}, },
{ {
"id": 3, "id": 3,
"name": "games/notification", "name": "games/metrics",
"type": "api" "type": "api"
}, },
{ {
"id": 4, "id": 4,
"name": "games/open", "name": "games/notification",
"type": "api" "type": "api"
}, },
{ {
"id": 5, "id": 5,
"name": "games/ranking", "name": "games/open",
"type": "api" "type": "api"
}, },
{ {
"id": 6, "id": 6,
"name": "gift/popup", "name": "games/ranking",
"type": "api" "type": "api"
}, },
{ {
"id": 7, "id": 7,
"name": "gm/Pay", "name": "gift/popup",
"type": "api" "type": "api"
}, },
{ {
"id": 8, "id": 8,
"name": "gm/SendPrize", "name": "gm/Pay",
"type": "api" "type": "api"
}, },
{ {
"id": 9, "id": 9,
"name": "hdinfo/details", "name": "gm/SendPrize",
"type": "api" "type": "api"
}, },
{ {
"id": 10, "id": 10,
"name": "AddHuoDong", "name": "hdinfo/details",
"type": "api" "type": "api"
}, },
{ {
"id": 11, "id": 11,
"name": "CatAllhd", "name": "AddHuoDong",
"type": "api" "type": "api"
}, },
{ {
"id": 12, "id": 12,
"name": "DelHuoDong", "name": "CatAllhd",
"type": "api" "type": "api"
}, },
{ {
"id": 13, "id": 13,
"name": "Email", "name": "DelHuoDong",
"type": "api" "type": "api"
}, },
{ {
"id": 14, "id": 14,
"name": "GetLog", "name": "Email",
"type": "api" "type": "api"
}, },
{ {
"id": 15, "id": 15,
"name": "healthz", "name": "GetLog",
"type": "api" "type": "api"
}, },
{ {
"id": 16, "id": 16,
"name": "union/rename", "name": "healthz",
"type": "api" "type": "api"
}, },
{ {
"id": 17, "id": 17,
"name": "user/data", "name": "union/rename",
"type": "api" "type": "api"
}, },
{ {
"id": 18, "id": 18,
"name": "user/disable", "name": "user/data",
"type": "api" "type": "api"
}, },
{ {
"id": 19, "id": 19,
"name": "user/getdata", "name": "user/disable",
"type": "api" "type": "api"
}, },
{ {
"id": 20, "id": 20,
"name": "user/getdata",
"type": "api"
},
{
"id": 21,
"name": "user/rename", "name": "user/rename",
"type": "api" "type": "api"
} }
@ -367,6 +377,44 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
] ]
}, },
"games/Ptlheapdump/Reqheapdump": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "act",
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "data",
"type": {
"type": "Any"
}
}
]
},
"games/Ptlheapdump/Resheapdump": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "code",
"type": {
"type": "Number"
}
},
{
"id": 1,
"name": "data",
"type": {
"type": "Any"
}
}
]
},
"games/Ptlmetrics/Reqmetrics": { "games/Ptlmetrics/Reqmetrics": {
"type": "Interface" "type": "Interface"
}, },
@ -2145,6 +2193,29 @@ export const serviceProto: ServiceProto<ServiceType> = {
}, },
{ {
"id": 5, "id": 5,
"name": "upModel",
"type": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "id",
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "time",
"type": {
"type": "Number"
}
}
]
}
},
{
"id": 6,
"name": "model", "name": "model",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2173,14 +2244,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 6, "id": 7,
"name": "renown", "name": "renown",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 7, "id": 8,
"name": "wxcLv", "name": "wxcLv",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2206,14 +2277,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 8, "id": 9,
"name": "mapId", "name": "mapId",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 9, "id": 10,
"name": "shoucangping", "name": "shoucangping",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2226,14 +2297,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 10, "id": 11,
"name": "useTujianLvPoint", "name": "useTujianLvPoint",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 11, "id": 12,
"name": "skills", "name": "skills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2246,7 +2317,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 12, "id": 13,
"name": "fightSkills", "name": "fightSkills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2259,7 +2330,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 13, "id": 14,
"name": "heroPos", "name": "heroPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2272,21 +2343,21 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 14, "id": 15,
"name": "ghId", "name": "ghId",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 15, "id": 16,
"name": "ghName", "name": "ghName",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 16, "id": 17,
"name": "ghLevel", "name": "ghLevel",
"type": { "type": {
"type": "Reference", "type": "Reference",
@ -2294,7 +2365,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 17, "id": 18,
"name": "ghwz", "name": "ghwz",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2308,7 +2379,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 18, "id": 19,
"name": "ghExitTime", "name": "ghExitTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2316,7 +2387,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 19, "id": 20,
"name": "loginTime", "name": "loginTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2324,7 +2395,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 20, "id": 21,
"name": "logoutTime", "name": "logoutTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2332,7 +2403,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 21, "id": 22,
"name": "cTime", "name": "cTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2340,7 +2411,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 22, "id": 23,
"name": "loginDays", "name": "loginDays",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2348,7 +2419,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 23, "id": 24,
"name": "serverName", "name": "serverName",
"type": { "type": {
"type": "String" "type": "String"
@ -2356,7 +2427,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 24, "id": 25,
"name": "sid", "name": "sid",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2364,7 +2435,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 25, "id": 26,
"name": "onlineTime", "name": "onlineTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2372,7 +2443,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 26, "id": 27,
"name": "newonlinetime", "name": "newonlinetime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2380,7 +2451,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 27, "id": 28,
"name": "isNpc", "name": "isNpc",
"type": { "type": {
"type": "Boolean" "type": "Boolean"
@ -2388,7 +2459,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 28, "id": 29,
"name": "matrix", "name": "matrix",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2402,7 +2473,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 29, "id": 30,
"name": "matrixPos", "name": "matrixPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2422,7 +2493,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 30, "id": 31,
"name": "selectMatrix", "name": "selectMatrix",
"type": { "type": {
"type": "String" "type": "String"
@ -2430,7 +2501,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 31, "id": 32,
"name": "fightHeros", "name": "fightHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -2441,7 +2512,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 32, "id": 33,
"name": "helpHeros", "name": "helpHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -2518,7 +2589,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 33, "id": 34,
"name": "changeNameNum", "name": "changeNameNum",
"type": { "type": {
"type": "Number" "type": "Number"
@ -2526,7 +2597,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 34, "id": 35,
"name": "peijianUnlock", "name": "peijianUnlock",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2540,7 +2611,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 35, "id": 36,
"name": "headFrames", "name": "headFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -2554,7 +2625,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 36, "id": 37,
"name": "chatFrames", "name": "chatFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",

View File

@ -0,0 +1,35 @@
import {ctor} from "./global";
import {initMongoDB} from "./setMongodb";
async function start() {
await initMongoDB()
// 刷新活动配置
console.log(`修复玩家model数据开始...`);
await G.mongodb.collection("user").updateMany({},{
$set:{
upModel:{id: "1", time: -1},
model: {
'1': {id: "1", time: -1},
'2': {id: "2", time: -1}
}
}
})
console.log(`修复玩家model数据完成...`);
}
ctor();
start().then(() => {
let s = 0;
setInterval(() => {
s += 1;
console.log(new Date().format("MM-dd hh:mm:ss"));
if (s >= 3) process.exit(1);
}, 1000)
console.log("逻辑执行完成...等待退出!!!");
});

121
src/path_20231221.ts Normal file
View File

@ -0,0 +1,121 @@
import {ctor} from "./global";
import {initMongoDB} from "./setMongodb";
import {yangchengmubiao} from "./shared/protocols/event/yangchengmubiao/PtlOpen";
async function start() {
await initMongoDB()
const hdid = [100, 101];
const task = {
'2001': {
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 50,
'cond': [],
'stype': 118
},
'2002': {
'prize': [{'a': 'item', 't': '4', 'n': 5}, {'a': 'item', 't': '626', 'n': 10}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 100,
'cond': [],
'stype': 118
},
'2003': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '626', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 200,
'cond': [],
'stype': 118
},
'2004': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 250,
'cond': [],
'stype': 118
},
'2005': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '600', 'n': 20}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 300,
'cond': [],
'stype': 118
},
'2006': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 400,
'cond': [],
'stype': 118
},
'2007': {
'prize': [{'a': 'item', 't': '4', 'n': 10}, {'a': 'item', 't': '619', 'n': 1}],
'tujing': '',
'title': 'intr_yczm_day_des_2',
'type': 2,
'pval': 500,
'cond': [],
'stype': 118
}
};
// 中间插入了2004 所以之前的任务id一次往后顺延
const change = {2004: 2005, 2005: 2006, 2006: 2007};
// 刷新活动配置
await G.mongodb.collection("hdinfo").updateMany({hdid: {$in: hdid}}, {
"$set": {'data.tasklist.2': task}
})
let datas: yangchengmubiao[] = [];
// 刷新玩家领取记录
datas = datas.concat(await G.mongodb.cEvent(`yangchengmubiao${hdid[0]}`).find(
{type: `yangchengmubiao${hdid[0]}`}
).toArray());
datas = datas.concat(await G.mongodb.cEvent(`yangchengmubiao${hdid[1]}`).find(
{type: `yangchengmubiao${hdid[1]}`}
).toArray());
for (let i = 0; i < datas.length; i++) {
let data = datas[i];
let finished = data.finishid["2"].map((task) => {
return change[task] ? change[task] : task
});
let maxtaskval = Math.max(...Object.values(data.taskval));
let taskval = {};
for (let taskid in task) {
taskval[taskid] = maxtaskval;
}
await G.mongodb.collection("event").updateOne(
{uid: data.uid, type: data.type}, {$set: {taskval: taskval, "finishid.2": finished}}
)
console.log(`修复玩家${data.uid}人才计划数据完成...`);
}
}
ctor();
start().then(() => {
let s = 0;
setInterval(() => {
s += 1;
console.log(new Date().format("MM-dd hh:mm:ss"));
if (s >= 3) process.exit(1);
}, 1000)
console.log("逻辑执行完成...等待退出!!!");
});

View File

@ -54,7 +54,6 @@ export class HuoDongFun {
if (htype != 0) _where["htype"] = htype if (htype != 0) _where["htype"] = htype
let _res = await this.catAllHD(_where) let _res = await this.catAllHD(_where)
let result = [] let result = []
for (let index = 0; index < _res.length; index++) { for (let index = 0; index < _res.length; index++) {
const element = _res[index]; const element = _res[index];

View File

@ -10,6 +10,7 @@ import {call, PlayerFun} from './player';
import {number} from "mathjs"; import {number} from "mathjs";
import {getGud} from './gud'; import {getGud} from './gud';
import {getConf as zmlbGetConf} from '../api_s2c/event/zhoumolibao/ApiOpen'; import {getConf as zmlbGetConf} from '../api_s2c/event/zhoumolibao/ApiOpen';
import {Christmasfun} from "../api_s2c/event/christmas/fun";
async function checkPayIsActive(payId: string, logs: payLog[], payArgs) { async function checkPayIsActive(payId: string, logs: payLog[], payArgs) {
let conf: any = await this.getConf(payId, payArgs); let conf: any = await this.getConf(payId, payArgs);
@ -177,6 +178,7 @@ export class PayFun {
if (payed) { if (payed) {
console.log(uid, payId, payArgs, orderNo); console.log(uid, payId, payArgs, orderNo);
console.log('订单号已存在'); console.log('订单号已存在');
return;
} }
} }
@ -230,16 +232,21 @@ export class PayFun {
let conf = await zmlbGetConf(call, {payId}) let conf = await zmlbGetConf(call, {payId})
prize.push(...conf.prize) prize.push(...conf.prize)
} }
//圣诞节活动充值
try{
await Christmasfun.payChristmas(payId, call);
}catch (e) {
console.log("Christmasfun.payChristmas Error",e);
}
let isReplaceConf = await this.checkBuysAfterPay(uid, payId, conf, payArgs, player) let isReplaceConf = await this.checkBuysAfterPay(uid, payId, conf, payArgs, player)
if (isReplaceConf) { if (isReplaceConf) {
let prizePayId = `zuanshi_${conf.money}` let prizePayId = `zuanshi_${conf.money}`
payArgs.toPrizePayId = prizePayId payArgs.toPrizePayId = prizePayId
conf = this.replacePrizeToChongzhi(prizePayId, conf) conf = this.replacePrizeToChongzhi(prizePayId, conf)
prize = [...conf.prize] prize = conf.prize;
} }
await PlayerFun.sendPrize(call, prize); await PlayerFun.sendPrize(call, prize);
await PlayerFun.addAttr(call, conf.payExp); await PlayerFun.addAttr(call, conf.payExp);
if (payId == 'G123SendGift') { if (payId == 'G123SendGift') {
@ -285,7 +292,7 @@ export class PayFun {
* @param payId * @param payId
* @param conf * @param conf
*/ */
static async replacePrizeToChongzhi(payId, conf) { static replacePrizeToChongzhi(payId, conf) {
return { return {
id: payId, id: payId,
money: conf.money, money: conf.money,

View File

@ -169,6 +169,15 @@ export class PlayerFun {
change[atn.t] = this.fixAttrLteZero(atn.t, await this.getAtnNum(call, atn) + atn.n); change[atn.t] = this.fixAttrLteZero(atn.t, await this.getAtnNum(call, atn) + atn.n);
if (atn.t == 'rmbmoney') { if (atn.t == 'rmbmoney') {
this.changeAttrLog(call.conn.uid, change[atn.t], atn, call.conn.gud.rmbmoney) this.changeAttrLog(call.conn.uid, change[atn.t], atn, call.conn.gud.rmbmoney)
// 扣除钻石时
if (atn.n < 0) {
// 监听任务消耗任务
G.emit("Class_task_156", 'Class_task_156', call, -atn.n, 0);
}
}
// 增加vip经验的任务监听
if (atn.t == "payExp" && atn.n > 0) {
G.emit("Class_task_157", 'Class_task_157', call, atn.n, 0);
} }
all.push(this.changeAttr(call.conn.uid, change)); all.push(this.changeAttr(call.conn.uid, change));
all.push(this.upAttr(call, {...atn, n: change[atn.t]})); all.push(this.upAttr(call, {...atn, n: change[atn.t]}));

View File

@ -22,12 +22,15 @@ export class CrossEmailPull extends Scheduler {
G.clientCross.callApi("email/GetCrossEmail", {server_id: G.config.serverId + ""}).then((res) => { G.clientCross.callApi("email/GetCrossEmail", {server_id: G.config.serverId + ""}).then((res) => {
if (!res.isSucc) return; if (!res.isSucc) return;
res.res.emails.forEach(async (email) => { res.res.emails.forEach(async (email) => {
let _prize = R.clone(email?.prizeData?.prize) || [];
if (email?.prizeData) delete email.prizeData;
email["prize"] = _prize;
if (email.uid != "system") { if (email.uid != "system") {
await EmailFun.addEmail(email) await EmailFun.addEmail(email)
} else { } else {
await EmailFun.addQuanFuEmail(email) await EmailFun.addQuanFuEmail(email)
} }
await EmailFun.addEmail(email)
}) })
if (res.res.emails.length > 0) { if (res.res.emails.length > 0) {
G.clientCross.callApi("email/DelCrossEmail", {eids: res.res.emails.map(e => e._id)}) G.clientCross.callApi("email/DelCrossEmail", {eids: res.res.emails.map(e => e._id)})

View File

@ -102,9 +102,10 @@ export class SchedulerWzryDlDjinji extends SchedulerWzryAutoBaoMing {
return return
} }
let _zuanshiUser = await getRankList(null,{ let _zuanshiUser = await getRankList(256,{
'data.player.uid':1 'data.player.uid':1
}); //Rank.list.wzryCross.getRankListAll() },{'data.player.isNpc':{$exists:false}});
if (_zuanshiUser.length < 256) { if (_zuanshiUser.length < 256) {
console.log("本期无玩家,此次不执行") console.log("本期无玩家,此次不执行")
await this.record() await this.record()
@ -117,10 +118,10 @@ export class SchedulerWzryDlDjinji extends SchedulerWzryAutoBaoMing {
for (let index = 0; index < _zuanshiUser.length; index++) { for (let index = 0; index < _zuanshiUser.length; index++) {
const element = _zuanshiUser[index]; const element = _zuanshiUser[index];
_userList.push(element.player.uid) _userList.push(element.player.uid)
if (element.player.uid.indexOf('npc_') != -1) { // if (element.player.uid.indexOf('npc_') != -1) {
if (_userList.length >= 256) break // if (_userList.length >= 256) break
continue // continue
} // }
// 发送晋级钻石赛奖励 // 发送晋级钻石赛奖励
prize.length > 0 && EmailFun.addEmail({ prize.length > 0 && EmailFun.addEmail({
uid: element.player.uid, uid: element.player.uid,

View File

@ -788,7 +788,7 @@ export class TaskAllEmitFun {
let _val = node.call.req.num; let _val = node.call.req.num;
G.emit("Class_task_136", 'Class_task_136', node.call, _val, 0); G.emit("Class_task_136", 'Class_task_136', node.call, _val, 0);
// todo 统计藏品修复胶此处只是临时处理防止线上任务数据出错正确做法是统计修复胶的消耗走136任务的统计 // todo 统计藏品修复胶此处只是临时处理防止线上任务数据出错正确做法是统计修复胶的消耗走136任务的统计
G.emit("Class_task_134", 'Class_task_134', node.call, _val, 0, {}); G.emit("Class_task_134", 'Class_task_134', node.call, _val, 0, []);
} }
if (node.call.service.name == 'peijian/LvUp' && node.return.isSucc) { if (node.call.service.name == 'peijian/LvUp' && node.return.isSucc) {

View File

@ -390,7 +390,10 @@ export module manager {
async initVal(call: ApiCall, con) { async initVal(call: ApiCall, con) {
const data = await TanXianFun.getData(call); const data = await TanXianFun.getData(call);
return data.useFastGuaJiNum || 0 if (data?.resetTime > PublicShared.getToDayZeroTime()) {
return data.useFastGuaJiNum || 0
}
return 0
} }
} }
@ -401,7 +404,10 @@ export module manager {
async initVal(call: ApiCall, con) { async initVal(call: ApiCall, con) {
let data = await JJCFun.getData(call); let data = await JJCFun.getData(call);
return data?.useFightNum || 0 if (data?.resetTime >= PublicShared.getToDayZeroTime()) {
return data?.useFightNum || 0
}
return 0
} }
} }
@ -418,7 +424,10 @@ export module manager {
async initVal(call: ApiCall, con) { 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'});
return R.compose(R.sum(), R.map(i => i[0].useFightNum), R.values())(myData.data.numInfo) || 0 if (myData.data.refreshTime > PublicShared.getToDayZeroTime()) {
return R.compose(R.sum(), R.map(i => i[0].useFightNum), R.values())(myData.data.numInfo) || 0
}
return 0
} }
} }
@ -435,7 +444,10 @@ export module manager {
async initVal(call: ApiCall, con) { 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'});
return myData.useFightNum || 0 if (myData?.refreFightTime > PublicShared.getToDayZeroTime()) {
return myData?.useFightNum || 0
}
return 0
} }
} }
@ -491,7 +503,10 @@ export module manager {
async initVal(call: ApiCall, con) { async initVal(call: ApiCall, con) {
let data: Partial<CollectionWanted> = await G.mongodb.collection('wanted').findOne({uid: call.uid}) || {}; let data: Partial<CollectionWanted> = await G.mongodb.collection('wanted').findOne({uid: call.uid}) || {};
return data.toDayUseNum || 0 if (data.refreshTime > PublicShared.getToDayZeroTime()) {
return data.toDayUseNum || 0
}
return 0
} }
} }
@ -766,24 +781,44 @@ export module manager {
return call.conn.gud?.helpHeros?.length || 0; return call.conn.gud?.helpHeros?.length || 0;
} }
} }
// 第56个任务 完成圣诞活动小游戏 // 第56个任务 完成圣诞活动小游戏
export class Class_task_154 extends BaseClass { export class Class_task_154 extends BaseClass {
stype = 154 stype = 154
isinc = 1 isinc = 1
async initVal(call: ApiCall, con) { async initVal(call: ApiCall, con) {
return 1; return 0;
} }
} }
// 第57个任务 领取每日任务最终宝箱 // 第57个任务 领取每日任务最终宝箱
export class Class_task_155 extends BaseClass { export class Class_task_155 extends BaseClass {
stype = 155 stype = 155
isinc = 0 isinc = 0
async initVal(call: ApiCall, con) {
return 0;
}
}
// 第58个任务 每日钻石消耗
export class Class_task_156 extends BaseClass {
stype = 156
isinc = 1
async initVal(call: ApiCall, con) { async initVal(call: ApiCall, con) {
return 1; return 1;
} }
} }
// 第59个任务 获得vip经验
export class Class_task_157 extends BaseClass {
stype = 157
isinc = 1
async initVal(call: ApiCall, con) {
return 0;
}
}
} }

View File

@ -1,14 +1,14 @@
import CryptoJS from 'crypto-js'; import CryptoJS from 'crypto-js';
import { ObjectId, OptionalId, WithId } from 'mongodb'; import {ObjectId, OptionalId, WithId} from 'mongodb';
import { BaseConnection } from 'tsrpc'; import {BaseConnection} from 'tsrpc';
import { Wjjl } from '../module/collection_wjjl'; import {Wjjl} from '../module/collection_wjjl';
import { ServiceType } from '../shared/protocols/serviceProto'; import {ServiceType} from '../shared/protocols/serviceProto';
import { ReqLogin, ResLogin, playerAppend, playerAttr, playerInfo } from '../shared/protocols/user/PtlLogin'; import {ReqLogin, ResLogin, playerAppend, playerAttr, playerInfo} from '../shared/protocols/user/PtlLogin';
import { player } from '../shared/protocols/user/type'; import {player} from '../shared/protocols/user/type';
import { PublicShared } from '../shared/public/public'; import {PublicShared} from '../shared/public/public';
import { PlayerFun } from './player'; import {PlayerFun} from './player';
import { ZhanLingTasks } from './zhanling'; import {ZhanLingTasks} from './zhanling';
import { getGud, setGud } from './gud'; import {getGud, setGud} from './gud';
export const defaultUserInfo: playerInfo = { export const defaultUserInfo: playerInfo = {
lv: 1, lv: 1,
@ -30,14 +30,13 @@ export const defaultUserAttr: playerAttr = {
export const defaultUserAppend: playerAppend = { export const defaultUserAppend: playerAppend = {
name: '', name: '',
tujianLv: 0, tujianLv: 0,
head: { id: "1", time: -1 }, head: {id: "1", time: -1},
headFrame: { id: "1", time: -1 }, headFrame: {id: "1", time: -1},
chatFrame: { id: "1", time: -1 }, chatFrame: {id: "1", time: -1},
upModel: {id: "1", time: -1},
model: { model: {
1: { id: "1", time: -1 }, 1: {id: "1", time: -1},
2: { id: "1", time: -1 }, 2: {id: "2", time: -1}
3: { id: "1", time: -1 },
4: { id: "1", time: -1 },
}, },
renown: 0, renown: 0,
wxcLv: { wxcLv: {
@ -60,12 +59,12 @@ export const defaultUserAppend: playerAppend = {
ghId: '', ghId: '',
ghName: '', ghName: '',
ghLevel: 0, ghLevel: 0,
ghwz: { 1: 0, 2: 0, 3: 0, 4: 0 } ghwz: {1: 0, 2: 0, 3: 0, 4: 0}
}; };
export class UserFun { export class UserFun {
static create(bUid: string) { static create(bUid: string) {
let { bindUid, ...userInfo } = defaultUserInfo; let {bindUid, ...userInfo} = defaultUserInfo;
return { return {
bindUid: bUid, bindUid: bUid,
@ -73,6 +72,7 @@ export class UserFun {
...defaultUserAttr ...defaultUserAttr
}; };
} }
static async check(gud: ResLogin['gud'], req: ReqLogin) { static async check(gud: ResLogin['gud'], req: ReqLogin) {
let obj: k_v<any> = {}; let obj: k_v<any> = {};
let add: k_v<any> = {}; let add: k_v<any> = {};
@ -126,14 +126,14 @@ export class UserFun {
if (h_ids.length < 1) { if (h_ids.length < 1) {
gud.fightHeros = []; gud.fightHeros = [];
} else { } else {
let dHeros = await G.mongodb.collection('hero').find({ _id: { $in: h_ids.map(id => G.mongodb.conversionId(id)) } }).toArray(); let dHeros = await G.mongodb.collection('hero').find({_id: {$in: h_ids.map(id => G.mongodb.conversionId(id))}}).toArray();
gud.fightHeros = dHeros.map(h => h.heroId.toString()); gud.fightHeros = dHeros.map(h => h.heroId.toString());
} }
add.fightHeros = gud.fightHeros; add.fightHeros = gud.fightHeros;
} }
if (!gud.matrixPos) { if (!gud.matrixPos) {
gud.matrixPos = Object.fromEntries(Object.keys(G.gc.fightPlan).map(pos => [pos, { ...gud.heroPos }])); gud.matrixPos = Object.fromEntries(Object.keys(G.gc.fightPlan).map(pos => [pos, {...gud.heroPos}]));
add.matrixPos = gud.matrixPos; add.matrixPos = gud.matrixPos;
} }
@ -197,7 +197,7 @@ export class UserFun {
add.loginTime = G.time; add.loginTime = G.time;
if (Object.keys(add).length > 0) { if (Object.keys(add).length > 0) {
G.mongodb.collection('user').updateOne({ bindUid: gud.bindUid,sid:gud.sid }, { G.mongodb.collection('user').updateOne({bindUid: gud.bindUid, sid: gud.sid}, {
$set: { $set: {
...add ...add
} }
@ -211,24 +211,25 @@ export class UserFun {
return obj; return obj;
} }
// 检查空数据并修复 // 检查空数据并修复
static async checkUidOrName() { static async checkUidOrName() {
let users = await G.mongodb.collection('user').findOne({$or: [{uid: {$in:['', null]}},{name: {$in: ['', null]}}]}) let users = await G.mongodb.collection('user').findOne({$or: [{uid: {$in: ['', null]}}, {name: {$in: ['', null]}}]})
if(users) { if (users) {
let {bindUid, sid, _id} = users let {bindUid, sid, _id} = users
let uid = users.uid || (sid + '_' + _id) let uid = users.uid || (sid + '_' + _id)
// 随机创建name // 随机创建name
let b64 = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(bindUid + sid)); let b64 = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(bindUid + sid));
let name = users.name || `temp_${b64}`.toLocaleLowerCase(); let name = users.name || `temp_${b64}`.toLocaleLowerCase();
await G.mongodb.collection('user').updateOne({ bindUid, sid }, { await G.mongodb.collection('user').updateOne({bindUid, sid}, {
$set: { $set: {
uid, name uid, name
} }
}); });
} }
return return
} }
/**创建账号数据 */ /**创建账号数据 */
static async createUser(client: BaseConnection<ServiceType>, bindUid: string, sid: number): Promise<WithId<OptionalId<ResLogin['gud']>>> { static async createUser(client: BaseConnection<ServiceType>, bindUid: string, sid: number): Promise<WithId<OptionalId<ResLogin['gud']>>> {
// 开启事务 // 开启事务
@ -258,14 +259,17 @@ export class UserFun {
// session.endSession() // 结束事务 // session.endSession() // 结束事务
return gud as WithId<OptionalId<ResLogin['gud']>>; return gud as WithId<OptionalId<ResLogin['gud']>>;
} }
/**获取玩家附带的buff加成 */ /**获取玩家附带的buff加成 */
static getOtherBuff(gud: ResLogin['gud']) { static getOtherBuff(gud: ResLogin['gud']) {
return gud; return gud;
} }
static async getGud(uid: string) { static async getGud(uid: string) {
//return await G.redis.get('user', uid); //return await G.redis.get('user', uid);
return await getGud(uid); return await getGud(uid);
} }
/**激活头像框 */ /**激活头像框 */
static async activeHeadFrame(uid: string, k: string, v: number) { static async activeHeadFrame(uid: string, k: string, v: number) {
let gud: player; let gud: player;
@ -312,11 +316,12 @@ export class UserFun {
} }
if (change) { if (change) {
PlayerFun.changeAttr(uid, { headFrames: gud.headFrames }); PlayerFun.changeAttr(uid, {headFrames: gud.headFrames});
G.server.sendMsgByUid(uid, 'msg_s2c/PlayerChange', { headFrames: gud.headFrames }); G.server.sendMsgByUid(uid, 'msg_s2c/PlayerChange', {headFrames: gud.headFrames});
G.server.uid_connections[uid]?.refreshPower(); G.server.uid_connections[uid]?.refreshPower();
} }
} }
/**激活聊天框 */ /**激活聊天框 */
static async activeChatFrame(uid: string, k: string, v: number) { static async activeChatFrame(uid: string, k: string, v: number) {
let gud: player; let gud: player;
@ -363,8 +368,60 @@ export class UserFun {
} }
if (change) { if (change) {
PlayerFun.changeAttr(uid, { chatFrames: gud.chatFrames }); PlayerFun.changeAttr(uid, {chatFrames: gud.chatFrames});
G.server.sendMsgByUid(uid, 'msg_s2c/PlayerChange', { chatFrames: gud.chatFrames }); G.server.sendMsgByUid(uid, 'msg_s2c/PlayerChange', {chatFrames: gud.chatFrames});
G.server.uid_connections[uid]?.refreshPower();
}
}
/**激活造型 */
static async activeModel(uid: string, k: string, v: number) {
let gud: player;
// if (G.server.uid_connections[uid]) {
// gud = G.server.uid_connections[uid].gud;
// } else {
// gud = await G.redis.get('user', uid);
// }
gud = await getGud(uid);
let change = false;
let model = G.gc.playerModel;
let checks = Object.values(model).filter(v => v.cond[0] == k);
if (checks.length > 0) {
checks.forEach(conf => {
let val = v;
if (k == 'wxcLv') val = gud.wxcLv.lv;
else if (gud[k] != undefined) val = gud[k];
if (k == 'jjc_rank' && !gud.model[conf.id] && val <= conf.cond[1]) {
gud.model[conf.id] = {id: conf.id + '', time: -1};
change = true;
} else if (!gud.model[conf.id] && val >= conf.cond[1]) {
gud.model[conf.id] = {id: conf.id + '', time: -1};
change = true;
}
});
} else {
let conf = model[k];
if (conf?.cond?.[0] == 'time') {
let val = conf.cond[1];
if (val == -1) {
change = true;
gud.model[conf.id] = {id: conf.id + '', time: -1};
} else if (gud.model[conf.id].time < G.time) {
change = true;
gud.model[conf.id] = {id: conf.id + '', time: G.time + val * v};
} else {
change = true;
gud.model[conf.id] = {id: conf.id + '', time: gud.model[conf.id].time += val * v}
}
}
}
if (change) {
PlayerFun.changeAttr(uid, {model: gud.model});
G.server.sendMsgByUid(uid, 'msg_s2c/PlayerChange', {model: gud.model});
G.server.uid_connections[uid]?.refreshPower(); G.server.uid_connections[uid]?.refreshPower();
} }
} }

View File

@ -10,7 +10,8 @@ export async function createHttp() {
json: true, json: true,
cors: '*', cors: '*',
port: G.config.httpPort, port: G.config.httpPort,
logLevel: G.argv.logModel as LogLevel logLevel: G.argv.logModel as LogLevel,
apiTimeout:300000,
}); });
setHttp(G.http); setHttp(G.http);
await G.http.autoImplementApi(resolve(__dirname, 'api_o2s'), true); await G.http.autoImplementApi(resolve(__dirname, 'api_o2s'), true);

View File

@ -37,7 +37,7 @@ export function getFightDPS(fromRole: FightObj, toRole: FightObj, extData: DPS_E
* *
0.9-1.11 -1010 0.9-1.11 -1010
*/ */
if (fromRole.isDead || toRole.isDead) return { num: 0, dps: 0, miss: false, baoji: false, fromRole: fromRole, toRole: toRole }; if (fromRole.isDead || toRole.isDead) return { num: 0, dps: 0, miss: false, baoji: false, fromRole: fromRole, toRole: toRole };
let miss = false, baoji = false, dps = 0; let miss = false, baoji = false, dps = 0;
let fromRoleLv = fromRole.getData('lv'), toRoleLv = toRole.getData('lv'); let fromRoleLv = fromRole.getData('lv'), toRoleLv = toRole.getData('lv');
@ -182,6 +182,18 @@ export function getBuffDPS(toRole: FightObj, fromRole: FightObj, extData: { xiao
// todo 主角技能还没有限制百分比的最大伤害以下判断修复技能buff没有伤害 // todo 主角技能还没有限制百分比的最大伤害以下判断修复技能buff没有伤害
if (fromRole.getData('pos') != 7){ if (fromRole.getData('pos') != 7){
dps = dps > maxDps ? maxDps : dps; dps = dps > maxDps ? maxDps : dps;
} else {
// 主角技能伤害最大值: avg(所有上场干部的maxDps) * 2
let sumHeroMaxDps = 0, heroCount = 0;
const fromRoleSide = fromRole.getData('side');
fromRole.fightControl.fightRolesArr.forEach(role => {
if (role.getData('pos') < 7 && role.getData('side') === fromRoleSide) {
sumHeroMaxDps += role.getData('maxdps');
heroCount++;
}
});
maxDps = sumHeroMaxDps / heroCount * 2;
dps = dps > maxDps ? maxDps : dps;
} }
return { num: -dps, dps: -dps, miss: miss, baoji: baoji, fromRole: fromRole, toRole: toRole }; return { num: -dps, dps: -dps, miss: miss, baoji: baoji, fromRole: fromRole, toRole: toRole };

View File

@ -3954,6 +3954,29 @@ export const serviceProto: ServiceProto<ServiceType> = {
}, },
{ {
"id": 5, "id": 5,
"name": "upModel",
"type": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "id",
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "time",
"type": {
"type": "Number"
}
}
]
}
},
{
"id": 6,
"name": "model", "name": "model",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -3982,14 +4005,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 6, "id": 7,
"name": "renown", "name": "renown",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 7, "id": 8,
"name": "wxcLv", "name": "wxcLv",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4015,14 +4038,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 8, "id": 9,
"name": "mapId", "name": "mapId",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 9, "id": 10,
"name": "shoucangping", "name": "shoucangping",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4035,14 +4058,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 10, "id": 11,
"name": "useTujianLvPoint", "name": "useTujianLvPoint",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 11, "id": 12,
"name": "skills", "name": "skills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4055,7 +4078,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 12, "id": 13,
"name": "fightSkills", "name": "fightSkills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4068,7 +4091,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 13, "id": 14,
"name": "heroPos", "name": "heroPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4081,21 +4104,21 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 14, "id": 15,
"name": "ghId", "name": "ghId",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 15, "id": 16,
"name": "ghName", "name": "ghName",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 16, "id": 17,
"name": "ghLevel", "name": "ghLevel",
"type": { "type": {
"type": "Reference", "type": "Reference",
@ -4103,7 +4126,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 17, "id": 18,
"name": "ghwz", "name": "ghwz",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4117,7 +4140,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 18, "id": 19,
"name": "ghExitTime", "name": "ghExitTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4125,7 +4148,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 19, "id": 20,
"name": "loginTime", "name": "loginTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4133,7 +4156,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 20, "id": 21,
"name": "logoutTime", "name": "logoutTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4141,7 +4164,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 21, "id": 22,
"name": "cTime", "name": "cTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4149,7 +4172,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 22, "id": 23,
"name": "loginDays", "name": "loginDays",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4157,7 +4180,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 23, "id": 24,
"name": "serverName", "name": "serverName",
"type": { "type": {
"type": "String" "type": "String"
@ -4165,7 +4188,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 24, "id": 25,
"name": "sid", "name": "sid",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4173,7 +4196,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 25, "id": 26,
"name": "onlineTime", "name": "onlineTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4181,7 +4204,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 26, "id": 27,
"name": "newonlinetime", "name": "newonlinetime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4189,7 +4212,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 27, "id": 28,
"name": "isNpc", "name": "isNpc",
"type": { "type": {
"type": "Boolean" "type": "Boolean"
@ -4197,7 +4220,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 28, "id": 29,
"name": "matrix", "name": "matrix",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4211,7 +4234,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 29, "id": 30,
"name": "matrixPos", "name": "matrixPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4231,7 +4254,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 30, "id": 31,
"name": "selectMatrix", "name": "selectMatrix",
"type": { "type": {
"type": "String" "type": "String"
@ -4239,7 +4262,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 31, "id": 32,
"name": "fightHeros", "name": "fightHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -4250,7 +4273,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 32, "id": 33,
"name": "helpHeros", "name": "helpHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -4327,7 +4350,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 33, "id": 34,
"name": "changeNameNum", "name": "changeNameNum",
"type": { "type": {
"type": "Number" "type": "Number"
@ -4335,7 +4358,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 34, "id": 35,
"name": "peijianUnlock", "name": "peijianUnlock",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4349,7 +4372,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 35, "id": 36,
"name": "headFrames", "name": "headFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -4363,7 +4386,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 36, "id": 37,
"name": "chatFrames", "name": "chatFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5175,6 +5198,29 @@ export const serviceProto: ServiceProto<ServiceType> = {
}, },
{ {
"id": 5, "id": 5,
"name": "upModel",
"type": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "id",
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "time",
"type": {
"type": "Number"
}
}
]
}
},
{
"id": 6,
"name": "model", "name": "model",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5203,14 +5249,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 6, "id": 7,
"name": "renown", "name": "renown",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 7, "id": 8,
"name": "wxcLv", "name": "wxcLv",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5236,14 +5282,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 8, "id": 9,
"name": "mapId", "name": "mapId",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 9, "id": 10,
"name": "shoucangping", "name": "shoucangping",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5256,14 +5302,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 10, "id": 11,
"name": "useTujianLvPoint", "name": "useTujianLvPoint",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 11, "id": 12,
"name": "skills", "name": "skills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5276,7 +5322,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 12, "id": 13,
"name": "fightSkills", "name": "fightSkills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5289,7 +5335,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 13, "id": 14,
"name": "heroPos", "name": "heroPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5302,21 +5348,21 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 14, "id": 15,
"name": "ghId", "name": "ghId",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 15, "id": 16,
"name": "ghName", "name": "ghName",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 16, "id": 17,
"name": "ghLevel", "name": "ghLevel",
"type": { "type": {
"type": "Reference", "type": "Reference",
@ -5324,7 +5370,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 17, "id": 18,
"name": "ghwz", "name": "ghwz",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5338,7 +5384,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 18, "id": 19,
"name": "ghExitTime", "name": "ghExitTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5346,7 +5392,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 19, "id": 20,
"name": "loginTime", "name": "loginTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5354,7 +5400,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 20, "id": 21,
"name": "logoutTime", "name": "logoutTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5362,7 +5408,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 21, "id": 22,
"name": "cTime", "name": "cTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5370,7 +5416,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 22, "id": 23,
"name": "loginDays", "name": "loginDays",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5378,7 +5424,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 23, "id": 24,
"name": "serverName", "name": "serverName",
"type": { "type": {
"type": "String" "type": "String"
@ -5386,7 +5432,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 24, "id": 25,
"name": "sid", "name": "sid",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5394,7 +5440,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 25, "id": 26,
"name": "onlineTime", "name": "onlineTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5402,7 +5448,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 26, "id": 27,
"name": "newonlinetime", "name": "newonlinetime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5410,7 +5456,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 27, "id": 28,
"name": "isNpc", "name": "isNpc",
"type": { "type": {
"type": "Boolean" "type": "Boolean"
@ -5418,7 +5464,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 28, "id": 29,
"name": "matrix", "name": "matrix",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5432,7 +5478,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 29, "id": 30,
"name": "matrixPos", "name": "matrixPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5452,7 +5498,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 30, "id": 31,
"name": "selectMatrix", "name": "selectMatrix",
"type": { "type": {
"type": "String" "type": "String"
@ -5460,7 +5506,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 31, "id": 32,
"name": "fightHeros", "name": "fightHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -5471,7 +5517,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 32, "id": 33,
"name": "helpHeros", "name": "helpHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -5548,7 +5594,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 33, "id": 34,
"name": "changeNameNum", "name": "changeNameNum",
"type": { "type": {
"type": "Number" "type": "Number"
@ -5556,7 +5602,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 34, "id": 35,
"name": "peijianUnlock", "name": "peijianUnlock",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5570,7 +5616,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 35, "id": 36,
"name": "headFrames", "name": "headFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -5584,7 +5630,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 36, "id": 37,
"name": "chatFrames", "name": "chatFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -22862,6 +22908,29 @@ export const serviceProto: ServiceProto<ServiceType> = {
}, },
{ {
"id": 5, "id": 5,
"name": "upModel",
"type": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "id",
"type": {
"type": "String"
}
},
{
"id": 1,
"name": "time",
"type": {
"type": "Number"
}
}
]
}
},
{
"id": 6,
"name": "model", "name": "model",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -22890,14 +22959,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 6, "id": 7,
"name": "renown", "name": "renown",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 7, "id": 8,
"name": "wxcLv", "name": "wxcLv",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -22923,14 +22992,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 8, "id": 9,
"name": "mapId", "name": "mapId",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 9, "id": 10,
"name": "shoucangping", "name": "shoucangping",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -22943,14 +23012,14 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 10, "id": 11,
"name": "useTujianLvPoint", "name": "useTujianLvPoint",
"type": { "type": {
"type": "Number" "type": "Number"
} }
}, },
{ {
"id": 11, "id": 12,
"name": "skills", "name": "skills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -22963,7 +23032,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 12, "id": 13,
"name": "fightSkills", "name": "fightSkills",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -22976,7 +23045,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 13, "id": 14,
"name": "heroPos", "name": "heroPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -22989,21 +23058,21 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 14, "id": 15,
"name": "ghId", "name": "ghId",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 15, "id": 16,
"name": "ghName", "name": "ghName",
"type": { "type": {
"type": "String" "type": "String"
} }
}, },
{ {
"id": 16, "id": 17,
"name": "ghLevel", "name": "ghLevel",
"type": { "type": {
"type": "Reference", "type": "Reference",
@ -23011,7 +23080,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 17, "id": 18,
"name": "ghwz", "name": "ghwz",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -23025,7 +23094,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 18, "id": 19,
"name": "ghExitTime", "name": "ghExitTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23033,7 +23102,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 19, "id": 20,
"name": "loginTime", "name": "loginTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23041,7 +23110,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 20, "id": 21,
"name": "logoutTime", "name": "logoutTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23049,7 +23118,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 21, "id": 22,
"name": "cTime", "name": "cTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23057,7 +23126,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 22, "id": 23,
"name": "loginDays", "name": "loginDays",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23065,7 +23134,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 23, "id": 24,
"name": "serverName", "name": "serverName",
"type": { "type": {
"type": "String" "type": "String"
@ -23073,7 +23142,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 24, "id": 25,
"name": "sid", "name": "sid",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23081,7 +23150,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 25, "id": 26,
"name": "onlineTime", "name": "onlineTime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23089,7 +23158,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 26, "id": 27,
"name": "newonlinetime", "name": "newonlinetime",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23097,7 +23166,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 27, "id": 28,
"name": "isNpc", "name": "isNpc",
"type": { "type": {
"type": "Boolean" "type": "Boolean"
@ -23105,7 +23174,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 28, "id": 29,
"name": "matrix", "name": "matrix",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -23119,7 +23188,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 29, "id": 30,
"name": "matrixPos", "name": "matrixPos",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -23139,7 +23208,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 30, "id": 31,
"name": "selectMatrix", "name": "selectMatrix",
"type": { "type": {
"type": "String" "type": "String"
@ -23147,7 +23216,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 31, "id": 32,
"name": "fightHeros", "name": "fightHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -23158,7 +23227,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 32, "id": 33,
"name": "helpHeros", "name": "helpHeros",
"type": { "type": {
"type": "Array", "type": "Array",
@ -23235,7 +23304,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 33, "id": 34,
"name": "changeNameNum", "name": "changeNameNum",
"type": { "type": {
"type": "Number" "type": "Number"
@ -23243,7 +23312,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 34, "id": 35,
"name": "peijianUnlock", "name": "peijianUnlock",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -23257,7 +23326,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 35, "id": 36,
"name": "headFrames", "name": "headFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",
@ -23271,7 +23340,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"optional": true "optional": true
}, },
{ {
"id": 36, "id": 37,
"name": "chatFrames", "name": "chatFrames",
"type": { "type": {
"type": "Interface", "type": "Interface",

View File

@ -19,7 +19,7 @@ export type ResLogin = {
/** /**
* *
*/ */
openDay:number; openDay: number;
/**当前时间 */ /**当前时间 */
curTime: number; curTime: number;
/**是否第一次登录 */ /**是否第一次登录 */
@ -94,6 +94,13 @@ export type playerAppend = {
}; };
/**名字 */ /**名字 */
name: string; name: string;
/**正在使用的造型 */
upModel: {
/**id */
id: string,
/**到期时间戳 -1永久 */
time: number;
};
/**造型 */ /**造型 */
model: { model: {
[k: string]: { [k: string]: {

View File

@ -70,6 +70,14 @@ export class HeroShared {
} }
} }
} }
if (otherBuff.model) {
for (let [id, item] of Object.entries(otherBuff.model)) {
if (item.time == -1 || item.time > G.time) {
PublicShared.mergeProperty(buff, G.gc.playerModel[id].buff);
}
}
}
} }
//计算装备属性 //计算装备属性

View File

@ -1,25 +1,42 @@
export class UserShared { export class UserShared {
/**获取头像之类id */ /**获取头像之类id */
static getInfoId(type: 'head' | 'headFrame' | 'chatFrame' | 'model', id: string, pos?: string) { static getInfoId(type: 'head' | 'headFrame' | 'chatFrame' | 'model', id: string, pos?: string) {
return Array.from(arguments).filter(s => s != '').join('_'); return Array.from(arguments).filter(s => s != '').join('_');
} }
// todo active始终为空暂时获取对应的avtive解决打包上线的圣诞版本
// 后续要理清数据格式填入playerinfo的active包括user/infoOpen接口的返回
static getActive(fmtId, player, type, id?) {
switch (type) {
case 'head':
return {[fmtId]: player.head?.time}
case 'headFrame':
return {[fmtId]: player.headFrames[id]}
case 'chatFrame':
return {[fmtId]: player.chatFrames[id]}
case 'model':
return {[fmtId]: player.model?.[id]?.time}
}
return {}
}
/** /**
* *
* @param id 使 UserShared.getInfo id * @param id 使 UserShared.getInfo id
*/ */
static chechIsActive(fmtId: string, collection: Partial<{ lv: number, vip: number, lsyx: k_v<number>, active: k_v<number>; }>) { static chechIsActive(fmtId: string, collection: Partial<{ lv: number, vip: number, lsyx: k_v<number>, model: k_v<any>, active: k_v<number>; }>) {
const [type, id, pos] = fmtId.split('_'); const [type, id] = fmtId.split('_');
const jsonName = 'player' + type.slice(0, 1).toLocaleUpperCase() + type.slice(1); const jsonName = 'player' + type.slice(0, 1).toLocaleUpperCase() + type.slice(1);
const json = G.gc[jsonName] as any; const json = G.gc[jsonName] as any;
const conf: _gcType['playerHead'][''] = pos ? json[pos][id] : json[id]; const conf: _gcType['playerHead'] = json[id];
if (conf.cond[0] == 'lv') return collection.lv >= conf.cond[1]; if (conf.cond[0] == 'lv') return collection.lv >= conf.cond[1];
else if (conf.cond[0] == 'vip') return collection.vip >= conf.cond[1]; else if (conf.cond[0] == 'vip') return collection.vip >= conf.cond[1];
else if (conf.cond[0] == 'hero') return collection.lsyx[conf.cond[1]] > 0; else if (conf.cond[0] == 'hero') return collection.lsyx[conf.cond[1]] > 0;
else if (conf.cond[0] == 'time') return collection.active[fmtId] == -1 || collection.active[fmtId] > G.time; // else if (conf.cond[0] == 'time') return collection.active[fmtId] == -1 || collection.active[fmtId] > G.time;
else if (conf.cond[0] == 'time') return conf.cond[1] == -1 || collection.active?.[fmtId] > G.time;
else if (conf.cond[0] == 'model') return Object.values(collection.model).find(i => i.id == conf.cond[1]);
else return false; else return false;
} }
} }

1122
tsbufferIndex.js Normal file

File diff suppressed because it is too large Load Diff