This commit is contained in:
ciniao 2023-12-14 16:07:54 +08:00
commit e0d9c40be3
10 changed files with 61 additions and 228 deletions

View File

@ -20,7 +20,7 @@ export default async function (call: ApiCall<ReqBuyLv, ResBuyLv>) {
let change: ResBuyLv['change'] = {};
change.lv = data.lv + lv;
change.exp = G.gc.zhanling.lv[change.lv];
change.exp = data.exp + 1000
G.mongodb.cEvent('zhanling').updateOne(
{ uid: call.uid, type: 'zhanling' },

View File

@ -2,6 +2,7 @@ import {ApiCall} from "tsrpc";
import {ReqOpen, ResOpen} from "../../../shared/protocols/event/zhoumolibao/PtlOpen";
import {PayFun} from "../../../public/pay";
import {HuoDongFun} from "../../../public/huodongfun";
import {PublicShared} from "../../../shared/public/public";
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
@ -13,8 +14,30 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let payIds = _hd?.data?.gift?.filter(i => i.payId)?.map(i => i.payId)
call.succ({
record: data.record,
record: data?.record || {},
buyLog: await PayFun.getPayLogs(call.uid, payIds)
})
}
export async function checkResetBuyLog(call: ApiCall) {
let zeroTime = PublicShared.getToDayZeroTime()
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
if (data.refreshTime && data.refreshTime > zeroTime) return
G.mongodb.cEvent(`zhoumolibao`).updateOne(
{uid: call.uid, type: `zhoumolibao`},
{$set: {record: {}}},
{upsert: true}
)
let _hd = (await HuoDongFun.gethdList(call, 9))[0]
let payIds = _hd?.data?.gift?.filter(i => i.payId)?.map(i => i.payId)
let payLogs = await PayFun.getPayLogs(call.uid, payIds)
let payLogLength = R.values(payLogs).filter(i => i.time < zeroTime).length
if (payLogLength) {
PayFun.delPayLog(call.uid, payIds.map(i => ({payId: i})))
}
}

View File

@ -11,13 +11,13 @@ export default async function (call: ApiCall<ReqReceive, ResReceive>) {
// 取奖励列表,判断是否有可领取奖励
let data = await G.mongodb.cEvent('zhoumolibao').findOne({uid: call.uid, type: 'zhoumolibao'})
let rec = data.record[call.req.id]
if (rec && rec >= gift?.buyNum) return call.errorCode(-2)
let rec = data?.record?.[call.req.id]
// if (rec && rec >= gift?.buyNum) return call.errorCode(-2)
await PlayerFun.sendPrize(call, gift.prize);
await G.mongodb.cEvent('zhoumolibao').updateOne({uid: call.uid, type: 'zhoumolibao'}, {
$inc: {[`record.${gift.id}`]: 1}
$inc: {[`record.${gift.id}`]: 1},
},{ upsert: true })
call.succ({})

View File

@ -1,23 +0,0 @@
import { ApiCall } from "tsrpc";
import { ReqDazao, ResDazao } from "../../shared/protocols/weixiuchang/PtlDazao";
import { PlayerFun } from "../../public/player";
import { PublicShared } from '../../shared/public/public';
export default async function (call: ApiCall<ReqDazao, ResDazao>) {
let [id, num] = [call.req.id, call.req.num];
let dzConf = G.gc.weixiuchang_dz[id];
if (!dzConf) {
return call.error(globalThis.lng.weixiuchang_1);
}
let need = [].concat(dzConf.item).map(v => { return { ...v, n: v.n * num }; });
await PlayerFun.checkNeedIsMeet(call, need);
let prize = [];
for (let i = 0; i < num; i++) {
prize = prize.concat(PublicShared.randomDropGroup(PublicShared.randomNum(0, 1) < dzConf.success ? dzConf.target : dzConf.lose));
}
prize = PublicShared.mergePrize(prize);
await PlayerFun.cutNeed(call, need);
await PlayerFun.addItem(call, prize);
call.succ({ prize: prize });
}

View File

@ -1,29 +0,0 @@
import { ApiCall } from "tsrpc";
import { ReqZuzhuang, ResZuzhuang } from "../../shared/protocols/weixiuchang/PtlZuzhuang";
import { PlayerFun } from "../../public/player";
export default async function (call: ApiCall<ReqZuzhuang, ResZuzhuang>) {
let data = call.conn.gud.wxcLv;
let conf = G.gc.weixiuchang_zz[data.lv + 1];
let req = call.req;
let newdata = { ...data };
if (req.type == 'sx') {
// 安装零部件
if (data.ids.length == conf.need.length) return call.error('', { code: -1, message: globalThis.lng.shiwu_6 });
if (typeof req.idx != 'number') return call.error('', { code: -2, message: globalThis.lng.shiwu_6 });
if (data.ids.includes(req.idx)) return call.error('', { code: -3, message: globalThis.lng.weixiuchang_2 });
let need = req.cutneed == 0 ? [conf.need[req.idx]] : [].concat(conf.need2[req.idx] || conf.need2[0]).map(v => { return { ...v, n: v.n * conf.need[req.idx].n }; });
let isMeet = await PlayerFun.checkNeedIsMeet(call, need);
if (!isMeet.isOk) return call.error('', { code: -4, message: '材料不足' });
await PlayerFun.cutNeed(call, need);
newdata.ids.push(req.idx);
} else {
// 升星 or 进阶
if (data.ids.length != conf.need.length) return call.error('', { code: -1, message: globalThis.lng.shiwu_6 });
newdata.ids.length = 0;
newdata.lv += 1;
}
await PlayerFun.addAttr(call, { wxcLv: newdata });
call.succ({});
}

View File

@ -46,8 +46,8 @@ export type eventType = {
xianshizhaomu: ResOpenXianshizhaomu & { refreshTime: number; };
qirichongzhi: Omit<ResOpenQirichongzhi, 'finished'>;
jierihuodong: Omit<ResOpenJierihuodong, 'taskFinish'> & { refreshTime: number; };
kaifujingsai: ResOpenKaifujingsai
zhoumolibao: ResOpenZhoumolibao
kaifujingsai: ResOpenKaifujingsai;
zhoumolibao: ResOpenZhoumolibao & { refreshTime: number; }
} & {
[k: `${number}jijin`]: ResOpenYuedujijin;
[k: `yangchengmubiao${number}`]: yangchengmubiao;

View File

@ -8,9 +8,9 @@ export type ReqOpen = {
export type ResOpen = {
record:{
[k: string]: number;
[k: string]: any;
}
buyLog:{
[k: string]: number;
[k: string]: any;
}
};

View File

@ -314,13 +314,11 @@ import { ReqRenownBuy, ResRenownBuy } from './user/PtlRenownBuy';
import { ReqRenownGetPrize, ResRenownGetPrize } from './user/PtlRenownGetPrize';
import { ReqRenownOpen, ResRenownOpen } from './user/PtlRenownOpen';
import { ReqTujian, ResTujian } from './user/PtlTujian';
import { ReqDazao, ResDazao } from './weixiuchang/PtlDazao';
import { ReqDecompose, ResDecompose } from './weixiuchang/PtlDecompose';
import { ReqExchange, ResExchange } from './weixiuchang/PtlExchange';
import { ReqOpen as ReqOpen_56, ResOpen as ResOpen_56 } from './weixiuchang/PtlOpen';
import { ReqUpLv, ResUpLv } from './weixiuchang/PtlUpLv';
import { ReqUpStar, ResUpStar } from './weixiuchang/PtlUpStar';
import { ReqZuzhuang, ResZuzhuang } from './weixiuchang/PtlZuzhuang';
import { ReqAutoBaoMing, ResAutoBaoMing } from './wzry/PtlAutoBaoMing';
import { ReqBaoMing, ResBaoMing } from './wzry/PtlBaoMing';
import { ReqcatFightLog, RescatFightLog } from './wzry/PtlcatFightLog';
@ -1495,10 +1493,6 @@ export interface ServiceType {
req: ReqTujian,
res: ResTujian
},
"weixiuchang/Dazao": {
req: ReqDazao,
res: ResDazao
},
"weixiuchang/Decompose": {
req: ReqDecompose,
res: ResDecompose
@ -1519,10 +1513,6 @@ export interface ServiceType {
req: ReqUpStar,
res: ResUpStar
},
"weixiuchang/Zuzhuang": {
req: ReqZuzhuang,
res: ResZuzhuang
},
"wzry/AutoBaoMing": {
req: ReqAutoBaoMing,
res: ResAutoBaoMing
@ -3341,151 +3331,141 @@ export const serviceProto: ServiceProto<ServiceType> = {
},
{
"id": 315,
"name": "weixiuchang/Dazao",
"type": "api"
},
{
"id": 316,
"name": "weixiuchang/Decompose",
"type": "api"
},
{
"id": 317,
"id": 316,
"name": "weixiuchang/Exchange",
"type": "api"
},
{
"id": 318,
"id": 317,
"name": "weixiuchang/Open",
"type": "api"
},
{
"id": 319,
"id": 318,
"name": "weixiuchang/UpLv",
"type": "api"
},
{
"id": 320,
"id": 319,
"name": "weixiuchang/UpStar",
"type": "api"
},
{
"id": 321,
"name": "weixiuchang/Zuzhuang",
"type": "api"
},
{
"id": 322,
"id": 320,
"name": "wzry/AutoBaoMing",
"type": "api"
},
{
"id": 323,
"id": 321,
"name": "wzry/BaoMing",
"type": "api"
},
{
"id": 324,
"id": 322,
"name": "wzry/catFightLog",
"type": "api"
},
{
"id": 325,
"id": 323,
"name": "wzry/CatGroup",
"type": "api"
},
{
"id": 326,
"id": 324,
"name": "wzry/DldFight",
"type": "api"
},
{
"id": 327,
"id": 325,
"name": "wzry/DldRefre",
"type": "api"
},
{
"id": 328,
"id": 326,
"name": "wzry/JingCai",
"type": "api"
},
{
"id": 329,
"id": 327,
"name": "wzry/JingCaiOpen",
"type": "api"
},
{
"id": 330,
"id": 328,
"name": "wzry/Open",
"type": "api"
},
{
"id": 331,
"id": 329,
"name": "wzry/UpdateFight",
"type": "api"
},
{
"id": 332,
"id": 330,
"name": "wzry/Wzzd",
"type": "api"
},
{
"id": 333,
"id": 331,
"name": "wzry/ZuanShiOpen",
"type": "api"
},
{
"id": 334,
"id": 332,
"name": "xstask/AllGet",
"type": "api"
},
{
"id": 335,
"id": 333,
"name": "xstask/Get",
"type": "api"
},
{
"id": 336,
"id": 334,
"name": "xstask/LvUp",
"type": "api"
},
{
"id": 337,
"id": 335,
"name": "xstask/OnekeyReceive",
"type": "api"
},
{
"id": 338,
"id": 336,
"name": "xstask/Open",
"type": "api"
},
{
"id": 339,
"id": 337,
"name": "xstask/Receive",
"type": "api"
},
{
"id": 340,
"id": 338,
"name": "xstask/Refresh",
"type": "api"
},
{
"id": 341,
"id": 339,
"name": "yongbingzhuzhan/Handle",
"type": "api"
},
{
"id": 342,
"id": 340,
"name": "zhanqianbushu/ChangePos",
"type": "api"
},
{
"id": 343,
"id": 341,
"name": "zhanqianbushu/Select",
"type": "api"
},
{
"id": 344,
"id": 342,
"name": "zhanqianbushu/Up",
"type": "api"
}
@ -11245,7 +11225,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"indexSignature": {
"keyType": "String",
"type": {
"type": "Number"
"type": "Any"
}
}
}
@ -11258,7 +11238,7 @@ export const serviceProto: ServiceProto<ServiceType> = {
"indexSignature": {
"keyType": "String",
"type": {
"type": "Number"
"type": "Any"
}
}
}
@ -21158,41 +21138,6 @@ export const serviceProto: ServiceProto<ServiceType> = {
"user/PtlTujian/ResTujian": {
"type": "Interface"
},
"weixiuchang/PtlDazao/ReqDazao": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "id",
"type": {
"type": "Number"
}
},
{
"id": 1,
"name": "num",
"type": {
"type": "Number"
}
}
]
},
"weixiuchang/PtlDazao/ResDazao": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "prize",
"type": {
"type": "Array",
"elementType": {
"type": "Reference",
"target": "type/prizeType"
}
}
}
]
},
"weixiuchang/PtlDecompose/ReqDecompose": {
"type": "Interface",
"properties": [
@ -21375,69 +21320,6 @@ export const serviceProto: ServiceProto<ServiceType> = {
}
]
},
"weixiuchang/PtlZuzhuang/ReqZuzhuang": {
"type": "Interface",
"properties": [
{
"id": 0,
"name": "type",
"type": {
"type": "Union",
"members": [
{
"id": 0,
"type": {
"type": "Literal",
"literal": "sx"
}
},
{
"id": 1,
"type": {
"type": "Literal",
"literal": "jj"
}
}
]
}
},
{
"id": 1,
"name": "cutneed",
"type": {
"type": "Union",
"members": [
{
"id": 0,
"type": {
"type": "Literal",
"literal": 0
}
},
{
"id": 1,
"type": {
"type": "Literal",
"literal": 1
}
}
]
},
"optional": true
},
{
"id": 2,
"name": "idx",
"type": {
"type": "Number"
},
"optional": true
}
]
},
"weixiuchang/PtlZuzhuang/ResZuzhuang": {
"type": "Interface"
},
"wzry/PtlAutoBaoMing/ReqAutoBaoMing": {
"type": "Interface",
"properties": [

View File

@ -1,9 +0,0 @@
import { prizeType } from "../type";
export type ReqDazao = {
id: number,
num: number
}
export type ResDazao = {
prize: prizeType[];
}

View File

@ -1,11 +0,0 @@
export type ReqZuzhuang = {
/**sx:安装零部件 jj:进阶or升星 */
type: 'sx' | 'jj';
/**0 材料消耗 1 购买消耗 */
cutneed?: 0 | 1;
idx?: number;
};
export type ResZuzhuang = {
};