| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- 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>(
- T changeValue,
- bool isInheritedEffect,
- CardSource card,
- Func<bool> 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<T>(
- Permanent targetPermanent,
- T changeValue,
- bool isInheritedEffect,
- CardSource card,
- Func<bool> condition,
- string hashstring = null)
- {
- bool PermanentCondition(Permanent permanent)
- {
- return permanent == targetPermanent;
- }
- return ChangeSAttackStaticEffect(
- permanentCondition: PermanentCondition,
- changeValue: changeValue,
- isInheritedEffect: isInheritedEffect,
- card: card,
- condition: condition,
- hashstring: hashstring
- );
- }
- public static ChangeSAttackClass ChangeSAttackStaticEffect<T>(
- Func<Permanent, bool> permanentCondition,
- T changeValue,
- bool isInheritedEffect,
- CardSource card,
- Func<bool> condition,
- string hashstring = null)
- {
- bool isInt = typeof(T) == typeof(int);
- bool isIntFunc = typeof(T) == typeof(Func<int>);
- if (!isInt && !isIntFunc) return null;
- if (isInt && (int)(object)changeValue == 0) return null;
- if (isIntFunc && changeValue as Func<int> == null) return null;
- int _changeValue() => isInt ? (int)(object)changeValue : (changeValue as Func<int>)();
- 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 (hashstring != null)
- {
- changeSAttackClass.SetHashString(hashstring);
- }
- 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
- #region Static effect that inverts one's own SAttack
- public static InvertSAttackClass InvertSelfSAttackStaticEffect<T>(
- T changeValue,
- bool isInheritedEffect,
- CardSource card,
- Func<bool> condition)
- {
- bool CanUseCondition()
- {
- if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
- {
- if (condition == null || condition())
- {
- return true;
- }
- }
- return false;
- }
- return InvertTargetSAttackStaticEffect(
- targetPermanent: card.PermanentOfThisCard(),
- changeValue: changeValue,
- isInheritedEffect: isInheritedEffect,
- card: card,
- condition: CanUseCondition);
- }
- #endregion
- #region Static effect that inverts SAttack
- public static InvertSAttackClass InvertTargetSAttackStaticEffect<T>(
- Permanent targetPermanent,
- T changeValue,
- bool isInheritedEffect,
- CardSource card,
- Func<bool> condition)
- {
- bool PermanentCondition(Permanent permanent)
- {
- return permanent == targetPermanent;
- }
- return InvertSAttackStaticEffect(
- permanentCondition: PermanentCondition,
- changeValue: changeValue,
- isInheritedEffect: isInheritedEffect,
- card: card,
- condition: condition
- );
- }
- public static InvertSAttackClass InvertSAttackStaticEffect<T>(
- Func<Permanent, bool> permanentCondition,
- T changeValue,
- bool isInheritedEffect,
- CardSource card,
- Func<bool> condition)
- {
- bool isInt = typeof(T) == typeof(int);
- bool isIntFunc = typeof(T) == typeof(Func<int>);
- if (!isInt && !isIntFunc) return null;
- if (isInt && (int)(object)changeValue == 0) return null;
- if (isIntFunc && changeValue as Func<int> == null) return null;
- int _changeValue() => isInt ? (int)(object)changeValue : (changeValue as Func<int>)();
- bool isUpValue() => _changeValue() > 0;
- string effectName() => isUpValue() ? $"<Security A. +> are turned into <Security A. ->" : $"<Security A. -> are turned into <Security A. +>";
- InvertSAttackClass invertSAttackClass = new InvertSAttackClass();
- invertSAttackClass.SetUpICardEffect("", CanUseCondition, card);
- invertSAttackClass.SetUpChangeSAttackClass(changeInvertFunc: InvertValue, permanentCondition: PermanentCondition);
- invertSAttackClass.SetIsInheritedEffect(isInheritedEffect);
- invertSAttackClass.SetHashString($"InvertSecA_{card.CardID}");
- invertSAttackClass.SetIsBackgroundProcess(true);
- bool CanUseCondition(Hashtable hashtable)
- {
- if (condition == null || condition())
- {
- invertSAttackClass.SetEffectName(effectName());
- return true;
- }
- return false;
- }
- int InvertValue(Permanent permanent, int invertValue)
- {
- if (PermanentCondition(permanent))
- {
- invertValue += _changeValue();
- }
- return invertValue;
- }
- bool PermanentCondition(Permanent permanent)
- {
- if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
- {
- if (!permanent.TopCard.CanNotBeAffected(invertSAttackClass))
- {
- if (permanentCondition == null || permanentCondition(permanent))
- {
- return true;
- }
- }
- }
- return false;
- }
- return invertSAttackClass;
- }
- #endregion
- }
|