BT7_030.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT7_030 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash digivolution cards and Draw 2 for each opponent's Digimon with no digivolution cards", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] For each card with [Hybrid] in its traits in this Digimon's digivolution cards, trash 1 digivolution card from the bottom of each of your opponent's Digimon. Then, for each Digimon your opponent has with no digivolution cards, <Draw 2>. (Draw 2 cards from your deck.)";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  28. {
  29. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. return true;
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. int hybridCount = card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardTraits.Contains("Hybrid"));
  52. if (hybridCount >= 1)
  53. {
  54. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  55. {
  56. foreach (Permanent selectedPermanent in card.Owner.Enemy.GetBattleAreaDigimons())
  57. {
  58. if (CanSelectPermanentCondition(selectedPermanent))
  59. {
  60. yield return ContinuousController.instance.StartCoroutine(
  61. CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  62. targetPermanent: selectedPermanent,
  63. trashCount: 1,
  64. isFromTop: false,
  65. activateClass: activateClass));
  66. }
  67. }
  68. }
  69. }
  70. int drawCount = 2 * card.Owner.Enemy.GetBattleAreaDigimons().Count((permanent) => permanent.HasNoDigivolutionCards);
  71. if (drawCount >= 1)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, drawCount, activateClass).Draw());
  74. }
  75. }
  76. }
  77. if (timing == EffectTiming.OnDestroyedAnyone)
  78. {
  79. ActivateClass activateClass = new ActivateClass();
  80. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  81. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  82. cardEffects.Add(activateClass);
  83. string EffectDiscription()
  84. {
  85. return "[On Deletion] You may play 1 blue level 4 or lower Digimon card with[Hybrid] in its form from your hand without paying its memory cost.";
  86. }
  87. bool CanSelectCardCondition(CardSource cardSource)
  88. {
  89. if (cardSource.IsDigimon)
  90. {
  91. if (cardSource.HasCardColor(CardColor.Blue))
  92. {
  93. if (cardSource.Level <= 4)
  94. {
  95. if (cardSource.CardTraits.Contains("Hybrid"))
  96. {
  97. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  98. {
  99. if (cardSource.HasLevel)
  100. {
  101. return true;
  102. }
  103. }
  104. }
  105. }
  106. }
  107. }
  108. return false;
  109. }
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  113. }
  114. bool CanActivateCondition(Hashtable hashtable)
  115. {
  116. if (CardEffectCommons.IsExistOnTrash(card))
  117. {
  118. if (card.Owner.HandCards.Count >= 1)
  119. {
  120. return true;
  121. }
  122. }
  123. return false;
  124. }
  125. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  126. {
  127. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  128. {
  129. List<CardSource> selectedCards = new List<CardSource>();
  130. int maxCount = 1;
  131. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  132. selectHandEffect.SetUp(
  133. selectPlayer: card.Owner,
  134. canTargetCondition: CanSelectCardCondition,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. maxCount: maxCount,
  138. canNoSelect: true,
  139. canEndNotMax: false,
  140. isShowOpponent: true,
  141. selectCardCoroutine: SelectCardCoroutine,
  142. afterSelectCardCoroutine: null,
  143. mode: SelectHandEffect.Mode.Custom,
  144. cardEffect: activateClass);
  145. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  146. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  147. yield return StartCoroutine(selectHandEffect.Activate());
  148. IEnumerator SelectCardCoroutine(CardSource cardSource)
  149. {
  150. selectedCards.Add(cardSource);
  151. yield return null;
  152. }
  153. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  154. cardSources: selectedCards,
  155. activateClass: activateClass,
  156. payCost: false,
  157. isTapped: false,
  158. root: SelectCardEffect.Root.Hand,
  159. activateETB: true));
  160. }
  161. }
  162. }
  163. return cardEffects;
  164. }
  165. }