using System.Collections; using System.Collections.Generic; using System; using System.Linq; using UnityEngine; public partial class CardEffectFactory { #region Static effect that changes one's own SAttack public static ChangeSAttackClass ChangeSelfSAttackStaticEffect( T changeValue, bool isInheritedEffect, CardSource card, Func condition) { bool CanUseCondition() { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { if (condition == null || condition()) { return true; } } return false; } return ChangeTargetSAttackStaticEffect( targetPermanent: card.PermanentOfThisCard(), changeValue: changeValue, isInheritedEffect: isInheritedEffect, card: card, condition: CanUseCondition); } #endregion #region Static effect that changes SAttack public static ChangeSAttackClass ChangeTargetSAttackStaticEffect( Permanent targetPermanent, T changeValue, bool isInheritedEffect, CardSource card, Func condition) { bool PermanentCondition(Permanent permanent) { return permanent == targetPermanent; } return ChangeSAttackStaticEffect( permanentCondition: PermanentCondition, changeValue: changeValue, isInheritedEffect: isInheritedEffect, card: card, condition: condition ); } public static ChangeSAttackClass ChangeSAttackStaticEffect( Func permanentCondition, T changeValue, bool isInheritedEffect, CardSource card, Func condition) { bool isInt = typeof(T) == typeof(int); bool isIntFunc = typeof(T) == typeof(Func); if (!isInt && !isIntFunc) return null; if (isInt && (int)(object)changeValue == 0) return null; if (isIntFunc && changeValue as Func == null) return null; int _changeValue() => isInt ? (int)(object)changeValue : (changeValue as Func)(); bool isUpValue() => _changeValue() > 0; string effectName() => isUpValue() ? $"Security Attack +{_changeValue()}" : $"Security Attack {_changeValue()}"; ChangeSAttackClass changeSAttackClass = new ChangeSAttackClass(); changeSAttackClass.SetUpICardEffect("", CanUseCondition, card); changeSAttackClass.SetUpChangeSAttackClass(changeSAttackFunc: ChangeSAttack, permanentCondition: PermanentCondition, isUpDown: _isUpDown); if (isInheritedEffect) { changeSAttackClass.SetIsInheritedEffect(true); } bool CanUseCondition(Hashtable hashtable) { if (condition == null || condition()) { changeSAttackClass.SetEffectName(effectName()); return true; } return false; } int ChangeSAttack(Permanent permanent, int SAttack) { if (PermanentCondition(permanent)) { SAttack += _changeValue(); } return SAttack; } bool PermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)) { if (!permanent.TopCard.CanNotBeAffected(changeSAttackClass)) { if (permanentCondition == null || permanentCondition(permanent)) { return true; } } } return false; } CalculateOrder _isUpDown() { return CalculateOrder.UpDownValue; } return changeSAttackClass; } #endregion }