BT5_087.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 BT5_087 : 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 3 cards from deck top and play Digimon", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Trash the top 3 cards of your deck. Then, you may play up to 2 black and/or purple Digimon cards with play costs of 8 or less from your trash without paying their memory costs.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsDigimon)
  26. {
  27. if (cardSource.GetCostItself <= 8)
  28. {
  29. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  30. {
  31. if (cardSource.HasCardColor(CardColor.Black))
  32. {
  33. return true;
  34. }
  35. if (cardSource.HasCardColor(CardColor.Purple))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleArea(card))
  51. {
  52. return true;
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(3, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  59. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  60. {
  61. int maxCount = Math.Min(2, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  62. List<CardSource> selectedCards = new List<CardSource>();
  63. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  64. selectCardEffect.SetUp(
  65. canTargetCondition: CanSelectCardCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: CanEndSelectCondition,
  68. canNoSelect: () => true,
  69. selectCardCoroutine: SelectCardCoroutine,
  70. afterSelectCardCoroutine: null,
  71. message: "Select cards to play.",
  72. maxCount: maxCount,
  73. canEndNotMax: true,
  74. isShowOpponent: true,
  75. mode: SelectCardEffect.Mode.Custom,
  76. root: SelectCardEffect.Root.Trash,
  77. customRootCardList: null,
  78. canLookReverseCard: true,
  79. selectPlayer: card.Owner,
  80. cardEffect: activateClass);
  81. selectCardEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
  82. selectCardEffect.SetUpCustomMessage_ShowCard("Played Cards");
  83. yield return StartCoroutine(selectCardEffect.Activate());
  84. bool CanEndSelectCondition(List<CardSource> cardSources)
  85. {
  86. if (CardEffectCommons.HasNoElement(cardSources))
  87. {
  88. return false;
  89. }
  90. return true;
  91. }
  92. IEnumerator SelectCardCoroutine(CardSource cardSource)
  93. {
  94. selectedCards.Add(cardSource);
  95. yield return null;
  96. }
  97. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  98. cardSources: selectedCards,
  99. activateClass: activateClass,
  100. payCost: false,
  101. isTapped: false,
  102. root: SelectCardEffect.Root.Trash,
  103. activateETB: true));
  104. }
  105. }
  106. }
  107. if (timing == EffectTiming.OnAllyAttack)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("Return 1 digivolution card and delete 1 Digimon", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  112. cardEffects.Add(activateClass);
  113. string EffectDiscription()
  114. {
  115. return "[When Attacking] You may return 1 level 6 Digimon card in this Digimon's digivolution cards to its owner's hand to delete 1 of your opponent's unsuspended Digimon with a play cost of 12 or less.";
  116. }
  117. bool CanSelectCardCondition(CardSource cardSource)
  118. {
  119. if (cardSource.IsDigimon)
  120. {
  121. if (cardSource.Level == 6)
  122. {
  123. if (cardSource.HasLevel)
  124. {
  125. return true;
  126. }
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanSelectPermanentCondition(Permanent permanent)
  132. {
  133. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  134. {
  135. if (!permanent.IsSuspended)
  136. {
  137. if (permanent.TopCard.GetCostItself <= 12)
  138. {
  139. return true;
  140. }
  141. }
  142. }
  143. return false;
  144. }
  145. bool CanUseCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  148. }
  149. bool CanActivateCondition(Hashtable hashtable)
  150. {
  151. if (CardEffectCommons.IsExistOnBattleArea(card))
  152. {
  153. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  154. {
  155. return true;
  156. }
  157. }
  158. return false;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  161. {
  162. if (CardEffectCommons.IsExistOnBattleArea(card))
  163. {
  164. Permanent selectedPermanent = card.PermanentOfThisCard();
  165. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  166. {
  167. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  168. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  169. selectCardEffect.SetUp(
  170. canTargetCondition: CanSelectCardCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. canNoSelect: () => false,
  174. selectCardCoroutine: null,
  175. afterSelectCardCoroutine: null,
  176. message: "Select 1 card to add to your hand.",
  177. maxCount: maxCount,
  178. canEndNotMax: false,
  179. isShowOpponent: true,
  180. mode: SelectCardEffect.Mode.AddHand,
  181. root: SelectCardEffect.Root.Custom,
  182. customRootCardList: selectedPermanent.DigivolutionCards,
  183. canLookReverseCard: true,
  184. selectPlayer: card.Owner,
  185. cardEffect: activateClass);
  186. yield return StartCoroutine(selectCardEffect.Activate());
  187. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  188. {
  189. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  190. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  191. selectPermanentEffect.SetUp(
  192. selectPlayer: card.Owner,
  193. canTargetCondition: CanSelectPermanentCondition,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. maxCount: maxCount,
  197. canNoSelect: false,
  198. canEndNotMax: false,
  199. selectPermanentCoroutine: null,
  200. afterSelectPermanentCoroutine: null,
  201. mode: SelectPermanentEffect.Mode.Destroy,
  202. cardEffect: activateClass);
  203. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  204. }
  205. }
  206. }
  207. }
  208. }
  209. return cardEffects;
  210. }
  211. }