23 lines
871 B
TypeScript
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({});
|
|
} |