BT10_027.cs 12 KB

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