import { ResGetList } from '../protocols/shiwu/PtlGetList';
import { heroShiWu, prizeType } from '../protocols/type';
import { PublicShared } from './public';

type shiwuType = ResGetList['list'][''];

export class ShiwuShared {
    static get _conf() {
        return G.gc.shiwucom.base;
    }
    /**
     * 获取饰物buff
     */
    static getShiwuBuff(shiwu: heroShiWu, buff: any = {}, heroId: string | number) {
        if (!buff.skillArr) buff.skillArr = [];

        PublicShared.mergeProperty(buff, PublicShared.arrBuffToObjectBuff(shiwu.jichu));

        shiwu.fujia.forEach(v => {
            let b = {};
            b[v.buffKey] = v.buffVal;
            PublicShared.mergeProperty(buff, b);
        });

        if (shiwu.zhuanshu && shiwu.zhuanshu.hero == heroId) {
            shiwu.zhuanshu.skill && buff.skillArr.push(shiwu.zhuanshu.skill);
            shiwu.zhuanshu.buff && PublicShared.mergeProperty(buff, PublicShared.arrBuffToObjectBuff(shiwu.zhuanshu.buff));
        }

        return buff;
    }
    /**获取洗练消耗 */
    static getConciseNeed(data: number): prizeType[];
    static getConciseNeed(data: Pick<shiwuType, 'shiwuId'>): prizeType[];
    static getConciseNeed(data: number | Pick<shiwuType, 'shiwuId'>) {
        if (typeof data == 'number') {
            return [G.gc.shiwucom.base.gaojixilian[data]];
        } else {
            return [
                {
                    a: this._conf.putongxilian.a,
                    t: this._conf.putongxilian.t,
                    n: PublicShared.eval(this._conf.putongxilian.n, { shiwulv: G.gc.shiwu[data.shiwuId].lv })
                }
            ];
        }
    }
    /**获取重铸消耗 */
    static getRecastNeed(type = 1) {
        return [this._conf['chongzhuneed' + type]];
    }
}