EX7_046.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX7
  5. {
  6. public class EX7_046 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("De-Digivolve 1", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return
  21. "[On Play] <De-Digivolve 1> 1 of your opponent's Digimon (Trash the top card. You can't trash past level 3 cards).";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  26. }
  27. bool CanSelectPermanentCondition(Permanent permanent)
  28. {
  29. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  34. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  35. }
  36. IEnumerator ActivateCoroutine(Hashtable hashtable)
  37. {
  38. SelectPermanentEffect selectPermanentEffect =
  39. GManager.instance.GetComponent<SelectPermanentEffect>();
  40. selectPermanentEffect.SetUp(
  41. selectPlayer: card.Owner,
  42. canTargetCondition: CanSelectPermanentCondition,
  43. canTargetCondition_ByPreSelecetedList: null,
  44. canEndSelectCondition: null,
  45. maxCount: 1,
  46. canNoSelect: false,
  47. canEndNotMax: false,
  48. selectPermanentCoroutine: SelectPermanentCoroutine,
  49. afterSelectPermanentCoroutine: null,
  50. mode: SelectPermanentEffect.Mode.Custom,
  51. cardEffect: activateClass);
  52. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  53. "The opponent is selecting 1 Digimon to De-Digivolve.");
  54. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  55. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  56. {
  57. yield return ContinuousController.instance.StartCoroutine(
  58. new IDegeneration(permanent, 1, activateClass).Degeneration());
  59. }
  60. }
  61. }
  62. #endregion
  63. #region When Digivolving
  64. if (timing == EffectTiming.OnEnterFieldAnyone)
  65. {
  66. ActivateClass activateClass = new ActivateClass();
  67. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  68. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  69. cardEffects.Add(activateClass);
  70. string EffectDescription()
  71. {
  72. return
  73. "[When Digivolving] If your opponent doesn't have a level 5 or higher Digimon, gain 1 memory.";
  74. }
  75. bool CanUseCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  78. }
  79. bool CanActivateCondition(Hashtable hashtable)
  80. {
  81. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  82. card.Owner.CanAddMemory(activateClass) &&
  83. card.Owner.Enemy.GetBattleAreaPermanents()
  84. .Count(permanent => permanent.TopCard.HasLevel && permanent.Level >= 5) == 0;
  85. }
  86. IEnumerator ActivateCoroutine(Hashtable hashtable)
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  89. }
  90. }
  91. #endregion
  92. #region Opponent's Turn - ESS
  93. if (timing == EffectTiming.OnAllyAttack)
  94. {
  95. ActivateClass activateClass = new ActivateClass();
  96. activateClass.SetUpICardEffect("Switch attack target to this Digimon", CanUseCondition, card);
  97. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  98. activateClass.SetIsInheritedEffect(true);
  99. activateClass.SetHashString("AttackSwitch_EX7_046");
  100. cardEffects.Add(activateClass);
  101. string EffectDescription()
  102. {
  103. return
  104. "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may switch the attack target to this Digimon.";
  105. }
  106. bool AttackingPermanent(Permanent permanent)
  107. {
  108. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  113. CardEffectCommons.IsOpponentTurn(card) &&
  114. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanent);
  115. }
  116. bool CanActivateCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  119. GManager.instance.attackProcess.AttackingPermanent != null &&
  120. GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  121. }
  122. IEnumerator ActivateCoroutine(Hashtable hashtable)
  123. {
  124. yield return ContinuousController.instance.StartCoroutine(
  125. GManager.instance.attackProcess.SwitchDefender(activateClass, false, card.PermanentOfThisCard()));
  126. }
  127. }
  128. #endregion
  129. return cardEffects;
  130. }
  131. }
  132. }