import { PublicShared } from "../../public/public";
import { getBuffDPS, getFightAddHP } from "../fightDPS";
import { isDropBuff } from "../fightFun";
import { BuffBase } from "./buffBase";

export class Buff_liuxue extends BuffBase {
    start() {
        let skillConf = this.data.skillConf;
        this.remainingRounds = skillConf.round;
        this.role.fightControl.event.on('fightEvent_roundNums', this.fightEvent_roundNums.bind(this), this);
        this.fightEvent_roundNums({ turn: this.role.fightControl.roundNums });
    }
    dobuff() {
        super.dobuff();

        let dpsinfo = getBuffDPS(this.role, this.data.fromRole, {
            overlapTimes: this.overlapTimes,
            xiaoguocanshu: this.data.skillConf.xiaoguocanshu
        });

        let ov = this.role.getData('hp');
        this.role.fightControl.record({
            act: 'downHp',
            fromRole: this.role.rid,
            why: 'buff',
            buffId: this._BuffId,
            ov: ov,
            nv: 0
        });
        let recordIdx = this.role.fightControl.getRecordIdx();
        this.role.modifyHp(dpsinfo, {
            skillType: 'buff',
            skillId: this.data.buffid
        });
        this.role.fightControl.fixRecordByIdx(recordIdx, { nv: this.role.getData('hp') });
    }
    fightEvent_roundNums(data: { turn: number; }) {
        this.remainingRounds--;
        if (this.remainingRounds == -1) {
            this.clear('duration');
        } else {
            this.dobuff();
        }
    }
}

export class Buff_zhongdu extends Buff_liuxue { }
export class Buff_ranshao extends Buff_liuxue { }
export class Buff_maxdu extends Buff_liuxue { }

// export class Buff_addhp extends BuffBase {
//     dobuff() {
//         super.dobuff();
//         if (this.role.hasbuff("noaddhp")) return;

//         let dpsinfo = getFightAddHP(this.role, this.data.fromRole, {
//             pro: this.data.skillConf.xiaoguocanshu.pro,
//             type: this.data.skillConf.xiaoguocanshu.type
//         });

//         let ov = this.role.getData('hp');
//         this.role.fightControl.record({
//             act: 'addHp',
//             fromRole: this.role.rid,
//             why: 'buff',
//             buffId: this._BuffId,
//             ov: ov,
//             nv: 0
//         });
//         let recordIdx = this.role.fightControl.getRecordIdx();
//         this.role.modifyHp(dpsinfo, {
//             skillType: 'buff',
//             skillId: this.data.buffid
//         });
//         this.role.fightControl.fixRecordByIdx(recordIdx, { nv: this.role.getData('hp') });
//     }
// }

export class Buff_hudun extends BuffBase {
    dobuff() {
        super.dobuff();
        let pro = this.data.skillConf.xiaoguocanshu.pro;
        if (this.data.skillConf.xiaoguocanshu.gs) {
            pro = PublicShared.eval(this.data.skillConf.xiaoguocanshu.val, { slv: this.data.fromRole.skillLv });
        }
        this.role.hudunzhi += parseInt(pro);
    }
}

// export class Buff_zhongshang extends BuffBase {
//
// }

