HJ_Server/src/api_s2c/conglinshoulie/ApiRec.ts
DESKTOP-15R5JU0\legu 97e070ea81 init
2023-11-17 12:02:12 +08:00

23 lines
871 B
TypeScript

import { ApiCall } from "tsrpc";
import { PlayerFun } from '../../public/player';
import { ReqRec, ResRec } from "../../shared/protocols/conglinshoulie/PtlRec";
import { HongDianChange } from "../hongdian/fun";
import { addStar, clslDb } from './ApiOpen';
export default async function (call: ApiCall<ReqRec, ResRec>) {
let conf = G.gc.clsl_com.fightWinPrize[call.req.index];
if (!conf) return call.errorCode(-1);
let db = await clslDb().findOne({ uid: call.uid, type: 'clsl' });
if ((db?.fightWinNum || 0) < conf.total || db?.recWinPrize?.includes(call.req.index)) return call.errorCode(-2);
await PlayerFun.sendPrize(call, conf.prize);
addStar(call, conf.star);
clslDb().updateOne({ uid: call.uid, type: 'clsl' }, { $push: { recWinPrize: call.req.index } });
HongDianChange.sendChangeKey(call.uid, ['clslhd'])
call.succ({});
}