import { ApiCall } from "tsrpc";
import { ReqTanHe, ResTanHe } from "../../shared/protocols/gonghui/PtlTanHe";
import { getGud } from "../../public/gud";

export default async function (call: ApiCall<ReqTanHe, ResTanHe>) {
    let GHdata = await call.conn.gonghui;
    //let createPlayer = await G.redis.get('user', GHdata.data.createPlayer.uid);
    let createPlayer = await getGud(GHdata.data.createPlayer.uid);

    if (GHdata.data.tanhe) call.error(globalThis.lng.gonghui_24);

    if (createPlayer && (G.time - createPlayer.logoutTime > G.gc.shili_com.tanheTime || G.time - createPlayer.loginTime > G.gc.shili_com.tanheTime)) {
        await GHdata.tanhe(call.uid);
        call.succ({});
    } else {
        call.error(globalThis.lng.gonghui_25);
    }
}