Merge branch 'master' into feature/json
This commit is contained in:
commit
3e198b688e
@ -24,7 +24,6 @@ export default async function (call: ApiCall<Reqdisable, Resdisable>) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let res = await G.mongodb.collection('user').updateOne({uid}, {$set: data});
|
let res = await G.mongodb.collection('user').updateOne({uid}, {$set: data});
|
||||||
//G.redis.set('user', uid, typeStr, value);
|
|
||||||
setGud(uid, data);
|
setGud(uid, data);
|
||||||
let result = res.modifiedCount > 0 ? 0 : 1;
|
let result = res.modifiedCount > 0 ? 0 : 1;
|
||||||
//3. 返回结果
|
//3. 返回结果
|
||||||
|
@ -120,7 +120,6 @@ export default async function (call: ApiCall<ReqBingo, ResBingo>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (shell[0] == 'heroMaxLv') {
|
} else if (shell[0] == 'heroMaxLv') {
|
||||||
//let heros = await G.redis.get('hero', call.uid);
|
|
||||||
|
|
||||||
let s = await G.mongodb.collection('hero').find({
|
let s = await G.mongodb.collection('hero').find({
|
||||||
uid: call.uid
|
uid: call.uid
|
||||||
|
@ -12,7 +12,7 @@ export default async function (call: ApiCall<ReqFight, ResFight>) {
|
|||||||
let change: Partial<ResOpen> = {};
|
let change: Partial<ResOpen> = {};
|
||||||
let data = await DxltFun.getData(call);
|
let data = await DxltFun.getData(call);
|
||||||
|
|
||||||
if (data.killBoss >= G.gc.dxlt_com.dayFightLayer) return call.error(globalThis.lng.dixialeitai_2);
|
if (data.killBoss >= G.gc.dxlt_com.dayFightLayer) return call.error(globalThis.lng.dixialeitai_13);
|
||||||
if (G.gc.dxlt_layer[data.curLayer].type != 1) return call.error(globalThis.lng.dixialeitai_3);
|
if (G.gc.dxlt_layer[data.curLayer].type != 1) return call.error(globalThis.lng.dixialeitai_3);
|
||||||
if (data.over) return call.error(globalThis.lng.dixialeitai_4);
|
if (data.over) return call.error(globalThis.lng.dixialeitai_4);
|
||||||
if (!data.heros[call.req]) return call.error(globalThis.lng.dixialeitai_5);
|
if (!data.heros[call.req]) return call.error(globalThis.lng.dixialeitai_5);
|
||||||
|
@ -41,7 +41,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
} else {
|
} else {
|
||||||
call.succ(data);
|
call.succ(data);
|
||||||
}
|
}
|
||||||
|
G.ioredis.set(`dxlt:${call.uid}`, JSON.stringify(data));
|
||||||
G.redis.set('dxlt', call.uid, data);
|
|
||||||
G.mongodb.collection('dxlt').updateOne({ uid: call.uid }, { $set: { ...data } });
|
G.mongodb.collection('dxlt').updateOne({ uid: call.uid }, { $set: { ...data } });
|
||||||
}
|
}
|
@ -3,11 +3,15 @@ import {EmailFun} from '../../public/email';
|
|||||||
import {ReqOpen, ResOpen} from "../../shared/protocols/email/PtlOpen";
|
import {ReqOpen, ResOpen} from "../../shared/protocols/email/PtlOpen";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
|
// 存入当前玩家多语言信息
|
||||||
|
await G.redis.rawSet(`user:lng:${call.uid}`, call.req.lng, {EX: 259200})
|
||||||
|
|
||||||
let list = await EmailFun.getAllEmail(call.uid, false);
|
let list = await EmailFun.getAllEmail(call.uid, false);
|
||||||
let obj: ResOpen = {};
|
let obj: ResOpen = {};
|
||||||
list.forEach(e => obj[e._id] = e);
|
for (let email of list) {
|
||||||
call.succ(obj);
|
obj[email._id] = email;
|
||||||
|
if (email.prizelist) delete email.prizelist;
|
||||||
|
}
|
||||||
|
|
||||||
// 存入当前玩家多语言信息
|
call.succ(obj);
|
||||||
G.redis.rawSet(`user:lng:${call.uid}`, call.req.lng, {EX: 259200})
|
|
||||||
}
|
}
|
@ -24,7 +24,6 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
|||||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({ uid: call.conn.uid, type: 'usertasklog' },
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({ uid: call.conn.uid, type: 'usertasklog' },
|
||||||
{ $set: { maxequiplv: maxequiplv, equipcolor: color } }, { upsert: true })
|
{ $set: { maxequiplv: maxequiplv, equipcolor: color } }, { upsert: true })
|
||||||
|
|
||||||
//G.redis.set('equip', call.uid, kvList);
|
|
||||||
|
|
||||||
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_equip').findOne({ uid: call.conn.uid, type: 'lshd_equip' });
|
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_equip').findOne({ uid: call.conn.uid, type: 'lshd_equip' });
|
||||||
let { uid, _id, type, ...equips } = (recLshd || {});
|
let { uid, _id, type, ...equips } = (recLshd || {});
|
||||||
|
@ -109,7 +109,7 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
|
|||||||
});
|
});
|
||||||
const showOffListKey = showOffListKeyPrefix + activityId;
|
const showOffListKey = showOffListKeyPrefix + activityId;
|
||||||
await G.iorediscross.lpush(showOffListKey, msg);
|
await G.iorediscross.lpush(showOffListKey, msg);
|
||||||
await G.ioredis.ltrim(showOffListKey, 0, 49); // 限制列表保存 50 条消息, 避免无限增长
|
await G.iorediscross.ltrim(showOffListKey, 0, 49); // 限制列表保存 50 条消息, 避免无限增长
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,16 +15,13 @@ export default async function (call: ApiCall<ReqList, ResList>) {
|
|||||||
]).toArray();
|
]).toArray();
|
||||||
break;
|
break;
|
||||||
case 'friend':
|
case 'friend':
|
||||||
//res = await G.redis.gets('user', ...my.data.friendList.map(uid => [uid] as [string]))
|
|
||||||
res = (await G.mongodb.find('user',{uid:{$in:my.data.friendList}})) as any;
|
res = (await G.mongodb.find('user',{uid:{$in:my.data.friendList}})) as any;
|
||||||
break;
|
break;
|
||||||
case 'apply':
|
case 'apply':
|
||||||
// 预防申请列表出现脏数据(过滤已添加好友)
|
// 预防申请列表出现脏数据(过滤已添加好友)
|
||||||
//res = await G.redis.gets('user', ...);
|
|
||||||
res = (await G.mongodb.find('user',{uid:{$in: my.data.applyList.filter(uid => my.data.friendList.indexOf(uid) == -1) }})) as any
|
res = (await G.mongodb.find('user',{uid:{$in: my.data.applyList.filter(uid => my.data.friendList.indexOf(uid) == -1) }})) as any
|
||||||
break;
|
break;
|
||||||
case 'black':
|
case 'black':
|
||||||
//res = await G.redis.gets('user', ...my.data.blacklist.map(uid => [uid] as [string]))
|
|
||||||
res = (await G.mongodb.find('user',{uid:{$in: my.data.blacklist}})) as any;
|
res = (await G.mongodb.find('user',{uid:{$in: my.data.blacklist}})) as any;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ export default async function (call: ApiCall<ReqApplyList, ResApplyList>) {
|
|||||||
let GHdata = await call.conn.gonghui
|
let GHdata = await call.conn.gonghui
|
||||||
|
|
||||||
if (GHdata.data.applyList?.length > 0) {
|
if (GHdata.data.applyList?.length > 0) {
|
||||||
//let players = await G.redis.gets('user', ...GHdata.data.applyList.map(a => [a.uid] as [string]));
|
|
||||||
let uids = GHdata.data.applyList.map((i)=>i.uid);
|
let uids = GHdata.data.applyList.map((i)=>i.uid);
|
||||||
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ export default async function (call: ApiCall<ReqFbOpen, ResFbOpen>) {
|
|||||||
if (call.req.fbId != gh.data.fuben.id) {
|
if (call.req.fbId != gh.data.fuben.id) {
|
||||||
let md = await G.mongodb.collection('gonghuiFb').findOne({ ghId: gh.data._id, fbId: call.req.fbId });
|
let md = await G.mongodb.collection('gonghuiFb').findOne({ ghId: gh.data._id, fbId: call.req.fbId });
|
||||||
let uids = Object.keys(md.rankList);
|
let uids = Object.keys(md.rankList);
|
||||||
//let players = await G.redis.gets('user', ...uids.map(uid => [uid] as [string]));
|
|
||||||
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
||||||
res.rankList = players.map(p => {
|
res.rankList = players.map(p => {
|
||||||
return {
|
return {
|
||||||
@ -22,7 +21,6 @@ export default async function (call: ApiCall<ReqFbOpen, ResFbOpen>) {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let uids = Object.keys(gh.data.fuben.dps);
|
let uids = Object.keys(gh.data.fuben.dps);
|
||||||
//let players = await G.redis.gets('user', ...uids.map(uid => [uid] as [string]));
|
|
||||||
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
let players = (await G.mongodb.find('user',{uid:{$in: uids}})) as any;
|
||||||
res.rankList = players.map(p => {
|
res.rankList = players.map(p => {
|
||||||
return {
|
return {
|
||||||
|
@ -29,12 +29,8 @@ export async function getFinished(conn: BaseConnection, types: string[]) {
|
|||||||
else if (type == 'use_attr_rmbmoney') obj[type] = await ActionLog.getRetainLog(conn.uid, 'use_attr_rmbmoney');
|
else if (type == 'use_attr_rmbmoney') obj[type] = await ActionLog.getRetainLog(conn.uid, 'use_attr_rmbmoney');
|
||||||
else if (type == 'zccg') obj[type] = (await G.mongodb.collection('pata').findOne({ uid: conn.uid }))?.lv || 0;
|
else if (type == 'zccg') obj[type] = (await G.mongodb.collection('pata').findOne({ uid: conn.uid }))?.lv || 0;
|
||||||
else if (type == 'equip_star_5') {
|
else if (type == 'equip_star_5') {
|
||||||
//let equips = await G.redis.get('equip', conn.uid);
|
|
||||||
//obj[type] = Object.values(equips).filter(e => e.star >= 5).length;
|
|
||||||
obj[type] = await G.mongodb.collection('equip').count({ uid: conn.uid, star: { $gte: 5 } });
|
obj[type] = await G.mongodb.collection('equip').count({ uid: conn.uid, star: { $gte: 5 } });
|
||||||
} else if (type == 'peijian_colour_5') {
|
} else if (type == 'peijian_colour_5') {
|
||||||
//let peijians = await G.redis.get('peijian', conn.uid);
|
|
||||||
//obj[type] = Object.values(peijians).filter(p => G.gc.peijian[p.peijianId].colour >= 5).length;
|
|
||||||
obj[type] = await G.mongodb.collection('peijian').count({ uid: conn.uid, peijianId: { $in: peijianGteColor5ID } });
|
obj[type] = await G.mongodb.collection('peijian').count({ uid: conn.uid, peijianId: { $in: peijianGteColor5ID } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,55 +1,58 @@
|
|||||||
/**
|
/**
|
||||||
* 争霸赛分组,每300个玩家分一组
|
* 争霸赛分组,每300个玩家分一组
|
||||||
* 最后一组:如果是有100人即往上人数 那就自己一组打
|
* 最后一组:如果是有100人即往上人数 那就自己一组打
|
||||||
* 如果不够100 就合到前一组
|
* 如果不够100 就合到前一组
|
||||||
*/
|
*/
|
||||||
export async function zbsGroup(){
|
export async function zbsGroup() {
|
||||||
let arr = await G.mongodb.collection("hbzb_user_cross").find(
|
let arr = await G.mongodb.collection("hbzb_user_cross").find(
|
||||||
{ "jifen": { $gt: -999999 } }
|
{"jifen": {$gt: -999999}}
|
||||||
).sort(
|
|
||||||
{ "data.player.cTime": -1 }
|
|
||||||
).project({
|
).project({
|
||||||
uid:1,
|
uid: 1,
|
||||||
jifen:1
|
jifen: 1,
|
||||||
|
'data.player.cTime': 1
|
||||||
}).toArray();
|
}).toArray();
|
||||||
|
|
||||||
|
// 移除mongo查询里的排序,↑会造成内存超出报错,
|
||||||
|
// 在内存里按照玩家注册时间相近的排序分组
|
||||||
|
R.sort((a, b) => b.data.player.cTime - a.data.player.cTime)
|
||||||
|
|
||||||
//有积分的玩家总数
|
//有积分的玩家总数
|
||||||
let groups = [];
|
let groups = [];
|
||||||
let currGroup = [];
|
let currGroup = [];
|
||||||
|
|
||||||
arr.map((u,index)=>{
|
arr.map((u, index) => {
|
||||||
if(currGroup.length >= 300){
|
if (currGroup.length >= 300) {
|
||||||
//每300个丢一组
|
//每300个丢一组
|
||||||
groups.push( currGroup );
|
groups.push(currGroup);
|
||||||
currGroup = [];
|
currGroup = [];
|
||||||
}
|
}
|
||||||
currGroup.push({uid: u.uid, jifen: u.jifen});
|
currGroup.push({uid: u.uid, jifen: u.jifen});
|
||||||
});
|
});
|
||||||
|
|
||||||
//循环完毕后检查余量
|
//循环完毕后检查余量
|
||||||
if(currGroup.length > 0){
|
if (currGroup.length > 0) {
|
||||||
if(currGroup.length >= 100){
|
if (currGroup.length >= 100) {
|
||||||
//如果有100人 就自己一组
|
//如果有100人 就自己一组
|
||||||
groups.push( currGroup );
|
groups.push(currGroup);
|
||||||
}else{
|
} else {
|
||||||
//不够100 就合到前一组
|
//不够100 就合到前一组
|
||||||
groups[groups.length] = (groups[groups.length]||[]).concat(currGroup);
|
groups[groups.length] = (groups[groups.length] || []).concat(currGroup);
|
||||||
}
|
}
|
||||||
currGroup = [];
|
currGroup = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
//循环groups里的数据,对每一组里按jifen降序排序,然后给每个玩家分组
|
//循环groups里的数据,对每一组里按jifen降序排序,然后给每个玩家分组
|
||||||
groups.map((group,groupIndex)=>{
|
groups.map((group, groupIndex) => {
|
||||||
group.sort((a,b)=>{
|
group.sort((a, b) => {
|
||||||
return b.jifen - a.jifen;
|
return b.jifen - a.jifen;
|
||||||
});
|
});
|
||||||
for(let i=0;i<group.length;i++){
|
for (let i = 0; i < group.length; i++) {
|
||||||
G.mongodb.collection("hbzb_user_cross").updateOne(
|
G.mongodb.collection("hbzb_user_cross").updateOne(
|
||||||
{ uid: group[i].uid },
|
{uid: group[i].uid},
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
"zbsgroup": "group"+(groupIndex+1),
|
"zbsgroup": "group" + (groupIndex + 1),
|
||||||
"rank":(i+1),
|
"rank": (i + 1),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -60,46 +63,46 @@ export async function zbsGroup(){
|
|||||||
/**
|
/**
|
||||||
* 获取争霸赛阶段排行
|
* 获取争霸赛阶段排行
|
||||||
*/
|
*/
|
||||||
export async function getZbsRankList(uid?: string, _zbsgroup?: string) : Promise<{ myRank: any; rankList: any[]; }> {
|
export async function getZbsRankList(uid?: string, _zbsgroup?: string): Promise<{ myRank: any; rankList: any[]; }> {
|
||||||
let myData;
|
let myData;
|
||||||
let zbsgroup = _zbsgroup;
|
let zbsgroup = _zbsgroup;
|
||||||
|
|
||||||
if(uid){
|
if (uid) {
|
||||||
myData = await G.crossmongodb.collection("hbzb_user_cross").findOne({uid:uid});
|
myData = await G.crossmongodb.collection("hbzb_user_cross").findOne({uid: uid});
|
||||||
if(!myData || !myData?.zbsgroup)return null;
|
if (!myData || !myData?.zbsgroup) return null;
|
||||||
zbsgroup = myData?.zbsgroup;
|
zbsgroup = myData?.zbsgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
let arr = await G.crossmongodb.collection("hbzb_user_cross").find(
|
let arr = await G.crossmongodb.collection("hbzb_user_cross").find(
|
||||||
{ "zbsgroup": zbsgroup }
|
{"zbsgroup": zbsgroup}
|
||||||
).sort(
|
).sort(
|
||||||
{ "rank": 1 }
|
{"rank": 1}
|
||||||
).limit(100).toArray();
|
).limit(100).toArray();
|
||||||
|
|
||||||
|
|
||||||
let rank = {
|
let rank = {
|
||||||
"myRank":{},
|
"myRank": {},
|
||||||
"rankList" : []
|
"rankList": []
|
||||||
}
|
}
|
||||||
|
|
||||||
let myRank = -1;
|
let myRank = -1;
|
||||||
arr.map((u,index)=>{
|
arr.map((u, index) => {
|
||||||
rank.rankList.push( {
|
rank.rankList.push({
|
||||||
player: ((u.data) as any).player || {},
|
player: ((u.data) as any).player || {},
|
||||||
roles: ((u.data) as any).roles || {},
|
roles: ((u.data) as any).roles || {},
|
||||||
rank : (index+1),
|
rank: (index + 1),
|
||||||
//兼容前端
|
//兼容前端
|
||||||
valArr: [ (index+1) ]
|
valArr: [(index + 1)]
|
||||||
});
|
});
|
||||||
|
|
||||||
if(u.uid == uid){
|
if (u.uid == uid) {
|
||||||
myRank = rank.rankList.length;
|
myRank = rank.rankList.length;
|
||||||
rank.myRank = {
|
rank.myRank = {
|
||||||
player: ((u.data) as any).player || {},
|
player: ((u.data) as any).player || {},
|
||||||
roles: ((u.data) as any).roles || {},
|
roles: ((u.data) as any).roles || {},
|
||||||
rank : (index+1),
|
rank: (index + 1),
|
||||||
//兼容前端
|
//兼容前端
|
||||||
valArr: [ (index+1) ]
|
valArr: [(index + 1)]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -57,6 +57,8 @@ export default async function (call: ApiCall<ReqChangePos, ResChangePos>) {
|
|||||||
}
|
}
|
||||||
fightHeros.push(hero.heroId.toString());
|
fightHeros.push(hero.heroId.toString());
|
||||||
|
|
||||||
|
fightHeros = await checkFightHerosAndFix(call.uid, heroPos, fightHeros)
|
||||||
|
|
||||||
Wjjl.setVal(call.uid, 'fight_hero_colour_4', fightHeros.map(id => G.gc.hero[id].colour).filter(c => c >= 4).length);
|
Wjjl.setVal(call.uid, 'fight_hero_colour_4', fightHeros.map(id => G.gc.hero[id].colour).filter(c => c >= 4).length);
|
||||||
|
|
||||||
let checkMatrixPos = HeroFun.checkMatrixPosAndChange(call, heroPos, matrixPos)
|
let checkMatrixPos = HeroFun.checkMatrixPosAndChange(call, heroPos, matrixPos)
|
||||||
@ -66,3 +68,11 @@ export default async function (call: ApiCall<ReqChangePos, ResChangePos>) {
|
|||||||
call.conn.refreshPower();
|
call.conn.refreshPower();
|
||||||
kfjsFun.setHeroLvCount(call)
|
kfjsFun.setHeroLvCount(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkFightHerosAndFix(uid, heroPos, fightHeros) {
|
||||||
|
if (fightHeros.length == R.values(heroPos).length) {
|
||||||
|
return fightHeros
|
||||||
|
}
|
||||||
|
let heros = await HeroFun.getHeros({uid}, R.values(heroPos));
|
||||||
|
return heros.map(i => i.heroId)
|
||||||
|
}
|
@ -54,8 +54,6 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
|||||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'},
|
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({uid: call.conn.uid, type: 'usertasklog'},
|
||||||
{$set: {maxherolv: maxherolv, herocolor: color}}, {upsert: true});
|
{$set: {maxherolv: maxherolv, herocolor: color}}, {upsert: true});
|
||||||
|
|
||||||
//G.redis.set('hero', call.uid, kvList);
|
|
||||||
|
|
||||||
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_hero').findOne({
|
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_hero').findOne({
|
||||||
uid: call.conn.uid,
|
uid: call.conn.uid,
|
||||||
type: 'lshd_hero'
|
type: 'lshd_hero'
|
||||||
|
@ -36,23 +36,3 @@ export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
|||||||
|
|
||||||
kfjsFun.setHeroLvCount(call)
|
kfjsFun.setHeroLvCount(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// export default async function (call: ApiCall<ReqLvUp, ResLvUp, ServiceType>) {
|
|
||||||
// let hero = await G.redis.get('hero', call.uid, call.req.id);
|
|
||||||
// if (!hero) return call.errorCode(-1);
|
|
||||||
// if (hero.lv >= call.conn.gud.lv * 3) return call.errorCode(-2);
|
|
||||||
//
|
|
||||||
// let need = HeroShared.getHeroLvUpNeed(hero.heroId, hero.lv);
|
|
||||||
// await PlayerFun.checkNeedIsMeet(call, need);
|
|
||||||
// await PlayerFun.cutNeed(call, need);
|
|
||||||
// await HeroFun.changeHeroAttr(call, hero, {
|
|
||||||
// lv: hero.lv + 1
|
|
||||||
// });
|
|
||||||
// event_cszl_record(call.conn.gud, hero.heroId, hero.lv, 'lv')
|
|
||||||
//
|
|
||||||
// HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);
|
|
||||||
//
|
|
||||||
// call.succ({ lv: hero.lv });
|
|
||||||
// }
|
|
@ -221,27 +221,6 @@ export class HongDianFun {
|
|||||||
let prize = G.gc.pata[_myData.lv - 1]?.sdprize;
|
let prize = G.gc.pata[_myData.lv - 1]?.sdprize;
|
||||||
_res.val.saodang.show = max - (_myData.saodangNum || 0) > 0 && !!prize
|
_res.val.saodang.show = max - (_myData.saodangNum || 0) > 0 && !!prize
|
||||||
_res.show = _res.show || _res.val.saodang.show
|
_res.show = _res.show || _res.val.saodang.show
|
||||||
// 商店判断
|
|
||||||
// 个人爬塔商店购买情况
|
|
||||||
// let shopData = await G.redis.get('shop', call.uid, '7'); // 商店编号7,未理清商店id存放的数据表,后续该出尽量改为数据库读取
|
|
||||||
|
|
||||||
// 12.12策划确定爬塔id7的商店移除,此处商店不再需要红点
|
|
||||||
// let shopData = await ShopFun.getShopData(call.uid, "7")
|
|
||||||
// if (shopData) {
|
|
||||||
// let {buyNum, shopItems} = shopData
|
|
||||||
// // 获取爬塔商店商品
|
|
||||||
// for (let index in shopItems) {
|
|
||||||
// let x = shopItems[index]
|
|
||||||
// if (x.needZCCG > 0 && x.needZCCG < _myData.lv && (buyNum && !buyNum[index])) {
|
|
||||||
// // 验证是否达到购买条件
|
|
||||||
// let isOk = await (await PlayerFun.checkNeedIsMeet(call, x.buyNeed, false)).isOk
|
|
||||||
// if (isOk) {
|
|
||||||
// _res.show = true
|
|
||||||
// _res.val.shopItems.show = true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,21 +4,6 @@ import { ReqGetList, ResGetList } from "../../shared/protocols/item/PtlGetList";
|
|||||||
import { getItemList } from "../../public/item";
|
import { getItemList } from "../../public/item";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||||
// let list: ResGetList['list'] = {};
|
|
||||||
// let kvList: k_v<RedisCollections2['item']> = {};
|
|
||||||
// let arrList = await G.mongodb.collection('item').find({ uid: call.uid,num:{$ne:0}}).toArray();
|
|
||||||
|
|
||||||
// arrList.forEach(v => {
|
|
||||||
// let d = G.mongodb.conversionIdObj(v);
|
|
||||||
// kvList[G.formatRedisKey(d.itemId)] = d;
|
|
||||||
// list[d.itemId] = d;
|
|
||||||
// });
|
|
||||||
|
|
||||||
//去掉item Redis相关
|
|
||||||
//G.redis.set('item', call.uid, kvList);
|
|
||||||
|
|
||||||
//call.conn.item = list;
|
|
||||||
|
|
||||||
let list = await getItemList(call.uid);
|
let list = await getItemList(call.uid);
|
||||||
call.succ({
|
call.succ({
|
||||||
list: list
|
list: list
|
||||||
|
@ -20,9 +20,6 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
{$set: {resetTime: G.time, receivedArr: [], buyFightNum: 0, useFightNum: 0}},
|
{$set: {resetTime: G.time, receivedArr: [], buyFightNum: 0, useFightNum: 0}},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// G.redis.set('jjc', call.uid, data);
|
|
||||||
|
|
||||||
data.recordWin = data.recordWin || 0;
|
data.recordWin = data.recordWin || 0;
|
||||||
let enemy = await JJCFun.randomEnemy(call.uid)
|
let enemy = await JJCFun.randomEnemy(call.uid)
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
|||||||
list[d._id] = d;
|
list[d._id] = d;
|
||||||
});
|
});
|
||||||
|
|
||||||
// G.redis.set('shiwu', call.uid, kvList);
|
|
||||||
|
|
||||||
call.succ({
|
call.succ({
|
||||||
list: list
|
list: list
|
||||||
});
|
});
|
||||||
|
@ -11,7 +11,7 @@ export default async function (call: ApiCall<ReqBuy, ResBuy>) {
|
|||||||
|
|
||||||
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
||||||
|
|
||||||
let shopData = await ShopFun.getShopData(uid, shopId);
|
let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv);
|
||||||
|
|
||||||
let shopItem = shopData.shopItems[index];
|
let shopItem = shopData.shopItems[index];
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
|
|
||||||
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
||||||
|
|
||||||
let shopData = await ShopFun.getShopData(uid, shopId)
|
let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv)
|
||||||
|
|
||||||
call.succ(shopData);
|
call.succ(shopData);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { PlayerFun } from '../../public/player';
|
import {PlayerFun} from '../../public/player';
|
||||||
import { ShopFun } from '../../public/shop';
|
import {ShopFun} from '../../public/shop';
|
||||||
import { ReqRefresh, ResRefresh } from "../../shared/protocols/shop/PtlRefresh";
|
import {ReqRefresh, ResRefresh} from "../../shared/protocols/shop/PtlRefresh";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
||||||
let shopId = call.req.shopId;
|
let shopId = call.req.shopId;
|
||||||
@ -9,7 +9,7 @@ export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
|||||||
|
|
||||||
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
||||||
|
|
||||||
let shopData = await ShopFun.getShopData(uid, shopId);
|
let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv);
|
||||||
|
|
||||||
if (!shopData) return call.error(globalThis.lng.shop_1);
|
if (!shopData) return call.error(globalThis.lng.shop_1);
|
||||||
|
|
||||||
@ -46,6 +46,6 @@ export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
|||||||
|
|
||||||
await ShopFun.changeShopData(uid, shopId, change);
|
await ShopFun.changeShopData(uid, shopId, change);
|
||||||
|
|
||||||
let { buyNum, shopItems, ...ops } = change;
|
let {buyNum, shopItems, ...ops} = change;
|
||||||
call.succ({buyNum: buyNum, shopItems: shopItems, ...ops});
|
call.succ({buyNum: buyNum, shopItems: shopItems, ...ops});
|
||||||
}
|
}
|
@ -128,8 +128,6 @@ async function doLogin(call: ApiCall<ReqLogin, ResLogin>) {
|
|||||||
return call.error(lng.user_10);
|
return call.error(lng.user_10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//去掉userRedis相关
|
|
||||||
//await G.redis.set('user', gud.uid, gud);
|
|
||||||
await initGud(gud.uid, gud);
|
await initGud(gud.uid, gud);
|
||||||
|
|
||||||
// 修复公会id
|
// 修复公会id
|
||||||
|
@ -7,7 +7,16 @@ import { ReqDldFight, ResDldFight } from "../../shared/protocols/wzry/PtlDldFigh
|
|||||||
import { PublicShared } from "../../shared/public/public";
|
import { PublicShared } from "../../shared/public/public";
|
||||||
import { HongDianChange } from "../hongdian/fun";
|
import { HongDianChange } from "../hongdian/fun";
|
||||||
|
|
||||||
|
const maxScore = 269; // 积分上限
|
||||||
|
const lockPrefix = 'lock:DldFight:';
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqDldFight, ResDldFight>) {
|
export default async function (call: ApiCall<ReqDldFight, ResDldFight>) {
|
||||||
|
const lockKey = lockPrefix + call.uid;
|
||||||
|
const gotLock = await G.ioredis.setnx(lockKey, 1);
|
||||||
|
if (!gotLock) {
|
||||||
|
return call.errorCode(-101); // -101 并发请求, 告知客户端稍后再试 request_too_fast
|
||||||
|
}
|
||||||
|
await G.ioredis.expire(lockKey, 1); // 设置 ttl 避免死锁
|
||||||
let status = await WangZheRongYaofun.getWangZheStatus();
|
let status = await WangZheRongYaofun.getWangZheStatus();
|
||||||
if (status.status != 3) {
|
if (status.status != 3) {
|
||||||
// 未到大乱斗时间
|
// 未到大乱斗时间
|
||||||
@ -41,6 +50,10 @@ export default async function (call: ApiCall<ReqDldFight, ResDldFight>) {
|
|||||||
|
|
||||||
let _jifen = _myFight.jifen;
|
let _jifen = _myFight.jifen;
|
||||||
_myFight.jifen = _myFight.jifen + await WangZheRongYaofun.getMyScore(dldfight);
|
_myFight.jifen = _myFight.jifen + await WangZheRongYaofun.getMyScore(dldfight);
|
||||||
|
// 添加积分上限 (策划要求)
|
||||||
|
if (_myFight.jifen > maxScore) {
|
||||||
|
_myFight.jifen = maxScore;
|
||||||
|
}
|
||||||
|
|
||||||
// 设置数据
|
// 设置数据
|
||||||
let _r = await WangZheRongYaofun.setWzryDldFight(call, _myFight);
|
let _r = await WangZheRongYaofun.setWzryDldFight(call, _myFight);
|
||||||
@ -69,7 +82,7 @@ export default async function (call: ApiCall<ReqDldFight, ResDldFight>) {
|
|||||||
_mydata.jifen = _myFight.jifen;
|
_mydata.jifen = _myFight.jifen;
|
||||||
|
|
||||||
HongDianChange.sendChangeKey(call.uid, ['wzryhd']);
|
HongDianChange.sendChangeKey(call.uid, ['wzryhd']);
|
||||||
|
await G.ioredis.del(lockKey);
|
||||||
call.succ({
|
call.succ({
|
||||||
mydata: _mydata,
|
mydata: _mydata,
|
||||||
result: result,
|
result: result,
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import 'tsrpc';
|
import 'tsrpc';
|
||||||
import { ApiCall, BaseConnection, ConnectionStatus, WsServer } from 'tsrpc';
|
import { ApiCall, BaseConnection, ConnectionStatus, WsServer } from 'tsrpc';
|
||||||
import { Wjjl } from './module/collection_wjjl';
|
import { Wjjl } from './module/collection_wjjl';
|
||||||
@ -133,7 +132,7 @@ BaseConnection.prototype.getDefaultFightData = async function (this: BaseConnect
|
|||||||
posObj = this.gud.matrixPos[this.gud.selectMatrix];
|
posObj = this.gud.matrixPos[this.gud.selectMatrix];
|
||||||
}
|
}
|
||||||
|
|
||||||
let heros = await HeroFun.getHeros(this, Object.values(posObj).filter(_id => _id != ''));
|
let heros = await HeroFun.getHeros(this, Object.values(posObj).filter(_id => _id != '') as string[]);
|
||||||
|
|
||||||
Object.entries(posObj).forEach(obj => {
|
Object.entries(posObj).forEach(obj => {
|
||||||
let pos = obj[0];
|
let pos = obj[0];
|
||||||
@ -242,12 +241,10 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection<Ser
|
|||||||
if(power > this.gud?.maxpower){
|
if(power > this.gud?.maxpower){
|
||||||
//记录历史最大战力
|
//记录历史最大战力
|
||||||
//this.gud.maxpower = power;
|
//this.gud.maxpower = power;
|
||||||
//G.redis.set('user', this.uid, 'maxpower', power);
|
|
||||||
dbUpdate['maxpower'] = power;
|
dbUpdate['maxpower'] = power;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.gud.power = power;
|
//this.gud.power = power;
|
||||||
//G.redis.set('user', this.uid, 'power', power);
|
|
||||||
setGud(this.uid,dbUpdate);
|
setGud(this.uid,dbUpdate);
|
||||||
|
|
||||||
G.mongodb.collection('user').updateOne({ uid: this.uid }, { $set: dbUpdate });
|
G.mongodb.collection('user').updateOne({ uid: this.uid }, { $set: dbUpdate });
|
||||||
|
33
src/fix_patch/patch_test.ts
Normal file
33
src/fix_patch/patch_test.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import { patchFun, patchInit } from "../patch";
|
||||||
|
|
||||||
|
class Path{
|
||||||
|
@patchFun
|
||||||
|
async fun1(a:any) {
|
||||||
|
//这里执行脚本的内容,加了patchFun的函数,不允许重复执行
|
||||||
|
console.log("这是第1个脚本里内容");
|
||||||
|
return 12
|
||||||
|
}
|
||||||
|
|
||||||
|
@patchFun
|
||||||
|
async fun2(a:any) {
|
||||||
|
//这里执行脚本的内容,加了patchFun的函数,不允许重复执行
|
||||||
|
console.log("这是第2个脚本里内容");
|
||||||
|
return 12
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(){
|
||||||
|
await this.fun1(1);
|
||||||
|
await this.fun2(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main(){
|
||||||
|
await patchInit()
|
||||||
|
let patch = new Path();
|
||||||
|
await patch.run();
|
||||||
|
setInterval(() => {
|
||||||
|
console.log(new Date().format("MM-dd hh:mm:ss"));
|
||||||
|
}, 1000);
|
||||||
|
console.log("逻辑执行完成,等待退出");
|
||||||
|
}
|
||||||
|
main();
|
@ -142,7 +142,13 @@ class _G {
|
|||||||
}
|
}
|
||||||
|
|
||||||
on<T extends keyof gEventType>(event: T, callback: gEventType[T]) {
|
on<T extends keyof gEventType>(event: T, callback: gEventType[T]) {
|
||||||
return this.event.on(event, callback);
|
return this.event.on(event, (...args)=>{
|
||||||
|
try{
|
||||||
|
callback.call(this, ...args);
|
||||||
|
}catch(e){
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
once<T extends keyof gEventType>(event: T, callback: gEventType[T]) {
|
once<T extends keyof gEventType>(event: T, callback: gEventType[T]) {
|
||||||
|
@ -162,9 +162,6 @@ export function addListener() {
|
|||||||
XstaskFun.uidTask[uid] = null;
|
XstaskFun.uidTask[uid] = null;
|
||||||
delete XstaskFun.uidTask[uid];
|
delete XstaskFun.uidTask[uid];
|
||||||
}
|
}
|
||||||
|
|
||||||
//离线时更新该玩家的登出时间
|
|
||||||
//G.redis.set('user', uid, 'logoutTime', G.time);
|
|
||||||
setGud(uid,{ logoutTime: G.time });
|
setGud(uid,{ logoutTime: G.time });
|
||||||
G.mongodb.collection('user').updateOne({ uid: uid }, { $set: { logoutTime: G.time } });
|
G.mongodb.collection('user').updateOne({ uid: uid }, { $set: { logoutTime: G.time } });
|
||||||
});
|
});
|
||||||
|
@ -1213,6 +1213,7 @@ type gc_shop = k_v<{
|
|||||||
'npcImg': number
|
'npcImg': number
|
||||||
/** 商店看板娘说话 */
|
/** 商店看板娘说话 */
|
||||||
'npcText': string
|
'npcText': string
|
||||||
|
'version': string | number
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
type gc_shopcom = k_v<{
|
type gc_shopcom = k_v<{
|
||||||
|
@ -131,6 +131,7 @@ class Lng {
|
|||||||
dixialeitai_10 = "dixialeitai_10";
|
dixialeitai_10 = "dixialeitai_10";
|
||||||
dixialeitai_11 = "dixialeitai_11";
|
dixialeitai_11 = "dixialeitai_11";
|
||||||
dixialeitai_12 = "dixialeitai_12";
|
dixialeitai_12 = "dixialeitai_12";
|
||||||
|
dixialeitai_13 = "dixialeitai_13";
|
||||||
|
|
||||||
email_1 = "email_1";
|
email_1 = "email_1";
|
||||||
email_2 = "email_2";
|
email_2 = "email_2";
|
||||||
|
@ -4,4 +4,5 @@ import {ResOpen} from '../shared/protocols/shop/PtlOpen';
|
|||||||
export type CollectionShop = ResOpen & {
|
export type CollectionShop = ResOpen & {
|
||||||
uid: string; // 玩家uid
|
uid: string; // 玩家uid
|
||||||
shopId: string; // 商店id
|
shopId: string; // 商店id
|
||||||
|
version: string | number;
|
||||||
};
|
};
|
68
src/patch.ts
Normal file
68
src/patch.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import { extendType } from "./extends";
|
||||||
|
import { ctor } from "./global";
|
||||||
|
import { initIORedis } from "./ioredis";
|
||||||
|
import { initGcType } from "./jsonType";
|
||||||
|
import { createLng } from "./lng";
|
||||||
|
import { initMongoDB } from "./setMongodb";
|
||||||
|
import { initRedis } from "./setRedis";
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
|
var scriptName = path.basename(__filename);
|
||||||
|
|
||||||
|
export function patchFun(target: any, key: string, descriptor: PropertyDescriptor) {
|
||||||
|
let scriptName;
|
||||||
|
try {
|
||||||
|
throw new Error();
|
||||||
|
} catch (e) {
|
||||||
|
let caller = (e.stack.split("\n").slice(2)[0].split("\\").slice(-2));
|
||||||
|
scriptName = caller[1].split(':')[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!scriptName){
|
||||||
|
console.log('获取不到脚本名');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const originalMethod = descriptor.value;
|
||||||
|
descriptor.value = function(...args: any[]) {
|
||||||
|
//@ts-ignore
|
||||||
|
G.mongodb.collection("_patch_run_log").findOne({ fileName: scriptName, funName: key }).then(async runed=>{
|
||||||
|
if(runed){
|
||||||
|
console.log(`脚本${scriptName}已经执行过${key}方法,跳过`);
|
||||||
|
return (null as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`调用了${scriptName}脚本里的${key}方法,参数为:${args}`);
|
||||||
|
const result = await originalMethod.apply(this, args);
|
||||||
|
console.log(`执行结果为:${result}`);
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
await G.mongodb.collection("_patch_run_log").insertOne({
|
||||||
|
"fileName": scriptName,
|
||||||
|
"funName": key as any,
|
||||||
|
"ctime":Date.now(),
|
||||||
|
"res":result
|
||||||
|
});
|
||||||
|
return (result as any);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function patchInit() {
|
||||||
|
await patchStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function patchStart() {
|
||||||
|
//扩展框架
|
||||||
|
extendType();
|
||||||
|
//游戏配置提示文件
|
||||||
|
initGcType();
|
||||||
|
//连接mongodb
|
||||||
|
await initMongoDB();
|
||||||
|
//连接redis
|
||||||
|
await initRedis();
|
||||||
|
await initIORedis();
|
||||||
|
}
|
||||||
|
// //定义全局变量
|
||||||
|
ctor();
|
||||||
|
//创建语言包
|
||||||
|
createLng();
|
@ -7,15 +7,15 @@ export class DxltFun {
|
|||||||
/**修改数据 */
|
/**修改数据 */
|
||||||
static async changeData(call: ApiCall, change: Partial<ResOpen>) {
|
static async changeData(call: ApiCall, change: Partial<ResOpen>) {
|
||||||
|
|
||||||
Object.entries(change).forEach(v => {
|
let data = await this.getData(call);
|
||||||
G.redis.set('dxlt', call.uid, v[0] as any, v[1]);
|
Object.assign(data, change);
|
||||||
});
|
G.ioredis.set(`dxlt:${call.uid}`, JSON.stringify(data));
|
||||||
G.mongodb.collection('dxlt').updateOne({ uid: call.uid }, { $set: { ...change } });
|
|
||||||
|
|
||||||
|
G.mongodb.collection('dxlt').updateOne({ uid: call.uid }, { $set: { ...change } });
|
||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
static async getData(call: ApiCall) {
|
static async getData(call: ApiCall) {
|
||||||
return await G.redis.get('dxlt', call.uid);
|
return JSON.parse(await G.ioredis.get(`dxlt:${call.uid}`)) ;
|
||||||
}
|
}
|
||||||
/**回退层数 */
|
/**回退层数 */
|
||||||
static backLayer(data: ResOpen) {
|
static backLayer(data: ResOpen) {
|
||||||
|
@ -53,22 +53,7 @@ export class EmailFun {
|
|||||||
if (email.uid == "system" && email.prizeData) _email.prizeData.isGet = _email.prizelist.includes(uid);
|
if (email.uid == "system" && email.prizeData) _email.prizeData.isGet = _email.prizelist.includes(uid);
|
||||||
|
|
||||||
delete _email.readlist;
|
delete _email.readlist;
|
||||||
// let emailRead = await G.redis.get('email', uid, _email._id, 'emailRead');
|
|
||||||
// let emailRead = await G.redis.get('email', uid, _email._id, 'emailRead');
|
|
||||||
|
|
||||||
// if (email.uid != "system") {
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// // 全服邮件 数据操作
|
|
||||||
// if (email?.dellist?.indexOf(uid) == -1 && gud?.cTime && gud.cTime <= email.createTime) {
|
|
||||||
// if (_email.prizeData) _email.prizeData.isGet = email?.prizelist.indexOf(uid) != -1
|
|
||||||
// kvList[G.formatRedisKey(_email._id)] = _email;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// G.redis.set('email', uid, kvList);
|
|
||||||
|
|
||||||
let lng = await G.redis.rawGet(`user:lng:${uid}`)
|
let lng = await G.redis.rawGet(`user:lng:${uid}`)
|
||||||
|
|
||||||
return Object.values(kvList).map(i => ({
|
return Object.values(kvList).map(i => ({
|
||||||
@ -76,9 +61,6 @@ export class EmailFun {
|
|||||||
title: i.lngTitle ? (i.lngTitle[lng] || i.lngTitle['ja']) : i.title,
|
title: i.lngTitle ? (i.lngTitle[lng] || i.lngTitle['ja']) : i.title,
|
||||||
content: i.lngContent ? (i.lngContent[lng] || i.lngContent['ja']) : i.content
|
content: i.lngContent ? (i.lngContent[lng] || i.lngContent['ja']) : i.content
|
||||||
}));
|
}));
|
||||||
// } else {
|
|
||||||
// return Object.values(await G.redis.get('email', uid));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**领取邮件 */
|
/**领取邮件 */
|
||||||
@ -89,7 +71,6 @@ export class EmailFun {
|
|||||||
let change: k_v<boolean> = {};
|
let change: k_v<boolean> = {};
|
||||||
let oids = _ids.map(id => {
|
let oids = _ids.map(id => {
|
||||||
change[id] = true;
|
change[id] = true;
|
||||||
// G.redis.set('email', uid, id, 'prizeData', 'isGet', true);
|
|
||||||
return G.mongodb.conversionId(id);
|
return G.mongodb.conversionId(id);
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -111,11 +92,6 @@ export class EmailFun {
|
|||||||
|
|
||||||
// 更改邮件状态为已读-仅限没有奖励的邮件
|
// 更改邮件状态为已读-仅限没有奖励的邮件
|
||||||
static async readEmail(uid: string, id: string) {
|
static async readEmail(uid: string, id: string) {
|
||||||
// G.mongodb.collection('email').updateMany({ uid: uid, id: {$in: ids}}, {$set: { emailRead: true}})
|
|
||||||
// 查询系统邮件,
|
|
||||||
// let systemEmail = await G.mongodb.collection('email').find({ uid: "system", id: {$in: ids}});
|
|
||||||
// console.log(systemEmail)
|
|
||||||
// G.redis.set('email', uid, id, 'emailRead', true);
|
|
||||||
G.mongodb.collection('email').updateOne(G.mongodb.conversionIdObj({
|
G.mongodb.collection('email').updateOne(G.mongodb.conversionIdObj({
|
||||||
uid: uid, _id: id
|
uid: uid, _id: id
|
||||||
}), {$set: {emailRead: true}});
|
}), {$set: {emailRead: true}});
|
||||||
@ -151,11 +127,6 @@ export class EmailFun {
|
|||||||
/**增加 跨服定时器发送邮件 直接写入数据 (跨服定时器执行检测时会报错)*/
|
/**增加 跨服定时器发送邮件 直接写入数据 (跨服定时器执行检测时会报错)*/
|
||||||
static async addEmail(email: ReqEmail & { createTime?: number; }, isCross: boolean = false) {
|
static async addEmail(email: ReqEmail & { createTime?: number; }, isCross: boolean = false) {
|
||||||
let {prize, uid, ...e} = email;
|
let {prize, uid, ...e} = email;
|
||||||
// if (!isCross) {
|
|
||||||
// let existUid = await G.redis.hGet('player:uids', uid)
|
|
||||||
// if (!existUid) return '玩家uid不存在: ' + uid;
|
|
||||||
// }
|
|
||||||
|
|
||||||
let lng = await G.redis.rawGet(`user:lng:${uid}`)
|
let lng = await G.redis.rawGet(`user:lng:${uid}`)
|
||||||
|
|
||||||
let sendEmail: MsgEmail = {
|
let sendEmail: MsgEmail = {
|
||||||
@ -218,7 +189,6 @@ export class EmailFun {
|
|||||||
if (isCross) return _id
|
if (isCross) return _id
|
||||||
|
|
||||||
sendEmail._id = _id;
|
sendEmail._id = _id;
|
||||||
// G.redis.set('email', uid, _id, sendEmail);
|
|
||||||
G.server.sendMsgByUid(uid, 'msg_s2c/Email', sendEmail);
|
G.server.sendMsgByUid(uid, 'msg_s2c/Email', sendEmail);
|
||||||
|
|
||||||
return _id;
|
return _id;
|
||||||
@ -260,8 +230,6 @@ export class EmailFun {
|
|||||||
})).insertedId.toHexString();
|
})).insertedId.toHexString();
|
||||||
sendEmail._id = _id;
|
sendEmail._id = _id;
|
||||||
|
|
||||||
// let conns = G.server.connections;
|
|
||||||
// G.redis.set('email', uid, _id, sendEmail);
|
|
||||||
G.server.broadcastMsg('msg_s2c/Email', sendEmail);
|
G.server.broadcastMsg('msg_s2c/Email', sendEmail);
|
||||||
|
|
||||||
return _id;
|
return _id;
|
||||||
|
@ -27,9 +27,6 @@ export class EquipFun {
|
|||||||
|
|
||||||
Object.assign(equip, change);
|
Object.assign(equip, change);
|
||||||
|
|
||||||
// for (let k in change) {
|
|
||||||
// G.redis.set('equip', call.uid, equip._id, k as keyof CollectionEquip, change[k]);
|
|
||||||
// }
|
|
||||||
G.mongodb.collection('equip').updateOne({uid: call.uid, _id: new ObjectId(equip._id)}, {$set: {...change}});
|
G.mongodb.collection('equip').updateOne({uid: call.uid, _id: new ObjectId(equip._id)}, {$set: {...change}});
|
||||||
call.addEventMsg('msg_s2c/EquipChange', equip._id, change);
|
call.addEventMsg('msg_s2c/EquipChange', equip._id, change);
|
||||||
}
|
}
|
||||||
|
@ -135,16 +135,9 @@ export class FightFun {
|
|||||||
|
|
||||||
G.mongodb.collection('fightLog').insertOne({uid, type, ...result})
|
G.mongodb.collection('fightLog').insertOne({uid, type, ...result})
|
||||||
|
|
||||||
// if (await G.redis.type('fightLog', type, uid) == null) await G.redis.set('fightLog', type, uid, []);
|
|
||||||
|
|
||||||
// G.redis.arrAppend('fightLog', type, uid, result).then(len => {
|
|
||||||
// if (len > maxLen) G.redis.arrPop('fightLog', type, uid, 0);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async readLog(uid: string, type: string, len = 20) {
|
static async readLog(uid: string, type: string, len = 20) {
|
||||||
// return await G.redis.get('fightLog', type, uid) || [];
|
|
||||||
|
|
||||||
return await G.mongodb.collection('fightLog').find({uid, type}).limit(len).toArray() || []
|
return await G.mongodb.collection('fightLog').find({uid, type}).limit(len).toArray() || []
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,14 +31,21 @@ export class GH {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**更改isFightBoss状态 */
|
/**更改isFightBoss状态 */
|
||||||
changeIsFightBoss(bool = false) {
|
async changeIsFightBoss(bool = false) {
|
||||||
G.redis.hSet('gonghui:isFightBoss', this.data._id, bool)
|
const key = 'gonghui:isFightBoss:' + this.data._id;
|
||||||
|
if (bool) {
|
||||||
|
await G.ioredis.setnx(key, 1);
|
||||||
|
await G.ioredis.expire(key, 1);
|
||||||
|
} else {
|
||||||
|
await G.ioredis.del(key);
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/**获取isFightBoss状态 */
|
/**获取isFightBoss状态 */
|
||||||
async getIsFightBoss(): Promise<boolean> {
|
async getIsFightBoss(): Promise<boolean> {
|
||||||
return await G.redis.hGet('gonghui:isFightBoss', this.data._id) || false
|
const key = 'gonghui:isFightBoss:' + this.data._id;
|
||||||
|
return await G.ioredis.get(key)? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,7 +192,6 @@ export class GH {
|
|||||||
* 公会申请审批
|
* 公会申请审批
|
||||||
*/
|
*/
|
||||||
async apply(...p: string[]) {
|
async apply(...p: string[]) {
|
||||||
//let players = await G.redis.gets('user', ...p.map(u => [u] as [string]));
|
|
||||||
let players = await G.mongodb.find('user',{uid:{$in:p}});
|
let players = await G.mongodb.find('user',{uid:{$in:p}});
|
||||||
|
|
||||||
for (let i=0;i<players.length;i++) {
|
for (let i=0;i<players.length;i++) {
|
||||||
@ -203,8 +209,6 @@ export class GH {
|
|||||||
* 获取公会成员列表
|
* 获取公会成员列表
|
||||||
*/
|
*/
|
||||||
async getAllPlayers() {
|
async getAllPlayers() {
|
||||||
//let players = await G.redis.gets('user', ...this.data.players.map(p => [p.uid] as [string]));
|
|
||||||
// let players = await G.mongodb.find('user',{uid:{$in: this.data.players}});
|
|
||||||
let uids = this.data.players.map(p => p.uid);
|
let uids = this.data.players.map(p => p.uid);
|
||||||
let players = await G.mongodb.collection('user').find({uid:{$in: uids}}).toArray();
|
let players = await G.mongodb.collection('user').find({uid:{$in: uids}}).toArray();
|
||||||
|
|
||||||
|
@ -133,7 +133,6 @@ export class GHManage {
|
|||||||
}
|
}
|
||||||
this.countInterval = 0;
|
this.countInterval = 0;
|
||||||
let list:k_v<GH> = await this.getGHList()
|
let list:k_v<GH> = await this.getGHList()
|
||||||
// let list = await G.redis.hGetAll('key')
|
|
||||||
Object.entries(list).forEach(v => {
|
Object.entries(list).forEach(v => {
|
||||||
let [_id, gh] = v;
|
let [_id, gh] = v;
|
||||||
if (gh.data?.tanhe && G.time >= gh.data.tanhe.time) {
|
if (gh.data?.tanhe && G.time >= gh.data.tanhe.time) {
|
||||||
|
@ -19,10 +19,9 @@ export async function clearGud(uid) {
|
|||||||
G.ioredis.del(`gudVersion:${uid}_ver`);
|
G.ioredis.del(`gudVersion:${uid}_ver`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(await G.redis.type('tanxian', uid)){
|
//清空Redis缓存
|
||||||
console.log('清空tanxian Redis',uid);
|
G.ioredis.del(`tanxian:${uid}`);
|
||||||
G.redis.del("tanxian",uid);
|
G.ioredis.del(`dxlt:${uid}`);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,10 +24,6 @@ export class HeroFun {
|
|||||||
hero.zhanli = HeroShared.getHeroZhanLi(hero, call.otherBuff, Object.values(call.conn.gud.heroPos).indexOf(hero._id));
|
hero.zhanli = HeroShared.getHeroZhanLi(hero, call.otherBuff, Object.values(call.conn.gud.heroPos).indexOf(hero._id));
|
||||||
change.zhanli = hero.zhanli;
|
change.zhanli = hero.zhanli;
|
||||||
|
|
||||||
// for (let k in change) {
|
|
||||||
// await G.redis.set('hero', call.uid, hero._id, k as any, change[k]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
await G.mongodb.collection('hero').updateOne({uid: call.uid, _id: new ObjectId(hero._id)}, {
|
await G.mongodb.collection('hero').updateOne({uid: call.uid, _id: new ObjectId(hero._id)}, {
|
||||||
$set: {
|
$set: {
|
||||||
...change
|
...change
|
||||||
@ -41,13 +37,10 @@ export class HeroFun {
|
|||||||
|
|
||||||
/**获取英雄 */
|
/**获取英雄 */
|
||||||
static async getHero(call: call, oid: string) {
|
static async getHero(call: call, oid: string) {
|
||||||
//let data = await G.redis.get('hero', call.uid, oid);
|
|
||||||
//if (!data) { // 如果redis中的hero数据被清理掉 直接查询数据库
|
|
||||||
let {_id, ...info} = await G.mongodb.collection("hero").findOne({
|
let {_id, ...info} = await G.mongodb.collection("hero").findOne({
|
||||||
_id: G.mongodb.conversionId(oid)
|
_id: G.mongodb.conversionId(oid)
|
||||||
})
|
})
|
||||||
let data = Object.assign({_id: _id.toHexString()}, info)
|
let data = Object.assign({_id: _id.toHexString()}, info)
|
||||||
//}
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ export class LingZhuLaiXifun {
|
|||||||
// 隔天清零
|
// 隔天清零
|
||||||
if (_myData && PublicShared.chkSameDate(_myData.time, G.time)) {
|
if (_myData && PublicShared.chkSameDate(_myData.time, G.time)) {
|
||||||
_res = {
|
_res = {
|
||||||
num: _myData.num,
|
num: _myData.num || 0,
|
||||||
time: _myData.time,
|
time: _myData.time,
|
||||||
maxdps: _myData.maxdps
|
maxdps: _myData.maxdps
|
||||||
}
|
}
|
||||||
|
@ -181,11 +181,14 @@ export class PayFun {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 不要轻易改动这个方法,不允许集成业务逻辑在内部
|
||||||
|
* 如果有业务逻辑通过事件驱动,在支付成功后emit事件
|
||||||
|
*/
|
||||||
|
|
||||||
let conf: any = await this.getConf(payId, payArgs);
|
let conf: any = await this.getConf(payId, payArgs);
|
||||||
|
|
||||||
let prize = [...conf.prize];
|
let prize = [...conf.prize];
|
||||||
//let player = await G.redis.get('user', uid);
|
|
||||||
let player = await getGud(uid);
|
let player = await getGud(uid);
|
||||||
|
|
||||||
if (conf.firstPayPrize.length > 0) {
|
if (conf.firstPayPrize.length > 0) {
|
||||||
|
@ -228,9 +228,6 @@ export class PlayerFun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async changeAttr(uid: string, change: Partial<player>) {
|
static async changeAttr(uid: string, change: Partial<player>) {
|
||||||
//for (let k in change) {
|
|
||||||
//G.redis.set('user', uid, k as any, change[k]);
|
|
||||||
//}
|
|
||||||
setGud(uid, change);
|
setGud(uid, change);
|
||||||
|
|
||||||
G.mongodb.collection('user').updateOne({uid: uid}, {$set: change});
|
G.mongodb.collection('user').updateOne({uid: uid}, {$set: change});
|
||||||
@ -307,9 +304,6 @@ export class PlayerFun {
|
|||||||
firstTime: upObj.update.$setOnInsert.firstTime,
|
firstTime: upObj.update.$setOnInsert.firstTime,
|
||||||
lastTime: upObj.update.$setOnInsert.firstTime
|
lastTime: upObj.update.$setOnInsert.firstTime
|
||||||
};
|
};
|
||||||
//去掉item Redis相关
|
|
||||||
//G.redis.set('item', call.uid, atn.t, data);
|
|
||||||
|
|
||||||
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
|
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
|
||||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
|
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
|
||||||
addGameLog(call.uid, "_itemChange", {"additem": 1}, {
|
addGameLog(call.uid, "_itemChange", {"additem": 1}, {
|
||||||
@ -320,26 +314,14 @@ export class PlayerFun {
|
|||||||
} else {
|
} else {
|
||||||
if (item.num + atn.n <= 0) {
|
if (item.num + atn.n <= 0) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
//去掉item Redis相关
|
|
||||||
//G.redis.del('item', call.uid, atn.t),
|
|
||||||
|
|
||||||
G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t})
|
G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t})
|
||||||
]);
|
]);
|
||||||
//await G.redis.del('item', call.uid, atn.t);
|
|
||||||
//await G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t});
|
|
||||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, {num: 0});
|
call.addEventMsg('msg_s2c/ItemChange', atn.t, {num: 0});
|
||||||
addGameLog(call.uid, "_itemChange", {"delitem": 1}, {"itemId": atn.t})
|
addGameLog(call.uid, "_itemChange", {"delitem": 1}, {"itemId": atn.t})
|
||||||
} else {
|
} else {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
////去掉item Redis相关
|
|
||||||
//G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime),
|
|
||||||
//G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n),
|
|
||||||
|
|
||||||
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options)
|
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options)
|
||||||
]);
|
]);
|
||||||
// await G.redis.set('item', call.uid, atn.t, 'lastTime', upObj.update.$set.lastTime);
|
|
||||||
// await G.redis.numIncrBy('item', call.uid, atn.t, 'num', atn.n);
|
|
||||||
// await G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
|
|
||||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, {
|
call.addEventMsg('msg_s2c/ItemChange', atn.t, {
|
||||||
num: item.num + atn.n,
|
num: item.num + atn.n,
|
||||||
lastTime: upObj.update.$set.lastTime
|
lastTime: upObj.update.$set.lastTime
|
||||||
@ -381,11 +363,6 @@ export class PlayerFun {
|
|||||||
let id = result.insertedIds[key].toHexString();
|
let id = result.insertedIds[key].toHexString();
|
||||||
let {_id, ...ops} = v;
|
let {_id, ...ops} = v;
|
||||||
|
|
||||||
// G.redis.set('equip', call.uid, id, {
|
|
||||||
// _id: id,
|
|
||||||
// ...ops
|
|
||||||
// });
|
|
||||||
|
|
||||||
Wjjl.setVal(call.uid, `has_equip_color_${G.gc.equip[ops.equipId].colour}`, 1, false);
|
Wjjl.setVal(call.uid, `has_equip_color_${G.gc.equip[ops.equipId].colour}`, 1, false);
|
||||||
|
|
||||||
call.addEventMsg('msg_s2c/EquipChange', id, {
|
call.addEventMsg('msg_s2c/EquipChange', id, {
|
||||||
@ -458,19 +435,6 @@ export class PlayerFun {
|
|||||||
let id = result.insertedIds[key].toHexString();
|
let id = result.insertedIds[key].toHexString();
|
||||||
let {_id, ...ops} = v;
|
let {_id, ...ops} = v;
|
||||||
|
|
||||||
//https://www.codenong.com/53116318/
|
|
||||||
//新号创建时,hero下默认没有uid开头的key,这里会触发(error) ERR missing key at non-terminal path level错误
|
|
||||||
//hero/apiGetList里会G.redis.set('hero', call.uid, kvList);
|
|
||||||
//在这之后再执行下面的代码则不会报错
|
|
||||||
|
|
||||||
// if (await G.redis.type('hero', call.uid) != null) {
|
|
||||||
// G.redis.set('hero', call.uid, id, {
|
|
||||||
// _id: id,
|
|
||||||
// ...ops
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
call.addEventMsg('msg_s2c/HeroChange', id, {
|
call.addEventMsg('msg_s2c/HeroChange', id, {
|
||||||
_id: id,
|
_id: id,
|
||||||
...ops
|
...ops
|
||||||
@ -541,12 +505,6 @@ export class PlayerFun {
|
|||||||
insertData.forEach((v, key) => {
|
insertData.forEach((v, key) => {
|
||||||
let id = result.insertedIds[key].toHexString();
|
let id = result.insertedIds[key].toHexString();
|
||||||
let {_id, ...ops} = v;
|
let {_id, ...ops} = v;
|
||||||
|
|
||||||
// G.redis.set('shiwu', call.uid, id, {
|
|
||||||
// _id: id,
|
|
||||||
// ...ops
|
|
||||||
// });
|
|
||||||
|
|
||||||
call.addEventMsg('msg_s2c/ShiwuChange', id, {
|
call.addEventMsg('msg_s2c/ShiwuChange', id, {
|
||||||
_id: id,
|
_id: id,
|
||||||
...ops
|
...ops
|
||||||
@ -565,7 +523,6 @@ export class PlayerFun {
|
|||||||
*/
|
*/
|
||||||
static async cutShiwu(call: call, _idArr: string[]) {
|
static async cutShiwu(call: call, _idArr: string[]) {
|
||||||
for (let _id of _idArr) {
|
for (let _id of _idArr) {
|
||||||
// G.redis.del('shiwu', call.uid, _id);
|
|
||||||
G.mongodb.collection('shiwu').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
G.mongodb.collection('shiwu').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||||
call.addEventMsg('msg_s2c/ShiwuChange', _id, {num: 0});
|
call.addEventMsg('msg_s2c/ShiwuChange', _id, {num: 0});
|
||||||
addGameLog(call.uid, "_cutShiwu", {}, {_id: _id})
|
addGameLog(call.uid, "_cutShiwu", {}, {_id: _id})
|
||||||
|
@ -47,9 +47,6 @@ export class SchedulerNewDayLocalCtor extends Scheduler {
|
|||||||
...add
|
...add
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// for (let k in add) {
|
|
||||||
// G.redis.set('user', gud.uid, k as any, add[k] as any);
|
|
||||||
// }
|
|
||||||
setGud(gud.uid,add);
|
setGud(gud.uid,add);
|
||||||
}
|
}
|
||||||
G.server.sendMsgByUid(gud.uid, 'msg_s2c/PlayerChange', gud)
|
G.server.sendMsgByUid(gud.uid, 'msg_s2c/PlayerChange', gud)
|
||||||
|
@ -545,41 +545,6 @@ export class SchedulerWzryendDel extends SchedulerWzryAutoBaoMing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// export class SchedulerWzrycrossEmail extends SchedulerWzryAutoBaoMing {
|
|
||||||
// id: schedulerType = 'crosseamil_wzry';
|
|
||||||
// //每天晚上的20:15分,从跨服里拉取邮件数据到本地
|
|
||||||
// time = 72900;
|
|
||||||
// name = '拉跨服邮件到本服定时器(每天20:15)';
|
|
||||||
// type = 'day';
|
|
||||||
//
|
|
||||||
// async start() {
|
|
||||||
// let _res = await G.clientCross.callApi('wzry/WzFightData', { uid: '', isemail: true });
|
|
||||||
// if (_res.isSucc && Object.keys(_res.res.crossEmail).length) {
|
|
||||||
// let crossEmail = _res.res.crossEmail
|
|
||||||
// let delEmail = []
|
|
||||||
// for (let index = 0; index < crossEmail.length; index++) {
|
|
||||||
// const element = crossEmail[index];
|
|
||||||
// let _prize = element?.prizeData?.prize || []
|
|
||||||
// if (element?.prizeData) delete element.prizeData
|
|
||||||
// element["prize"] = _prize
|
|
||||||
// if (element.uid == "system") {
|
|
||||||
// delEmail.push(element._id)
|
|
||||||
// delete element._id
|
|
||||||
// EmailFun.addQuanFuEmail(element)
|
|
||||||
//
|
|
||||||
// } else if ( await G.redis.hGet('player:uids', element.uid)) {
|
|
||||||
// delEmail.push(element._id)
|
|
||||||
// delete element._id
|
|
||||||
// EmailFun.addEmail(element)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// await G.clientCross.callApi('wzry/UpdateFight', { uid: '', isdelemail: { isdel: true, email: delEmail } })
|
|
||||||
// }
|
|
||||||
// await this.record();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 分组
|
// 分组
|
||||||
export async function wzrygroup(userList) {
|
export async function wzrygroup(userList) {
|
||||||
let _u = shuffle(userList)
|
let _u = shuffle(userList)
|
||||||
|
@ -66,10 +66,6 @@ export class ShiwuFun {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (let k in change) {
|
|
||||||
// G.redis.set('shiwu', call.uid, shiwu._id, k as keyof shiwuType, change[k]);
|
|
||||||
// }
|
|
||||||
G.mongodb.collection('shiwu').updateOne(
|
G.mongodb.collection('shiwu').updateOne(
|
||||||
{uid: call.uid, _id: new ObjectId(shiwu._id)}, {$set: {...change}}
|
{uid: call.uid, _id: new ObjectId(shiwu._id)}, {$set: {...change}}
|
||||||
);
|
);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {CollectionShop} from '../module/collection_shop';
|
import { CollectionShop } from '../module/collection_shop';
|
||||||
import {ResOpen, shopItem} from '../shared/protocols/shop/PtlOpen';
|
import { ResOpen, shopItem } from '../shared/protocols/shop/PtlOpen';
|
||||||
import {PublicShared} from '../shared/public/public';
|
import { PublicShared } from '../shared/public/public';
|
||||||
import {ShiwuFun} from './shiwu';
|
import { ShiwuFun } from './shiwu';
|
||||||
|
|
||||||
type shopData = ResOpen;
|
type shopData = ResOpen;
|
||||||
type changeData = {
|
type changeData = {
|
||||||
[k in keyof shopData]: shopData[k]
|
[k in keyof (shopData & { version?: number | string })]: (shopData & { version?: number | string })[k]
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ShopFun {
|
export class ShopFun {
|
||||||
@ -47,24 +47,14 @@ export class ShopFun {
|
|||||||
return shopItems.filter(s => s.openDay <= sDay);
|
return shopItems.filter(s => s.openDay <= sDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**修改商店数据 */
|
|
||||||
// static async changeShopData(rId: string, shopId: string, shopData: Partial<shopData>, change: Partial<changeData>) {
|
|
||||||
//
|
|
||||||
// Object.assign(shopData, change);
|
|
||||||
//
|
|
||||||
// for (let k in change) {
|
|
||||||
// G.redis.set('shop', rId, shopId, k as keyof CollectionShop, change[k]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
static async changeShopData(uid: string, shopId: string, change: Partial<changeData>) {
|
static async changeShopData(uid: string, shopId: string, change: Partial<changeData>) {
|
||||||
let where = {uid: uid, shopId: shopId}
|
let where = { uid: uid, shopId: shopId }
|
||||||
G.mongodb.collection("shop").updateOne(where, {$set: change})
|
G.mongodb.collection("shop").updateOne(where, { $set: change })
|
||||||
}
|
}
|
||||||
|
|
||||||
static async initShopData(uid: string, shopId: string) {
|
static async initShopData(uid: string, shopId: string) {
|
||||||
let gud = await G.mongodb.collection("user").findOne({uid: uid}, {
|
let gud = await G.mongodb.collection("user").findOne({ uid: uid }, {
|
||||||
projection: {lv: 1, _id: 0}
|
projection: { lv: 1, _id: 0 }
|
||||||
})
|
})
|
||||||
let lv = gud?.lv || 1;
|
let lv = gud?.lv || 1;
|
||||||
|
|
||||||
@ -79,7 +69,7 @@ export class ShopFun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (await G.mongodb.collection("shop").findOneAndUpdate(
|
return (await G.mongodb.collection("shop").findOneAndUpdate(
|
||||||
{uid: uid, shopId: shopId},
|
{ uid: uid, shopId: shopId },
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
buyNum: {},
|
buyNum: {},
|
||||||
@ -90,11 +80,11 @@ export class ShopFun {
|
|||||||
lastFreeRefreshTime: G.time
|
lastFreeRefreshTime: G.time
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{upsert: true, returnDocument: 'after'}
|
{ upsert: true, returnDocument: 'after' }
|
||||||
)).value
|
)).value
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getShopData(uid: string, shopId: string) {
|
static async getShopData(uid: string, shopId: string, lv: number) {
|
||||||
let where = {
|
let where = {
|
||||||
uid: uid,
|
uid: uid,
|
||||||
shopId: shopId
|
shopId: shopId
|
||||||
@ -111,22 +101,16 @@ export class ShopFun {
|
|||||||
if (shopConf.freeRefreshInterval > 0 && G.time - shopData.lastFreeRefreshTime >= shopConf.freeRefreshInterval) {
|
if (shopConf.freeRefreshInterval > 0 && G.time - shopData.lastFreeRefreshTime >= shopConf.freeRefreshInterval) {
|
||||||
shopData.useFreeRefreshNum = 0;
|
shopData.useFreeRefreshNum = 0;
|
||||||
shopData.lastFreeRefreshTime = G.time;
|
shopData.lastFreeRefreshTime = G.time;
|
||||||
await this.changeShopData(uid, shopId, {useFreeRefreshNum: 0, lastFreeRefreshTime: G.time});
|
await this.changeShopData(uid, shopId, { useFreeRefreshNum: 0, lastFreeRefreshTime: G.time });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shopConf.version && shopConf.version != shopData.version) {
|
||||||
|
shopData.shopItems = this.getShopItems(shopId, lv);
|
||||||
|
await this.changeShopData(uid, shopId, { shopItems: shopData.shopItems, version: shopConf.version });
|
||||||
}
|
}
|
||||||
|
|
||||||
return shopData
|
return shopData
|
||||||
}
|
}
|
||||||
|
|
||||||
/**修改工会商店数据 */
|
|
||||||
// static async changeGHShopData(call: ApiCall, shopId: string, shopData: Partial<shopData>, change: Partial<changeData>) {
|
|
||||||
//
|
|
||||||
// Object.assign(shopData, change);
|
|
||||||
//
|
|
||||||
// for (let k in change) {
|
|
||||||
// G.redis.set('shop', call.conn.gud.ghId, shopId, k as keyof CollectionShop, change[k]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
static async changeGHShopData(ghid: string, shopId: string, change: Partial<changeData>) {
|
static async changeGHShopData(ghid: string, shopId: string, change: Partial<changeData>) {
|
||||||
this.changeShopData(ghid, shopId, change)
|
this.changeShopData(ghid, shopId, change)
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,22 @@ export class TanXianFun {
|
|||||||
static async changeData(call: ApiCall, change: dataChange) {
|
static async changeData(call: ApiCall, change: dataChange) {
|
||||||
|
|
||||||
G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { ...change } });
|
G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { ...change } });
|
||||||
|
let data = await this.getData(call);
|
||||||
for (let k in change) {
|
Object.assign(data, change);
|
||||||
G.redis.set('tanxian', call.uid, k as any, change[k]);
|
G.ioredis.set(`tanxian:${call.uid}`, JSON.stringify(data));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**获取探险数据 */
|
/**获取探险数据 */
|
||||||
static async getData(call: ApiCall, cache = true) {
|
static async getData(call: ApiCall, cache = true) {
|
||||||
if (cache && await G.redis.type('tanxian', call.uid) != null) return await G.redis.get('tanxian', call.uid);
|
if(cache){
|
||||||
|
let data = await G.ioredis.get(`tanxian:${call.uid}`);
|
||||||
|
if (data) return JSON.parse(data);
|
||||||
|
}
|
||||||
let { _id, uid, ...data } = await G.mongodb.collection('tanxian').findOne({ uid: call.uid });
|
let { _id, uid, ...data } = await G.mongodb.collection('tanxian').findOne({ uid: call.uid });
|
||||||
if (!data.eventTime) {
|
if (!data.eventTime) {
|
||||||
data.eventTime = G.time;
|
data.eventTime = G.time;
|
||||||
G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { eventTime: G.time } });
|
G.mongodb.collection('tanxian').updateOne({ uid: call.uid }, { $set: { eventTime: G.time } });
|
||||||
}
|
}
|
||||||
|
await G.ioredis.set(`tanxian:${call.uid}`, JSON.stringify(data));
|
||||||
await G.redis.set('tanxian', call.uid, data);
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
/**获取快速探险次数 */
|
/**获取快速探险次数 */
|
||||||
|
@ -202,10 +202,6 @@ export class UserFun {
|
|||||||
...add
|
...add
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// for (let k in add) {
|
|
||||||
// G.redis.set('user', gud.uid, k as any, add[k] as any);
|
|
||||||
// }
|
|
||||||
setGud(gud.uid, add);
|
setGud(gud.uid, add);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,18 +262,12 @@ export class UserFun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getGud(uid: string) {
|
static async getGud(uid: string) {
|
||||||
//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;
|
||||||
// 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);
|
gud = await getGud(uid);
|
||||||
|
|
||||||
let change = false;
|
let change = false;
|
||||||
@ -325,11 +315,6 @@ export class UserFun {
|
|||||||
/**激活聊天框 */
|
/**激活聊天框 */
|
||||||
static async activeChatFrame(uid: string, k: string, v: number) {
|
static async activeChatFrame(uid: string, k: string, v: number) {
|
||||||
let gud: player;
|
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);
|
gud = await getGud(uid);
|
||||||
|
|
||||||
let change = false;
|
let change = false;
|
||||||
@ -377,11 +362,6 @@ export class UserFun {
|
|||||||
/**激活造型 */
|
/**激活造型 */
|
||||||
static async activeModel(uid: string, k: string, v: number) {
|
static async activeModel(uid: string, k: string, v: number) {
|
||||||
let gud: player;
|
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);
|
gud = await getGud(uid);
|
||||||
|
|
||||||
let change = false;
|
let change = false;
|
||||||
|
@ -179,7 +179,7 @@ export class WangZheRongYaofun {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (win_num > 1) {
|
if (win_num > 1) {
|
||||||
return _score + win_num - 1
|
return _score + win_num
|
||||||
}
|
}
|
||||||
return _score
|
return _score
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,9 @@ const indexs: Partial<{ [k in keyof MongodbCollections]: IndexDescription[] }> =
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: {uid: 1}
|
key: {uid: 1}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: {type: 1}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
pata: [
|
pata: [
|
||||||
|
@ -77,8 +77,9 @@ async function clearRedis() {
|
|||||||
G.redis.fromatKey('hero'),
|
G.redis.fromatKey('hero'),
|
||||||
G.redis.fromatKey('equip'),
|
G.redis.fromatKey('equip'),
|
||||||
G.redis.fromatKey('shiwu'),
|
G.redis.fromatKey('shiwu'),
|
||||||
//G.redis.fromatKey('gbtx'),
|
G.redis.fromatKey('tanxian'),
|
||||||
//G.redis.fromatKey('dxlt'),
|
G.redis.fromatKey('gbtx'),
|
||||||
|
G.redis.fromatKey('dxlt'),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,13 +94,6 @@ export async function startAfter() {
|
|||||||
arr.forEach(async u => G.redis.hSet('player:uids', u.uid, 1))
|
arr.forEach(async u => G.redis.hSet('player:uids', u.uid, 1))
|
||||||
});
|
});
|
||||||
|
|
||||||
// G.mongodb.collection('payLog').find({}).toArray().then(arr => {
|
|
||||||
// arr.forEach(a => {
|
|
||||||
// let { _id, uid, ...logs } = a;
|
|
||||||
// G.redis.hSet('player:payLog', uid, logs)
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
} else if (G.argv.serverType == 'cross') {
|
} else if (G.argv.serverType == 'cross') {
|
||||||
|
|
||||||
RankKbzz.init();
|
RankKbzz.init();
|
||||||
|
14
src/setWs.ts
14
src/setWs.ts
@ -136,7 +136,7 @@ function setWs(server: WsServer<ServiceType>) {
|
|||||||
|
|
||||||
//处理API锁,极限情况下只锁10s,防止死锁
|
//处理API锁,极限情况下只锁10s,防止死锁
|
||||||
//在下方postApiReturnFlow里会解锁
|
//在下方postApiReturnFlow里会解锁
|
||||||
if (call.conn.apiLock[call.service.name] && new Date().getTime() - call.conn.requstApiTime[call.service.name] < 10000) {
|
if (call.conn.apiLock[call.service.name] && new Date().getTime() - call.conn.apiLock[call.service.name] < 10000) {
|
||||||
call.error('', {code: -100, message: '', time: 0});
|
call.error('', {code: -100, message: '', time: 0});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -182,18 +182,6 @@ function setWs(server: WsServer<ServiceType>) {
|
|||||||
if (node.call.service.name == 'user/Login' && node.return.isSucc) {
|
if (node.call.service.name == 'user/Login' && node.return.isSucc) {
|
||||||
//玩家uid已经登陆在线 通知账号在其他地方登录
|
//玩家uid已经登陆在线 通知账号在其他地方登录
|
||||||
const uid = node.return.res.gud.uid;
|
const uid = node.return.res.gud.uid;
|
||||||
// const loginConn = server.uid_connections[uid];
|
|
||||||
|
|
||||||
// let checkPid = await G.redis.hGet("uid2processId", uid);
|
|
||||||
// if (checkPid && ~~checkPid == process.pid && loginConn) {
|
|
||||||
// // 本进程踢线
|
|
||||||
// loginConn.sendMsg('msg_s2c/OtherLogin', loginConn.ip).then(v => {
|
|
||||||
// loginConn.close('otherLogin');
|
|
||||||
// });
|
|
||||||
// } else if (checkPid) {
|
|
||||||
// // 跨进程踢线,注意这里是异步的
|
|
||||||
// await G.server.sendMsgByUid(uid, 'msg_s2c/OtherLogin', '1', String(process.pid));
|
|
||||||
// }
|
|
||||||
server.uid_connections[uid] = node.call.conn;
|
server.uid_connections[uid] = node.call.conn;
|
||||||
setUidProcessId(uid);
|
setUidProcessId(uid);
|
||||||
}
|
}
|
||||||
|
@ -20264,10 +20264,24 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
|||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"name": "t",
|
"name": "t",
|
||||||
|
"type": {
|
||||||
|
"type": "Union",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
"type": {
|
"type": {
|
||||||
"type": "Number"
|
"type": "Number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"type": {
|
||||||
|
"type": "String"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"name": "n",
|
"name": "n",
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商店open接口
|
* 商店open接口
|
||||||
*/
|
*/
|
||||||
@ -32,7 +30,7 @@ export type shopItem = {
|
|||||||
/** 掉落类型 */
|
/** 掉落类型 */
|
||||||
'a': string;
|
'a': string;
|
||||||
/** 掉落id */
|
/** 掉落id */
|
||||||
't': number;
|
't': number | string;
|
||||||
/** 掉落数量 */
|
/** 掉落数量 */
|
||||||
'n': number;
|
'n': number;
|
||||||
/** 权重 */
|
/** 权重 */
|
||||||
|
@ -42,14 +42,6 @@ async function start() {
|
|||||||
// let c = await getItemNum('0_64e7024f1b2a9acc9e6900fb',['27382','12']);
|
// let c = await getItemNum('0_64e7024f1b2a9acc9e6900fb',['27382','12']);
|
||||||
// console.log('c',c)
|
// console.log('c',c)
|
||||||
|
|
||||||
redisClient.del([
|
|
||||||
G.redis.fromatKey('item'),
|
|
||||||
G.redis.fromatKey('equip'),
|
|
||||||
G.redis.fromatKey('hero'),
|
|
||||||
G.redis.fromatKey('shiwu'),
|
|
||||||
G.redis.fromatKey('gbtx'),
|
|
||||||
G.redis.fromatKey('dxlt'),
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//定义全局变量
|
//定义全局变量
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"moduleResolution": "node"
|
"moduleResolution": "node",
|
||||||
|
"experimentalDecorators": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src",
|
"src",
|
||||||
|
Loading…
Reference in New Issue
Block a user