Decode.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System.Collections;
  2. using System;
  3. public partial class CardEffectFactory
  4. {
  5. #region Trigger effect of [Decode] on oneself
  6. public static ActivateClass DecodeSelfEffect(CardColor color, int level, bool isInheritedEffect, CardSource card, Func<bool> condition,
  7. ICardEffect rootCardEffect = null)
  8. {
  9. Permanent targetPermanent = card.PermanentOfThisCard();
  10. bool CanUseCondition()
  11. {
  12. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  13. (condition == null || condition());
  14. }
  15. return DecodeEffect(color: color, level: level, targetPermanent: targetPermanent, isInheritedEffect: isInheritedEffect,
  16. condition: CanUseCondition, rootCardEffect: rootCardEffect, card);
  17. }
  18. #endregion
  19. #region Trigger effect of [Decode]
  20. public static ActivateClass DecodeEffect(CardColor color, int level, Permanent targetPermanent, bool isInheritedEffect,
  21. Func<bool> condition, ICardEffect rootCardEffect, CardSource card)
  22. {
  23. if (targetPermanent == null) return null;
  24. if (targetPermanent.TopCard == null) return null;
  25. if (card == null) return null;
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Decode", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, DataBase.DecodeEffectDiscription(color, level));
  29. activateClass.SetIsInheritedEffect(isInheritedEffect);
  30. if (rootCardEffect != null)
  31. {
  32. activateClass.SetIsInheritedEffect(false);
  33. activateClass.SetEffectSourcePermanent(targetPermanent);
  34. activateClass.SetRootCardEffect(rootCardEffect);
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  39. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
  40. !CardEffectCommons.IsByBattle(hashtable);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanActivateDecode(color, level, targetPermanent.TopCard, activateClass) &&
  45. (condition == null || condition());
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.DecodeProcess(color, level, targetPermanent.TopCard, activateClass);
  50. }
  51. return activateClass;
  52. }
  53. #endregion
  54. }