import { BuffConf } from "../conf/BuffConf";
import { BattleDataPool } from "./BattleDataPool";
import { BattleUtil } from "./BattleUtil";
import { DataBase } from "./DataBase";

//buff类型, 包含debuff
export class BuffData extends DataBase{
    //叠加类型
    cover:number;
    //来源  
    srcDataBaseID:number;
    srcDataBase:DataBase;
    
    //来源  
    targetDataBaseID:number;
    targetDataBase:DataBase;
    
    //动态参数------------
    //持续时间 同类buff可能刷新
    duration:number;
    //生命时间 当前buff已经存活时间
    lifeTime:number;
    //其他参数
    valueList:Array<number> = [];


    init(typeID:number,duration:number,valueList:Array<number>, src:DataBase,target:DataBase){
        super._init();
        this.typeID = typeID;
        this.srcDataBaseID = src.ID;
        this.srcDataBase = src;
        this.targetDataBaseID = target.ID;
        this.targetDataBase = target;

        let conf = BuffConf.data[typeID]
        if(conf){
            this.cover = conf.Cover;
        }
        else return null;

        this.duration = duration;
        this.valueList = valueList
        return this;
    }

    clear(){

        this.duration = 0;
        this.lifeTime = 0;
        //来源  
        this.srcDataBaseID = BattleUtil.TypeID_Init;
        this.srcDataBase = null;
    
        //来源  
        this.targetDataBaseID = BattleUtil.TypeID_Init;
        this.targetDataBase = null;

        this.valueList = []
    }
}

export let BuffDataPool = new BattleDataPool(BuffData,100)