import { ApiCall } from "tsrpc";
import { ReqRefresh, ResRefresh } from "../../cross/protocols/kbzz/PtlRefresh";

export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
    let enemys = await G.mongodb.collection('kbzzGroupUser').find({ group: call.req.group, troop: { $nin: [call.req.troop] } }).toArray();
    enemys.sort(() => Math.random() - .5);

    let arr = enemys.slice(0, G.gc.kbzz.refreshEnemyNum).map(e => {
        return {
            info: e.info,
            troop: e.troop,
            result: null
        };
    });

    call.succ({
        enemy: arr
    });
}