BT14_038.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_038 : 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. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.ContainsCardName("Sukamon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.SecuritySkill)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  25. activateClass.SetIsSecurityEffect(true);
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[Security] If you have 3 or more cards with [Sukamon] in their names in your trash, you may play 1 level 6 Digimon card with [Etemon] in its name from your hand without paying the cost.";
  30. }
  31. bool CanSelectCardCondition(CardSource cardSource)
  32. {
  33. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  34. {
  35. if (cardSource.IsDigimon)
  36. {
  37. if (cardSource.HasLevel)
  38. {
  39. if (cardSource.Level == 6)
  40. {
  41. if (cardSource.ContainsCardName("Etemon"))
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. if (card.Owner.ExecutingCards.Contains(card))
  54. {
  55. CardSource cardSource = CardEffectCommons.GetCardFromHashtable(hashtable);
  56. if (cardSource == card)
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. bool CanActivateCondition(Hashtable hashtable)
  64. {
  65. if (card.Owner.ExecutingCards.Contains(card))
  66. {
  67. if (card.Owner.HandCards.Count >= 1)
  68. {
  69. if (card.Owner.TrashCards.Count(cardSource => cardSource.ContainsCardName("Sukamon")) >= 3)
  70. {
  71. return true;
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  78. {
  79. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  80. {
  81. List<CardSource> selectedCards = new List<CardSource>();
  82. int maxCount = 1;
  83. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  84. selectHandEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectCardCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: maxCount,
  90. canNoSelect: true,
  91. canEndNotMax: false,
  92. isShowOpponent: true,
  93. selectCardCoroutine: SelectCardCoroutine,
  94. afterSelectCardCoroutine: null,
  95. mode: SelectHandEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  98. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  99. yield return StartCoroutine(selectHandEffect.Activate());
  100. IEnumerator SelectCardCoroutine(CardSource cardSource)
  101. {
  102. selectedCards.Add(cardSource);
  103. yield return null;
  104. }
  105. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  106. cardSources: selectedCards,
  107. activateClass: activateClass,
  108. payCost: false,
  109. isTapped: false,
  110. root: SelectCardEffect.Root.Hand,
  111. activateETB: true));
  112. }
  113. }
  114. }
  115. if (timing == EffectTiming.OnDestroyedAnyone)
  116. {
  117. ActivateClass activateClass = new ActivateClass();
  118. activateClass.SetUpICardEffect("Place this card at the bottom of security", CanUseCondition, card);
  119. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  120. cardEffects.Add(activateClass);
  121. string EffectDiscription()
  122. {
  123. return "[On Deletion] Place this card at the bottom of your security stack.";
  124. }
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  128. }
  129. bool CanActivateCondition(Hashtable hashtable)
  130. {
  131. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  132. {
  133. if (card.Owner.CanAddSecurity(activateClass))
  134. {
  135. return true;
  136. }
  137. }
  138. return false;
  139. }
  140. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  141. {
  142. if (CardEffectCommons.IsExistOnTrash(card))
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false));
  145. }
  146. }
  147. }
  148. if (timing == EffectTiming.OnDestroyedAnyone)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("Place 1 [Etemon] from trash at the bottom of security", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  153. activateClass.SetIsInheritedEffect(true);
  154. cardEffects.Add(activateClass);
  155. string EffectDiscription()
  156. {
  157. return "[On Deletion] Place 1 [Etemon] from your trash at the bottom of your security stack.";
  158. }
  159. bool CanSelectCardCondition(CardSource cardSource)
  160. {
  161. return cardSource.CardNames.Contains("Etemon");
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  170. {
  171. if (card.Owner.TrashCards.Some(CanSelectCardCondition))
  172. {
  173. if (card.Owner.CanAddSecurity(activateClass))
  174. {
  175. return true;
  176. }
  177. }
  178. }
  179. return false;
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  182. {
  183. if (card.Owner.TrashCards.Some(CanSelectCardCondition))
  184. {
  185. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  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: () => false,
  193. selectCardCoroutine: SelectCardCoroutine,
  194. afterSelectCardCoroutine: null,
  195. message: "Select 1 card to place on the bottom of security.",
  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 place on the bottom of security.", "The opponent is selecting 1 card to place on the bottom of security.");
  206. selectCardEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  207. yield return StartCoroutine(selectCardEffect.Activate());
  208. IEnumerator SelectCardCoroutine(CardSource cardSource)
  209. {
  210. selectedCards.Add(cardSource);
  211. yield return null;
  212. }
  213. foreach (CardSource cardSource in selectedCards)
  214. {
  215. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: false));
  216. }
  217. }
  218. }
  219. }
  220. return cardEffects;
  221. }
  222. }
  223. }