Compare commits
6 Commits
1090a5f8df
...
4379a95d7e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4379a95d7e | ||
![]() |
124681d757 | ||
![]() |
826840455c | ||
![]() |
60d0e04e33 | ||
![]() |
6233a6672e | ||
![]() |
afd856af30 |
@ -4,6 +4,7 @@ import { PlayerFun } from "../../public/player";
|
||||
import { ReqSaoDang, ResSaoDang } from "../../shared/protocols/lingzhulaixi/PtlSaoDang";
|
||||
import { PublicShared } from "../../shared/public/public";
|
||||
import { HongDianChange } from "../hongdian/fun";
|
||||
import {ActionLog} from "../../public/actionLog/actionLog";
|
||||
|
||||
export default async function (call: ApiCall<ReqSaoDang, ResSaoDang>) {
|
||||
let _con = await LingZhuLaiXifun.getCon(call.req.bid)
|
||||
@ -91,6 +92,8 @@ export default async function (call: ApiCall<ReqSaoDang, ResSaoDang>) {
|
||||
prize = PublicShared.mergePrize(prize)
|
||||
await PlayerFun.sendPrize(call, prize)
|
||||
|
||||
ActionLog.addDayLog(call.uid, { key: "lingzhulaixi/PkBoss", val: _num });
|
||||
|
||||
// 扣除挑战次数
|
||||
_myData.num += _num
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { ApiCall } from "tsrpc";
|
||||
import { PlayerFun } from '../../public/player';
|
||||
import { TanXianFun } from '../../public/tanxian';
|
||||
import { TeQuanFun } from "../../public/tequan";
|
||||
import { ReqFastGuaJi, ResFastGuaJi } from "../../shared/protocols/tanxian/PtlFastGuaJi";
|
||||
import { TanXianShared } from '../../shared/public/tanxian';
|
||||
import { event_dldh_addPrize } from '../event/diaoluoduihuan/ApiOpen';
|
||||
import { HongDianChange } from "../hongdian/fun";
|
||||
import { getEventPrize } from './ApiEvent';
|
||||
import {ApiCall} from "tsrpc";
|
||||
import {PlayerFun} from '../../public/player';
|
||||
import {TanXianFun} from '../../public/tanxian';
|
||||
import {TeQuanFun} from "../../public/tequan";
|
||||
import {ReqFastGuaJi, ResFastGuaJi} from "../../shared/protocols/tanxian/PtlFastGuaJi";
|
||||
import {TanXianShared} from '../../shared/public/tanxian';
|
||||
import {event_dldh_addPrize} from '../event/diaoluoduihuan/ApiOpen';
|
||||
import {HongDianChange} from "../hongdian/fun";
|
||||
import {getEventPrize} from './ApiEvent';
|
||||
|
||||
export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) {
|
||||
|
||||
@ -20,8 +20,12 @@ export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) {
|
||||
// let notFree = data.useFastGuaJiNum >= freeNum && ((data?.zztqfreeNum || 0) >= tqFree && tqFree) && (data?.useFreeGuaJiNum || 0) <= freeNum
|
||||
let notFree = (data?.useFreeGuaJiNum || 0) >= freeNum
|
||||
if (notFree) {
|
||||
let num = G.gc.tanxian_com.fastGuaJiNeed[data.useFastGuaJiNum - freeNum ] || 0;
|
||||
let need = [{ a: 'attr', t: 'rmbmoney', n: num ? num : G.gc.tanxian_com.fastGuaJiNeed[G.gc.tanxian_com.fastGuaJiNeed.length - 1] }];
|
||||
let num = G.gc.tanxian_com.fastGuaJiNeed[data.useFastGuaJiNum - freeNum] || 0;
|
||||
let need = [{
|
||||
a: 'attr',
|
||||
t: 'rmbmoney',
|
||||
n: num ? num : G.gc.tanxian_com.fastGuaJiNeed[G.gc.tanxian_com.fastGuaJiNeed.length - 1]
|
||||
}];
|
||||
await PlayerFun.checkNeedIsMeet(call, need);
|
||||
await PlayerFun.cutNeed(call, need);
|
||||
}
|
||||
@ -32,15 +36,15 @@ export default async function (call: ApiCall<ReqFastGuaJi, ResFastGuaJi>) {
|
||||
let eventPrize = getEventPrize(call.conn.gud.lv, G.gc.tanxian_com.fastGuaJiTime, call.conn.gud.mapId, call.conn.gud.wxcLv?.lv);
|
||||
let _p = [].concat(prize.prize, prize.dlz, eventPrize.prize);
|
||||
// 过滤物品数量为0的道具。
|
||||
_p = _p.filter(x => x.n > 0)
|
||||
_p = _p.filter(x => x.n > 0)
|
||||
// await event_dldh_addPrize(_p, call, G.gc.tanxian_com.fastGuaJiTime);
|
||||
await PlayerFun.sendPrize(call, _p);
|
||||
|
||||
let setData = { useFastGuaJiNum: data.useFastGuaJiNum + 1, useFreeGuaJiNum: (data?.useFreeGuaJiNum || 0) + (notFree ? 0 : 1)}
|
||||
if ((data?.zztqfreeNum || 0) < tqFree && tqFree) setData["zztqfreeNum"] = tqFree
|
||||
TanXianFun.changeData(call, setData);
|
||||
|
||||
// (await call.conn.gonghui)?.addExp(20, call.uid);
|
||||
// let setData = { useFastGuaJiNum: data.useFastGuaJiNum + 1, useFreeGuaJiNum: (data?.useFreeGuaJiNum || 0) + (notFree ? 0 : 1)}
|
||||
let setData = {$inc: {useFastGuaJiNum: 1, useFreeGuaJiNum: (notFree ? 0 : 1)}}
|
||||
// if ((data?.zztqfreeNum || 0) < tqFree && tqFree) setData["zztqfreeNum"] = tqFree
|
||||
if ((data?.zztqfreeNum || 0) < tqFree && tqFree) setData["$set"] = {zztqfreeNum: tqFree}
|
||||
await TanXianFun.changeDataNew(call, setData);
|
||||
|
||||
HongDianChange.sendChangeKey(call.uid, ['taskhd', 'huodonghd']);
|
||||
|
||||
|
@ -1,16 +1,31 @@
|
||||
import {ApiCall} from 'tsrpc';
|
||||
import {ResOpen} from '../shared/protocols/tanxian/PtlOpen';
|
||||
import {TeQuanFun} from './tequan';
|
||||
import {addGameLog} from "../gameLog";
|
||||
|
||||
type dataChange = Partial<ResOpen>;
|
||||
|
||||
export class TanXianFun {
|
||||
/**修改探险数据 */
|
||||
/**
|
||||
* 修改探险数据
|
||||
* 此改动是为了不影响旧的数据结构
|
||||
* 下面changeDataNew和此方法一样
|
||||
*/
|
||||
static async changeData(call: ApiCall, change: dataChange) {
|
||||
G.mongodb.collection('tanxian').updateOne({uid: call.uid}, {$set: {...change}});
|
||||
let data = await this.getData(call);
|
||||
Object.assign(data, change);
|
||||
G.ioredis.setex(`tanxian:${call.uid}`, 600, JSON.stringify(data));
|
||||
let {_id, uid, ...data} = (await G.mongodb.collection('tanxian').findOneAndUpdate({uid: call.uid}, {$set: {...change}}, {returnDocument: 'after'})).value;
|
||||
G.ioredis.setex(`tanxian:${uid}`, 600, JSON.stringify(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 此方法是为了不影响旧的数据结构
|
||||
* 用inc去叠加用户限制的次数
|
||||
* @param call
|
||||
* @param change
|
||||
*/
|
||||
static async changeDataNew(call: ApiCall, change) {
|
||||
let {_id, uid, ...data} = (await G.mongodb.collection('tanxian').findOneAndUpdate({uid: call.uid}, change, {returnDocument: 'after'})).value;
|
||||
G.ioredis.setex(`tanxian:${uid}`, 600, JSON.stringify(data));
|
||||
addGameLog(call.uid, "_fastguajiChange", {}, data)
|
||||
}
|
||||
|
||||
/**获取探险数据 */
|
||||
|
14
src/setWs.ts
14
src/setWs.ts
@ -139,14 +139,14 @@ function setWs(server: WsServer<ServiceType>) {
|
||||
|
||||
//处理API锁,极限情况下只锁10s,防止死锁
|
||||
//在下方postApiReturnFlow里会解锁
|
||||
if (call.conn.apiLock[call.service.name] && new Date().getTime() - call.conn.apiLock[call.service.name] < 10000) {
|
||||
if (call.conn.apiLock[call.service.name] && call.conn.apiLock[call.service.name] > new Date().getTime()) {
|
||||
call.error('', {code: -100, message: '', time: 0});
|
||||
return null;
|
||||
}
|
||||
|
||||
//API锁定
|
||||
//API锁定到什么时候
|
||||
if (!writeList.includes(call.service.name)) {
|
||||
call.conn.apiLock[call.service.name] = new Date().getTime();
|
||||
call.conn.apiLock[call.service.name] = new Date().getTime() + 10000;
|
||||
}
|
||||
//API耗时统计
|
||||
call.conn.requstApiTime[call.service.name] = new Date().getTime();
|
||||
@ -196,7 +196,13 @@ function setWs(server: WsServer<ServiceType>) {
|
||||
}
|
||||
|
||||
//API解锁
|
||||
delete node.call.conn.apiLock[node.call.service.name];
|
||||
let now = new Date().getTime();
|
||||
|
||||
if(node.return.isSucc){
|
||||
node.call.conn.apiLock[node.call.service.name] = now+200;
|
||||
}else{
|
||||
delete node.call.conn.apiLock[node.call.service.name];
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user