public BattleFighterBuff(BattleFighter owner, IBuffAction buffAction) { this.buffAction = buffAction; this.owner = owner; this.stackingList = new LinkedList<BuffStackInfo>(); this.paramMap = new Dictionary<int, int>(); this.permanent = buffAction.CDRound <= 0; }
/// <summary> /// is the buff count max, use when need real add buff, not cover or refresh </summary> /// <param name="buffAction"> /// @return </param> public virtual bool hasMaxCountBuff(IBuffAction buffAction) { if (size() >= BattleConstants.BUFF_MAX_SIZE) { return false; } int _maxSize = buffAction.Buff ? BattleConstants.BUFF_MAX_SIZE : BattleConstants.DEBUFF_MAX_SIZE; return hasMaxBuff(buffAction, _maxSize); }
public virtual void removeBuff(IBuffAction buffAction) { this.buffMap.Remove(buffAction.TypeB); }
public virtual bool hasSameBuff(IBuffAction buffAction) { return buffMap.ContainsKey(buffAction.TypeB); }
protected internal virtual int getBuffCount(IBuffAction buffAction) { Dictionary<int, BuffTypeHolder> _holderMap = getHolderMap(buffAction); int _buffCount = 0; foreach (BuffTypeHolder _holder in _holderMap.Values) { _buffCount += _holder.size(); } return _buffCount; }
protected internal virtual bool hasMaxBuff(IBuffAction buffAction, int maxSize) { return getBuffCount(buffAction) >= maxSize; }
public virtual void putHolderMap(IBuffAction buffAction, BuffTypeHolder typeHolder) { getHolderMap(buffAction)[buffAction.TypeA] = typeHolder; }
public virtual bool containBuffId(IBuffAction buffAction) { return containBuffId(buffAction.Id); }
public virtual BattleFighterBuff getBattleBuff(IBuffAction buffAction) { return get(buffAction.Id); }
protected internal virtual bool containTypeA(IBuffAction buffAction) { bool _containTypeA = false; bool _hasTypeAHolder = containTypeAInMap(buffAction); if (_hasTypeAHolder) { _containTypeA = !getBuffTypeHolder(buffAction).Empty; } return _containTypeA; }
protected internal virtual bool hasSameBuff(IBuffAction buffAction) { bool _contain = true; bool _typeA = containTypeA(buffAction); _contain = _typeA; if (_contain) { _contain = getBuffTypeHolder(buffAction).hasSameBuff(buffAction); } return _contain; }
protected internal virtual bool containTypeAInMap(IBuffAction buffAction) { return getHolderMap(buffAction).ContainsKey(buffAction.TypeA); }
public virtual BuffTypeHolder getBuffTypeHolder(IBuffAction buffAction) { BuffTypeHolder _holder = null; //if not contain type, there will be a null point exception in c# code if (containTypeAInMap(buffAction)) { _holder = getHolderMap(buffAction)[buffAction.TypeA]; } return _holder; }
protected internal virtual Dictionary<int, BuffTypeHolder> getHolderMap(IBuffAction buffAction) { return buffAction.Buff ? buffHolderMap : debuffHolderMap; }
protected internal virtual BattleFighterBuff createBattleFighterBuff(BattleFighter owner, IBuffAction buffAction) { BattleFighterBuff _buff = new BattleFighterBuff(owner, buffAction); return _buff; }
protected internal virtual BuffPolicyEnum calcPolicy(IBuffAction buffAction) { BuffPolicyEnum _policyType = null; if (containBuffId(buffAction)) { _policyType = BuffPolicyEnum.STACKING; } else { if (containTypeA(buffAction)) { _policyType = getBuffTypeHolder(buffAction).calcPolicy(buffAction); } else { _policyType = BuffPolicyEnum.COEXIST; } } return _policyType; }
protected internal virtual BuffPolicyEnum calcPolicy(IBuffAction buffAction) { return hasSameBuff(buffAction) ? BuffPolicyEnum.COVER : BuffPolicyEnum.OVERLAY; }
public virtual void createBuffHolder(IBuffAction buffAction) { BuffTypeHolder _holder = new BuffTypeHolder(buffAction.TypeA); putHolderMap(buffAction, _holder); }