BT13_062.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_062 : 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.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Trash 1 card from hand to return 1 card from trash to hand", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] By trashing 1 card with [Sukamon] or [Etemon] in its name in your hand, return 1 card with [Sukamon] in its name from your trash to the hand.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource != null)
  25. {
  26. if (cardSource.Owner == card.Owner)
  27. {
  28. if (cardSource.ContainsCardName("Sukamon"))
  29. {
  30. return true;
  31. }
  32. if (cardSource.ContainsCardName("Etemon"))
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanSelectCardCondition1(CardSource cardSource)
  41. {
  42. if (cardSource != null)
  43. {
  44. if (cardSource.Owner == card.Owner)
  45. {
  46. if (cardSource.ContainsCardName("Sukamon"))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (card.Owner.HandCards.Count >= 1)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (isExistOnField(card))
  72. {
  73. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  74. {
  75. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  76. {
  77. bool discarded = false;
  78. int discardCount = 1;
  79. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  80. selectHandEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: CanSelectCardCondition,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: discardCount,
  86. canNoSelect: true,
  87. canEndNotMax: false,
  88. isShowOpponent: true,
  89. selectCardCoroutine: null,
  90. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  91. mode: SelectHandEffect.Mode.Discard,
  92. cardEffect: activateClass);
  93. yield return StartCoroutine(selectHandEffect.Activate());
  94. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  95. {
  96. if (cardSources.Count >= 1)
  97. {
  98. discarded = true;
  99. yield return null;
  100. }
  101. }
  102. if (discarded)
  103. {
  104. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1))
  105. {
  106. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition1));
  107. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  108. selectCardEffect.SetUp(
  109. canTargetCondition: CanSelectCardCondition1,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. canNoSelect: () => false,
  113. selectCardCoroutine: null,
  114. afterSelectCardCoroutine: null,
  115. message: "Select 1 card to add to your hand.",
  116. maxCount: maxCount,
  117. canEndNotMax: false,
  118. isShowOpponent: true,
  119. mode: SelectCardEffect.Mode.AddHand,
  120. root: SelectCardEffect.Root.Trash,
  121. customRootCardList: null,
  122. canLookReverseCard: true,
  123. selectPlayer: card.Owner,
  124. cardEffect: activateClass);
  125. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. if (timing == EffectTiming.OnDestroyedAnyone)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Play 1 [Chuumon] from trash", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  138. activateClass.SetIsInheritedEffect(true);
  139. cardEffects.Add(activateClass);
  140. string EffectDiscription()
  141. {
  142. return "[On Deletion] If this Digimon has [Sukamon] or [Etemon] in its name, you may play 1 [Chuumon] from your trash suspended without paying the cost.";
  143. }
  144. bool CanSelectCardCondition(CardSource cardSource)
  145. {
  146. if (cardSource != null)
  147. {
  148. if (cardSource.Owner == card.Owner)
  149. {
  150. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  151. {
  152. if (cardSource.CardNames.Contains("Chuumon"))
  153. {
  154. return true;
  155. }
  156. }
  157. }
  158. }
  159. return false;
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  164. }
  165. bool CanActivateCondition(Hashtable hashtable)
  166. {
  167. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  168. {
  169. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  170. {
  171. if (CardEffectCommons.CanActivateSelfOnDeletionWithContainingCardName(hashtable, "Sukamon", card))
  172. {
  173. return true;
  174. }
  175. if (CardEffectCommons.CanActivateSelfOnDeletionWithContainingCardName(hashtable, "Etemon", card))
  176. {
  177. return true;
  178. }
  179. }
  180. }
  181. return false;
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  184. {
  185. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  186. List<CardSource> selectedCards = new List<CardSource>();
  187. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  188. selectCardEffect.SetUp(
  189. canTargetCondition: CanSelectCardCondition,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. canNoSelect: () => true,
  193. selectCardCoroutine: SelectCardCoroutine,
  194. afterSelectCardCoroutine: null,
  195. message: "Select 1 card to play.",
  196. maxCount: maxCount,
  197. canEndNotMax: false,
  198. isShowOpponent: true,
  199. mode: SelectCardEffect.Mode.Custom,
  200. root: SelectCardEffect.Root.Trash,
  201. customRootCardList: null,
  202. canLookReverseCard: true,
  203. selectPlayer: card.Owner,
  204. cardEffect: activateClass);
  205. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  206. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  207. yield return StartCoroutine(selectCardEffect.Activate());
  208. IEnumerator SelectCardCoroutine(CardSource cardSource)
  209. {
  210. selectedCards.Add(cardSource);
  211. yield return null;
  212. }
  213. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: true, root: SelectCardEffect.Root.Trash, activateETB: true));
  214. }
  215. }
  216. return cardEffects;
  217. }
  218. }
  219. }