import { TB } from "../../config/data/schema";
import GRoleDefault from "../base/role/GRoleDefault";
import { GSkillBase, GSkillState } from "./GSkill";


//怒气冷却
export default abstract class GSkillAngerBase implements GSkillBase {

    //怒气值
    anger:number = 0;
    //怒气最大值
    angerMax:number = 0;

    bind(role: GRoleDefault, info: TB.TbGRoleSkill): GSkillBase {
        throw new Error("Method not implemented.");
    }
    isRelease(): boolean {
        return this.anger >= this.angerMax;
    }
    release(): boolean {
        //是否可以释放技能
        if(!this.isRelease()) return false;
        this.anger = 0;
        return this.onRelease();
    }

    //子类实现释放
    abstract onRelease():boolean;


    //是否正在释放技能
    isReleasing(): boolean{
        return false;
    }

    state(): GSkillState {
        
        if(this.isReleasing()){
            return GSkillState.Releasing
        }

        if(this.isRelease())
            return GSkillState.Releasable
        else
            return GSkillState.NoRelease

    }
    onUpdate(dt: number) {
    }
    //返回进度条
    getProgress(): number {
        return this.anger / this.angerMax;
    }

}

