Merge branch 'bugfix' into release
This commit is contained in:
commit
83c99c25bd
@ -120,7 +120,13 @@ export default async function (call: ApiCall<ReqBingo, ResBingo>) {
|
||||
}
|
||||
|
||||
} else if (shell[0] == 'heroMaxLv') {
|
||||
let heros = await G.redis.get('hero', call.uid);
|
||||
//let heros = await G.redis.get('hero', call.uid);
|
||||
|
||||
let s = await G.mongodb.collection('hero').find({
|
||||
uid: call.uid
|
||||
}).toArray();
|
||||
let heros = s.map(h => G.mongodb.conversionIdObj(h));
|
||||
|
||||
for (let [_id, hero] of Object.entries(heros)) {
|
||||
await HeroFun.changeHeroAttr(call, hero, {
|
||||
lv: Object.keys(G.gc.playerLv).length * 3,
|
||||
|
@ -4,7 +4,7 @@ import { ReqGetList, ResGetList } from "../../shared/protocols/equip/PtlGetList"
|
||||
|
||||
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
let list: ResGetList['list'] = {};
|
||||
let kvList: k_v<RedisCollections2['equip']> = {};
|
||||
//let kvList: k_v<RedisCollections2['equip']> = {};
|
||||
let arrList = await G.mongodb.collection('equip').find({ uid: call.uid }).toArray();
|
||||
|
||||
let equipCon = G.gc.equip
|
||||
@ -12,7 +12,7 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
let maxequiplv = 0
|
||||
arrList.forEach(v => {
|
||||
let d = G.mongodb.conversionIdObj(v);
|
||||
kvList[G.formatRedisKey(d._id)] = d;
|
||||
//kvList[G.formatRedisKey(d._id)] = d;
|
||||
list[d._id] = d;
|
||||
|
||||
if (v.lv > maxequiplv) maxequiplv = v.lv
|
||||
@ -24,7 +24,7 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({ uid: call.conn.uid, type: 'usertasklog' },
|
||||
{ $set: { maxequiplv: maxequiplv, equipcolor: color } }, { upsert: true })
|
||||
|
||||
G.redis.set('equip', call.uid, kvList);
|
||||
//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 { uid, _id, type, ...equips } = (recLshd || {});
|
||||
|
@ -14,7 +14,7 @@ export default async function (call: ApiCall<ReqOneKeyWear, ResOneKeyWear, Servi
|
||||
|
||||
let wearNum = 0;
|
||||
let wearData = hero.equip || {};
|
||||
let equipList = await G.redis.get('equip', call.conn.uid) || {};
|
||||
let equipList = await EquipFun.getAllEquips(call);
|
||||
let allEquip = Object.values(equipList);
|
||||
let heroIds = Object.values(call.conn.gud.heroPos).filter(i => !!i)
|
||||
|
||||
|
@ -11,7 +11,7 @@ import { PublicShared } from "../../shared/public/public";
|
||||
|
||||
export default async function (call: ApiCall<ReqStarUp, ResStarUp, ServiceType>) {
|
||||
|
||||
let equip = await G.redis.get('equip', call.uid, call.req.equipId);
|
||||
let equip = await EquipFun.getEquip(call, call.req.equipId);
|
||||
|
||||
if (!equip) return call.error(globalThis.lng.equip_1);
|
||||
if (!G.gc.equipstar[equip.equipId]) return call.error(globalThis.lng.equip_4);
|
||||
@ -28,7 +28,7 @@ export default async function (call: ApiCall<ReqStarUp, ResStarUp, ServiceType>)
|
||||
|
||||
for (let _id of call.req.equipArr) {
|
||||
//遍历客户端传过来的所有装备,如果不存在或处于穿戴中,则报错
|
||||
let equip = await G.redis.get('equip', call.conn.uid, _id);
|
||||
let equip = await EquipFun.getEquip(call, _id);
|
||||
if (!equip) return call.error(globalThis.lng.equip_6);
|
||||
if (equip.wearaId) return call.error(globalThis.lng.equip_7);
|
||||
equipArr.push(equip);
|
||||
|
@ -5,7 +5,7 @@ import { ServiceType } from '../../shared/protocols/serviceProto';
|
||||
import kfjsFun from "../../public/kaifujingsai";
|
||||
|
||||
export default async function (call: ApiCall<ReqTakeOff, ResTakeOff, ServiceType>) {
|
||||
let equip = await G.redis.get('equip', call.conn.uid, call.req.equipId);
|
||||
let equip = await EquipFun.getEquip(call, call.req.equipId);
|
||||
|
||||
if (!equip) return call.error(globalThis.lng.equip_1);
|
||||
if (!equip.wearaId) return call.error(globalThis.lng.equip_9);
|
||||
|
@ -12,7 +12,7 @@ export default async function (call: ApiCall<ReqWear, ResWear, ServiceType>) {
|
||||
if (!hero) return call.error(globalThis.lng.equip_10);
|
||||
if (hero.lv < G.gc.herocom.equipOpenLv) return call.error(`英雄${G.gc.herocom.equipOpenLv}级开启`);
|
||||
|
||||
let equip = await G.redis.get('equip', call.conn.uid, call.req.equipId);
|
||||
let equip = await EquipFun.getEquip(call, call.req.equipId);
|
||||
|
||||
if (!equip) return call.error(globalThis.lng.equip_1);
|
||||
if (equip.wearaId == hero._id) return call.error(globalThis.lng.equip_11);
|
||||
|
@ -31,7 +31,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||
|
||||
call.succ({
|
||||
...ops,
|
||||
day: PublicShared.getOpenServerDay(call.conn.gud.cTime),
|
||||
day: PublicShared.getOpenServerDay(),
|
||||
taskFinished: taskFinished
|
||||
});
|
||||
}
|
||||
@ -79,7 +79,7 @@ export async function getTaskVal(gud: player, taskTyps: string[]) {
|
||||
else if (t.indexOf('toDayPay') != -1) {
|
||||
let daystr = t.split('_')[1] || '1';
|
||||
let day = Number(daystr);
|
||||
let zeroTime = PublicShared.getToDayZeroTime(gud.cTime);
|
||||
let zeroTime = PublicShared.getToDayZeroTime(G.openTime);
|
||||
val[t] = await PayFun.getPayDaysAllPayNum(
|
||||
gud.uid,
|
||||
zeroTime + (day - 1) * 24 * 3600, zeroTime + day * 24 * 3600
|
||||
|
@ -2,20 +2,46 @@ import {ApiCall} from "tsrpc";
|
||||
import {GHManage} from '../../public/gonghui/manage';
|
||||
import {ReqGetList, ResGetList} from "../../shared/protocols/gonghui/PtlGetList";
|
||||
|
||||
async function getGongHuiZhanli(ghId:string):Promise<number>{
|
||||
//如果redis里有,则直接返回
|
||||
let zhanliRes = await G.ioredis.get(`gongHuiZhanLi:${ghId}`);
|
||||
if(zhanliRes){
|
||||
return parseInt(zhanliRes);
|
||||
}
|
||||
|
||||
let GHData = await GHManage.getGHList();
|
||||
let ghs = Object.values(GHData).map(item => item.data).filter(i => !!i.players);
|
||||
let fuids = R.flatten(ghs.map(i => i.players.map(j => j.uid)))
|
||||
let allRoles = await G.mongodb.find('user',{uid: {$in: fuids}},['uid','power'])
|
||||
let zhanlis = Object.fromEntries(allRoles.map(r => [r.uid, r.power]));
|
||||
|
||||
|
||||
for (let gh of ghs) {
|
||||
let uids = gh.players.map(p => p.uid);
|
||||
let zhanli = uids.map(u => (zhanlis[u] || 0)).reduce((a, b) => a + b);
|
||||
//重设redis的值,有效期1小时
|
||||
G.ioredis.setex(`gongHuiZhanLi:${gh._id}`,3600, zhanli);
|
||||
|
||||
if(gh._id == ghId){
|
||||
zhanliRes = zhanli;
|
||||
}
|
||||
}
|
||||
|
||||
return parseInt(zhanliRes||"0");
|
||||
}
|
||||
|
||||
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
|
||||
let arr: ResGetList['list'] = [];
|
||||
let GHData = await GHManage.getGHList();
|
||||
let ghs = Object.values(GHData).map(item => item.data).filter(i => !!i.players);
|
||||
|
||||
let fuids = R.flatten(ghs.map(i => i.players.map(j => j.uid)))
|
||||
|
||||
let allRoles = await G.mongodb.find('user',{uid: {$in: fuids}},['uid','power'])
|
||||
let zhanlis = Object.fromEntries(allRoles.map(r => [r.uid, r.power]));
|
||||
|
||||
// let fuids = R.flatten(ghs.map(i => i.players.map(j => j.uid)))
|
||||
// let allRoles = await G.mongodb.find('user',{uid: {$in: fuids}},['uid','power'])
|
||||
// let zhanlis = Object.fromEntries(allRoles.map(r => [r.uid, r.power]));
|
||||
for (let gh of ghs) {
|
||||
let uids = gh.players.map(p => p.uid);
|
||||
let zhanli = uids.map(u => (zhanlis[u] || 0)).reduce((a, b) => a + b);
|
||||
//let uids = gh.players.map(p => p.uid);
|
||||
//let zhanli = uids.map(u => (zhanlis[u] || 0)).reduce((a, b) => a + b);
|
||||
let zhanli = await getGongHuiZhanli(gh._id);
|
||||
arr.push({
|
||||
gh: gh,
|
||||
zhanli: zhanli
|
||||
|
@ -39,7 +39,7 @@ export default async function (call: ApiCall<ReqChangePos, ResChangePos>) {
|
||||
}
|
||||
} else if (call.req.state == 'change') {
|
||||
if (heroPos[call.req.pos]) {
|
||||
let unLoadHero = await G.redis.get('hero', call.uid, heroPos[call.req.pos]);
|
||||
let unLoadHero = await HeroFun.getHero(call, heroPos[call.req.pos]);
|
||||
unLoadHero && fightHeros.removeOne(id => id == unLoadHero.heroId);
|
||||
}
|
||||
if (fightHeros.includes(hero.heroId.toString())) return call.errorCode(-2);
|
||||
|
@ -4,7 +4,7 @@ import { ReqGetList, ResGetList } from "../../shared/protocols/hero/PtlGetList";
|
||||
|
||||
export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
let list: ResGetList['list'] = {};
|
||||
let kvList: k_v<RedisCollections2['hero']> = {};
|
||||
//let kvList: k_v<RedisCollections2['hero']> = {};
|
||||
let arrList = await G.mongodb.collection('hero').find({ uid: call.uid }).toArray();
|
||||
|
||||
let heroCon = G.gc.hero;
|
||||
@ -12,7 +12,7 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
let maxherolv = 0;
|
||||
arrList.forEach(v => {
|
||||
let d = G.mongodb.conversionIdObj(v);
|
||||
kvList[G.formatRedisKey(d._id)] = d;
|
||||
//kvList[G.formatRedisKey(d._id)] = d;
|
||||
list[d._id] = d;
|
||||
|
||||
if (v.lv > maxherolv) maxherolv = v.lv;
|
||||
@ -23,7 +23,7 @@ export default async function (call: ApiCall<ReqGetList, ResGetList>) {
|
||||
await G.mongodb.collection('playerInfo', 'usertasklog').updateOne({ uid: call.conn.uid, type: 'usertasklog' },
|
||||
{ $set: { maxherolv: maxherolv, herocolor: color } }, { upsert: true });
|
||||
|
||||
G.redis.set('hero', call.uid, kvList);
|
||||
//G.redis.set('hero', call.uid, kvList);
|
||||
|
||||
let recLshd = await G.mongodb.collection('playerInfo', 'lshd_hero').findOne({ uid: call.conn.uid, type: 'lshd_hero' });
|
||||
let { uid, _id, type, ...heros } = (recLshd || {});
|
||||
|
@ -39,7 +39,7 @@ export default async function (call: ApiCall<ReqJinJie, ResJinJie, ServiceType>)
|
||||
|
||||
let selectHeros: ResGetList['list'][''][] = [];
|
||||
for (let _id of call.req.idArr) {
|
||||
let _hero = await G.redis.get('hero', call.uid, _id);
|
||||
let _hero = await HeroFun.getHero(call, _id);
|
||||
if (!_hero) return call.error(globalThis.lng.hero_1);
|
||||
selectHeros.push(_hero);
|
||||
}
|
||||
|
@ -5,9 +5,16 @@ import {ReqYanShi, ResYanShi} from "../../shared/protocols/kuangdong/PtlYanShi";
|
||||
|
||||
export default async function (call: ApiCall<ReqYanShi, ResYanShi>) {
|
||||
let hdid = call.req.hdid
|
||||
let kdInfo = await KuangDongfun.getKaiCaiInfo(hdid)
|
||||
let con = await KuangDongfun.getCon(hdid)
|
||||
|
||||
if (!kdInfo) {
|
||||
let kdInfo
|
||||
if (con.public_map == 1){
|
||||
kdInfo = await KuangDongfun.getKaiCaiInfo(hdid)
|
||||
}else {
|
||||
kdInfo = await KuangDongfun.getKaiCaiInfo(hdid, call.uid)
|
||||
}
|
||||
|
||||
if (!kdInfo || !con) {
|
||||
return call.error('', {code: -1, message: globalThis.lng.kudangdong_1})
|
||||
}
|
||||
|
||||
@ -30,12 +37,15 @@ export default async function (call: ApiCall<ReqYanShi, ResYanShi>) {
|
||||
_need && await PlayerFun.cutNeed(call, _need);
|
||||
|
||||
kdInfo.yanshi = 8 * 3600
|
||||
if (!kdInfo.ctime) kdInfo.ctime = G.time
|
||||
if (!kdInfo.etime) kdInfo.etime = G.time
|
||||
if (!kdInfo.kdtype) kdInfo.kdtype = con.type
|
||||
|
||||
// 如果调用这个方法,会upsert,在没有查到数据的情况下,
|
||||
// 会插入空数据,全服玩家的查询列表接口都会报错
|
||||
// await KuangDongfun.setminingZhanLing(call.uid, hdid, { $set: { yanshi: kdInfo.yanshi } })
|
||||
await G.mongodb.collection('kuangdong').updateOne({uid: call.uid, hdid: hdid},
|
||||
{$set: {yanshi: kdInfo.yanshi}});
|
||||
{$set: kdInfo});
|
||||
|
||||
kdInfo._id = kdInfo._id.toString()
|
||||
let changeData = {
|
||||
|
@ -172,7 +172,7 @@ export class EmailFun {
|
||||
sendEmail.sid = uid.split('_')[0]
|
||||
}
|
||||
|
||||
if (prize.length > 0) {
|
||||
if (prize?.length > 0) {
|
||||
sendEmail.prizeData = {
|
||||
prize: email.prize,
|
||||
isGet: false
|
||||
@ -186,27 +186,29 @@ export class EmailFun {
|
||||
sendEmail.lngContent = email.lngContent
|
||||
}
|
||||
|
||||
if (!isCross) {
|
||||
let emailList = await this.getAllEmail(uid);
|
||||
if (emailList.length >= 50) {
|
||||
emailList.sort((a, b) => {
|
||||
let noPrizeA = a.prizeData == undefined ? 0 : 1;
|
||||
let noPrizeB = b.prizeData == undefined ? 0 : 1;
|
||||
let getA = a.prizeData?.isGet == true ? 0 : 1;
|
||||
let getB = b.prizeData?.isGet == true ? 0 : 1;
|
||||
//太亏了!换其他清理机制,getAllEmail是性能消耗大户
|
||||
//todo.. 换其他清理机制
|
||||
// if (!isCross) {
|
||||
// let emailList = await this.getAllEmail(uid);
|
||||
// if (emailList.length >= 50) {
|
||||
// emailList.sort((a, b) => {
|
||||
// let noPrizeA = a.prizeData == undefined ? 0 : 1;
|
||||
// let noPrizeB = b.prizeData == undefined ? 0 : 1;
|
||||
// let getA = a.prizeData?.isGet == true ? 0 : 1;
|
||||
// let getB = b.prizeData?.isGet == true ? 0 : 1;
|
||||
|
||||
if (noPrizeA != noPrizeB) {
|
||||
return noPrizeA - noPrizeB;
|
||||
} else if (getA != getB) {
|
||||
return getA - getB;
|
||||
}
|
||||
return a.createTime - b.createTime;
|
||||
});
|
||||
// if (noPrizeA != noPrizeB) {
|
||||
// return noPrizeA - noPrizeB;
|
||||
// } else if (getA != getB) {
|
||||
// return getA - getB;
|
||||
// }
|
||||
// return a.createTime - b.createTime;
|
||||
// });
|
||||
|
||||
this.removeEmail(uid, emailList[0]._id);
|
||||
G.server.sendMsgByUid(uid, 'msg_s2c/EmailDel', emailList[0]._id);
|
||||
}
|
||||
}
|
||||
// this.removeEmail(uid, emailList[0]._id);
|
||||
// G.server.sendMsgByUid(uid, 'msg_s2c/EmailDel', emailList[0]._id);
|
||||
// }
|
||||
// }
|
||||
|
||||
let _id = (await G.mongodb.collection('email').insertOne({
|
||||
ttl: new Date(), ...G.mongodb.conversionIdObj(sendEmail)
|
||||
|
@ -17,7 +17,7 @@ export class EquipFun {
|
||||
|
||||
//穿戴装备时该装备穿戴在另一个英雄身上
|
||||
if (change.wearaId != undefined && equip.wearaId && equip.wearaId != change.wearaId && changeHero) {
|
||||
let takeHero = await G.redis.get('hero', call.uid, equip.wearaId);
|
||||
let takeHero = await HeroFun.getHero(call, equip.wearaId);
|
||||
if (takeHero) {
|
||||
let _equip = Object.assign({}, takeHero.equip);
|
||||
_equip[G.gc.equip[equip.equipId].type] = '';
|
||||
@ -27,9 +27,9 @@ export class EquipFun {
|
||||
|
||||
Object.assign(equip, change);
|
||||
|
||||
for (let k in change) {
|
||||
G.redis.set('equip', call.uid, equip._id, k as keyof CollectionEquip, change[k]);
|
||||
}
|
||||
// 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}});
|
||||
call.addEventMsg('msg_s2c/EquipChange', equip._id, change);
|
||||
}
|
||||
@ -37,24 +37,37 @@ export class EquipFun {
|
||||
/**
|
||||
* 获取装备
|
||||
*/
|
||||
static async getEquip(call: ApiCall, oid: string): Promise<CollectionEquip>;
|
||||
static async getEquip(call: ApiCall, oid: string[]): Promise<CollectionEquip[]>;
|
||||
static async getEquip(call: ApiCall, oid: string | string[]) {
|
||||
static async getEquip(call: ApiCall, oid?: string): Promise<CollectionEquip>;
|
||||
static async getEquip(call: ApiCall, oid?: string[]): Promise<CollectionEquip[]>;
|
||||
static async getEquip(call: ApiCall, oid?: string | string[]) {
|
||||
if (typeof oid == 'string') {
|
||||
let data = await G.redis.get('equip', call.uid, oid);
|
||||
if (!data) {
|
||||
let {_id, ...info} = await G.mongodb.collection('equip').findOne({
|
||||
_id: G.mongodb.conversionId(oid)
|
||||
})
|
||||
data = Object.assign({_id: _id.toHexString()}, info)
|
||||
}
|
||||
let data = Object.assign({_id: _id.toHexString()}, info)
|
||||
return data
|
||||
} else {
|
||||
let equips = await G.mongodb.collection('equip').find({
|
||||
let filter = {
|
||||
uid: call.uid,
|
||||
_id: {$in: oid.map(v => G.mongodb.conversionId(v))}
|
||||
}).toArray();
|
||||
}
|
||||
if(oid && oid.length > 0){
|
||||
filter['_id'] = {$in: oid.map(v => G.mongodb.conversionId(v))}
|
||||
}
|
||||
let equips = await G.mongodb.collection('equip').find(filter).toArray();
|
||||
return equips.map(v => G.mongodb.conversionIdObj(v));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的装备
|
||||
* 并对返回结果进行格式化,兼容原来的redis返回的格式
|
||||
*/
|
||||
static async getAllEquips(call: ApiCall):Promise<k_v<CollectionEquip>>{
|
||||
let res = {};
|
||||
let equips:CollectionEquip[] = await this.getEquip(call,[]);
|
||||
equips.map(v => {
|
||||
res['_'+v._id] = v;
|
||||
});
|
||||
return res;
|
||||
}
|
||||
}
|
@ -18,9 +18,11 @@ export async function clearGud(uid) {
|
||||
G.ioredis.del(`gudVersion:${uid}_pid`);
|
||||
G.ioredis.del(`gudVersion:${uid}_ver`);
|
||||
}
|
||||
G.redis.del("equip",uid);
|
||||
G.redis.del("hero",uid);
|
||||
G.redis.del("shiwu",uid);
|
||||
|
||||
if(await G.redis.type('tanxian', uid)){
|
||||
console.log('清空tanxian Redis',uid);
|
||||
G.redis.del("tanxian",uid);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -24,9 +24,9 @@ export class HeroFun {
|
||||
hero.zhanli = HeroShared.getHeroZhanLi(hero, call.otherBuff, Object.values(call.conn.gud.heroPos).indexOf(hero._id));
|
||||
change.zhanli = hero.zhanli;
|
||||
|
||||
for (let k in change) {
|
||||
await G.redis.set('hero', call.uid, hero._id, k as any, change[k]);
|
||||
}
|
||||
// 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)}, {
|
||||
$set: {
|
||||
@ -41,13 +41,13 @@ export class HeroFun {
|
||||
|
||||
/**获取英雄 */
|
||||
static async getHero(call: call, oid: string) {
|
||||
let data = await G.redis.get('hero', call.uid, oid);
|
||||
if (!data) { // 如果redis中的hero数据被清理掉 直接查询数据库
|
||||
//let data = await G.redis.get('hero', call.uid, oid);
|
||||
//if (!data) { // 如果redis中的hero数据被清理掉 直接查询数据库
|
||||
let {_id, ...info} = await G.mongodb.collection("hero").findOne({
|
||||
_id: G.mongodb.conversionId(oid)
|
||||
})
|
||||
data = Object.assign({_id: _id.toHexString()}, info)
|
||||
}
|
||||
let data = Object.assign({_id: _id.toHexString()}, info)
|
||||
//}
|
||||
return data
|
||||
}
|
||||
|
||||
|
@ -478,9 +478,10 @@ export class PayFun {
|
||||
* 获取某个时间段内 玩家的充值总金额
|
||||
*/
|
||||
static async getPayDaysAllPayNum(uid: string, sTime: number, eTime: number) {
|
||||
let logs = await G.mongodb.collection('dayPay').find({uid: uid}).toArray() || [];
|
||||
|
||||
logs = logs.filter(log => log.time >= sTime && log.time < eTime);
|
||||
let logs = await G.mongodb.collection('dayPay').find({
|
||||
uid: uid,
|
||||
time: {$gte: sTime, $lt: eTime}
|
||||
}).toArray() || [];
|
||||
|
||||
if (logs.length <= 0) return 0;
|
||||
return logs.map(log => log.payNum).reduce((a, b) => a + b);
|
||||
|
@ -350,10 +350,10 @@ export class PlayerFun {
|
||||
let id = result.insertedIds[key].toHexString();
|
||||
let {_id, ...ops} = v;
|
||||
|
||||
G.redis.set('equip', call.uid, id, {
|
||||
_id: id,
|
||||
...ops
|
||||
});
|
||||
// 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);
|
||||
|
||||
@ -432,12 +432,12 @@ export class PlayerFun {
|
||||
//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
|
||||
});
|
||||
}
|
||||
// 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, {
|
||||
|
@ -38,7 +38,7 @@ export class ShiwuFun {
|
||||
|
||||
//穿戴饰物时该装备穿戴在另一个英雄身上
|
||||
if (change.wearId != undefined && shiwu.wearId && shiwu.wearId != change.wearId && changeHero) {
|
||||
let takeHero = await G.redis.get('hero', call.uid, shiwu.wearId);
|
||||
let takeHero = await HeroFun.getHero(call, shiwu.wearId);
|
||||
if (takeHero) {
|
||||
let _shiwu = Object.assign({}, takeHero.shiwu);
|
||||
let _pos = Object.keys(_shiwu).filter(pos => _shiwu[pos]._id == shiwu._id)[0];
|
||||
@ -55,7 +55,7 @@ export class ShiwuFun {
|
||||
|
||||
//属性发生变化并且穿戴在英雄身上时
|
||||
if (change.wearId == undefined && shiwu.wearId) {
|
||||
let takeHero = await G.redis.get('hero', call.uid, shiwu.wearId);
|
||||
let takeHero = await HeroFun.getHero(call, shiwu.wearId);
|
||||
if (takeHero) {
|
||||
let _shiwu = Object.assign({}, takeHero.shiwu);
|
||||
let _pos = Object.keys(_shiwu).filter(pos => _shiwu[pos]._id == shiwu._id)[0];
|
||||
|
@ -2,6 +2,7 @@ import {
|
||||
Collection,
|
||||
CreateIndexesOptions,
|
||||
Db,
|
||||
FindCursor,
|
||||
IndexDescription,
|
||||
IndexSpecification,
|
||||
MongoClient,
|
||||
@ -18,6 +19,7 @@ import {HuoDongFun} from './public/huodongfun';
|
||||
import {zbsGroup} from './api_s2c/hbzb/zbs/fun';
|
||||
import {clusterRunOnce} from './clusterUtils';
|
||||
import { PublicShared } from './shared/public/public';
|
||||
import { addGameLog } from './gameLog';
|
||||
|
||||
const indexs: Partial<{ [k in keyof MongodbCollections]: IndexDescription[] }> = {
|
||||
item: [
|
||||
@ -627,3 +629,26 @@ export class _mongodb {
|
||||
return this.db.indexInformation(name)
|
||||
}
|
||||
}
|
||||
|
||||
//@ts-ignore
|
||||
FindCursor.prototype._toArray = FindCursor.prototype.toArray;
|
||||
//@ts-ignore
|
||||
FindCursor.prototype.toArray = async function(){
|
||||
let rss = await this._toArray();
|
||||
|
||||
//如果返回的数据超过50条
|
||||
if(rss.length>50){
|
||||
addGameLog("system","findCount",null,{
|
||||
collection: this.namespace.collection,
|
||||
db:this.namespace.db,
|
||||
count:rss.length
|
||||
})
|
||||
console.log("system,findCount",{
|
||||
collection: this.namespace.collection,
|
||||
db:this.namespace.db,
|
||||
count:rss.length
|
||||
})
|
||||
console.trace();
|
||||
}
|
||||
return rss;
|
||||
}
|
@ -60,10 +60,9 @@ export async function initRedis() {
|
||||
//启动前清理redis残余数据
|
||||
clusterRunOnce(async () => {
|
||||
await clearRedis();
|
||||
})
|
||||
|
||||
if (G.config.cleanRedis) await redisClient.flushDb();
|
||||
await setRedis();
|
||||
})
|
||||
if (G.config.cleanRedis) await redisClient.flushDb();
|
||||
console.log('connect redis succ');
|
||||
}
|
||||
|
||||
@ -75,9 +74,9 @@ async function clearRedis() {
|
||||
G.redis.fromatKey('jjc'),
|
||||
G.redis.fromatKey('user'),
|
||||
G.redis.fromatKey('item'),
|
||||
//G.redis.fromatKey('equip'),
|
||||
//G.redis.fromatKey('hero'),
|
||||
//G.redis.fromatKey('shiwu'),
|
||||
G.redis.fromatKey('hero'),
|
||||
G.redis.fromatKey('equip'),
|
||||
G.redis.fromatKey('shiwu'),
|
||||
//G.redis.fromatKey('gbtx'),
|
||||
//G.redis.fromatKey('dxlt'),
|
||||
])
|
||||
|
@ -23,6 +23,7 @@ export class HeroShared {
|
||||
|
||||
return allBuff;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取英雄基本属性
|
||||
* @param hero 英雄数据
|
||||
@ -286,6 +287,7 @@ export class HeroShared {
|
||||
|
||||
return buff;
|
||||
};
|
||||
|
||||
/**修正属性 数值取整*/
|
||||
static amendAttr(buff: k_v<number>) {
|
||||
for (let k in buff) {
|
||||
@ -294,6 +296,7 @@ export class HeroShared {
|
||||
buff[k] = Math.floor(buff[k]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取英雄战力
|
||||
* @param hero 英雄数据
|
||||
@ -303,6 +306,7 @@ export class HeroShared {
|
||||
let buff = this.getHeroBasicAttr(hero, otherBuff, pos);
|
||||
return this.computeHeroZhanLi(buff);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算英雄战力
|
||||
*/
|
||||
@ -313,6 +317,7 @@ export class HeroShared {
|
||||
let def = buff.def || 0;
|
||||
let hp = buff.hp || 0;
|
||||
let speed = buff.speed || 0;
|
||||
let speedpro = buff.speedpro || 0;
|
||||
let hppro = buff.hppro || 0;
|
||||
let dpspro = buff.dpspro || 0;
|
||||
let undpspro = buff.undpspro || 0;
|
||||
@ -329,11 +334,11 @@ export class HeroShared {
|
||||
(maxdps * .75) +
|
||||
(def * 1.03) +
|
||||
(hp * 1) +
|
||||
(speed * 21.28) +
|
||||
(hp * hppro * .5) +
|
||||
(speed * (speedpro + 1) * 21.28) +
|
||||
((mindps + maxdps) / 2 * dpspro * .75) +
|
||||
(hp * undpspro * .6) +
|
||||
((mindps + maxdps) / 2 * xixuepro * 1) +
|
||||
((mindps + maxdps) / 2 * xixuepro) +
|
||||
((mindps + maxdps) / 2 * baoshangpro * .75) +
|
||||
((mindps + maxdps) / 2 * shanbipro * .5) +
|
||||
((mindps + maxdps) / 2 * mingzhongpro * .5) +
|
||||
@ -341,6 +346,7 @@ export class HeroShared {
|
||||
(hp * pvpdpsdrop * .5)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取英雄升级消耗
|
||||
* @param id 英雄id
|
||||
@ -353,6 +359,7 @@ export class HeroShared {
|
||||
{a: 'attr', t: 'jinbi', n: G.gc.herolvup[lv].jinbineed}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取英雄进阶消耗
|
||||
* @param id 英雄id
|
||||
|
Loading…
Reference in New Issue
Block a user