import { ApiCall } from "tsrpc";
import { ReqTakeOff, ResTakeOff } from "../../shared/protocols/heroskin/PtlTakeOff";
import { HeroFun } from "../../public/hero";

export default async function (call: ApiCall<ReqTakeOff, ResTakeOff>) {
    let hero = await HeroFun.getHero(call, call.req.heroOid);
    if (!hero) { // 英雄不存在
        call.error(lng.hero_1);
        return;
    }

    if (!hero.skin) { // 没有穿戴皮肤
        call.error(lng.hero_22);
        return;
    }

    await HeroFun.changeHeroAttr(call, hero, { skin: "" });

    call.succ({});
}