BT15_030.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_030 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  15. }
  16. #region On Deletion/On Play Shared
  17. bool CanSelectPermanentCondition1(Permanent permanent)
  18. {
  19. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  20. {
  21. if (permanent.HasNoDigivolutionCards)
  22. {
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Trash digivolution cards and return 1 Digimon without digivolution cards to the deck bottom", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  35. cardEffects.Add(activateClass);
  36. string EffectDescription()
  37. {
  38. return "[On Play] Trash the top 2 digivolution cards of all of your opponent's Digimon. Then, return 2 of your opponent's Digimon with no digivolution cards to the deck bottom";
  39. }
  40. bool CanSelectPermanentCondition(Permanent permanent)
  41. {
  42. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  43. {
  44. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  67. {
  68. foreach (Permanent selectedPermanent in card.Owner.Enemy.GetBattleAreaDigimons())
  69. {
  70. if (CanSelectPermanentCondition(selectedPermanent))
  71. {
  72. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 2, isFromTop: true, activateClass: activateClass));
  73. }
  74. }
  75. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  76. {
  77. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  78. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  79. selectPermanentEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectPermanentCondition1,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: maxCount,
  85. canNoSelect: false,
  86. canEndNotMax: false,
  87. selectPermanentCoroutine: null,
  88. afterSelectPermanentCoroutine: null,
  89. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  90. cardEffect: activateClass);
  91. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  92. }
  93. }
  94. }
  95. #endregion
  96. #region On Deletion
  97. if (timing == EffectTiming.OnDestroyedAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("Trash digivolution cards and return 1 Digimon without digivolution cards to the deck bottom", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  102. cardEffects.Add(activateClass);
  103. string EffectDescription()
  104. {
  105. return "[On Deletion] Trash the top 2 digivolution cards of all of your opponent's Digimon. Then, return 2 of your opponent's Digimon with no digivolution cards to the deck bottom";
  106. }
  107. bool CanSelectPermanentCondition(Permanent permanent)
  108. {
  109. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  110. {
  111. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  112. {
  113. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  114. {
  115. return true;
  116. }
  117. }
  118. }
  119. return false;
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass); ;
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  128. {
  129. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  137. {
  138. foreach (Permanent selectedPermanent in card.Owner.Enemy.GetBattleAreaDigimons())
  139. {
  140. if (CanSelectPermanentCondition(selectedPermanent))
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 2, isFromTop: true, activateClass: activateClass));
  143. }
  144. }
  145. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  146. {
  147. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  148. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  149. selectPermanentEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectPermanentCondition1,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: maxCount,
  155. canNoSelect: false,
  156. canEndNotMax: false,
  157. selectPermanentCoroutine: null,
  158. afterSelectPermanentCoroutine: null,
  159. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  160. cardEffect: activateClass);
  161. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  162. }
  163. }
  164. }
  165. #endregion
  166. return cardEffects;
  167. }
  168. }
  169. }