import { ApiCall } from "tsrpc";
import { ReqDldRefre, ResDldRefre } from "../../cross/protocols/wzry/PtlDldRefre";

export default async function (call: ApiCall<ReqDldRefre, ResDldRefre>) {
    //let others = await G.mongodb.collection('wzry_fight').find({ uid: { $nin: [call.req.uid] } }).toArray();
    //let enemy = others.random();
    let enemy = await G.mongodb.collection('wzry_fight').aggregate([
        {
            $match: {uid: {
                $nin: [call.req.uid]
            }}
        },
        {
            $sample: { size: 1 }
        }
    ]).toArray();

    call.succ({ info: enemy[0].data })
}