import { ApiCall } from "tsrpc";
import { DxltFun } from '../../public/dxlt';
import { ReqNext, ResNext } from "../../shared/protocols/dixialeitai/PtlNext";
import { ResOpen } from '../../shared/protocols/dixialeitai/PtlOpen';
import { HongDianChange } from "../hongdian/fun";

export default async function (call: ApiCall<ReqNext, ResNext>) {

    let change: Partial<ResOpen> = {};
    let data = await DxltFun.getData(call);

    if (!G.gc.dxlt_layer[data.curLayer + 1]) return call.error(globalThis.lng.dixialeitai_7);

    change.curLayer = data.curLayer += 1;
    if (G.gc.dxlt_layer[change.curLayer].type == 2) {
        DxltFun.passLayerChange(data, change);
        DxltFun.changeShop(data, change);
        change.over = true;
    } else {
        change.over = false;
    }

    await DxltFun.changeData(call, change);

    HongDianChange.sendChangeKey(call.uid, ['dxlthd'])

    call.succ({
        change: change
    });
}