BT15_052.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_052 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. # region All Turns
  13. if (timing == EffectTiming.None)
  14. {
  15. bool Condition()
  16. {
  17. if (CardEffectCommons.IsExistOnBattleArea(card))
  18. {
  19. if (CardEffectCommons.IsOwnerTurn(card))
  20. {
  21. return true;
  22. }
  23. }
  24. return false;
  25. }
  26. bool CardCondition(CardSource cardSource)
  27. {
  28. return !cardSource.CardColors.Contains(CardColor.White);
  29. }
  30. cardEffects.Add(CardEffectFactory.CanNotDigivolveStaticSelfEffect(
  31. cardCondition: CardCondition,
  32. isInheritedEffect: false,
  33. card: card,
  34. condition: Condition,
  35. effectName: "This Digimon can digivolve only to white Digimon")
  36. );
  37. }
  38. #endregion
  39. #region Shared OP/WA
  40. string SharedEffectName()
  41. {
  42. return "Return 1 suspended Digimon to the bottom of deck.";
  43. }
  44. string SharedEffectDescription(string tag)
  45. {
  46. return $"[{tag}] Return 1 of your opponent's suspended Digimon to the bottom of the deck.";
  47. }
  48. bool CanSelectPermanentCondition(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  51. && permanent.IsSuspended;
  52. }
  53. bool SharedCanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleArea(card);
  56. }
  57. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  58. {
  59. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  60. {
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: CanSelectPermanentCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: false,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: null,
  72. afterSelectPermanentCoroutine: null,
  73. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  74. cardEffect: activateClass);
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. }
  77. }
  78. #endregion
  79. #region On Play
  80. if (timing == EffectTiming.OnEnterFieldAnyone)
  81. {
  82. ActivateClass activateClass = new ActivateClass();
  83. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  84. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  85. cardEffects.Add(activateClass);
  86. bool CanUseCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  89. && CardEffectCommons.IsExistOnBattleArea(card);
  90. }
  91. }
  92. #endregion
  93. #region When Attacking
  94. if (timing == EffectTiming.OnAllyAttack)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  98. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Attacking"));
  99. cardEffects.Add(activateClass);
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  103. && CardEffectCommons.IsExistOnBattleArea(card);
  104. }
  105. }
  106. #endregion
  107. #region End of Opponent's Turn
  108. if (timing == EffectTiming.OnEndTurn)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("Delete this Digimon and play 1 Digimon from hand", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  113. cardEffects.Add(activateClass);
  114. string EffectDiscription()
  115. {
  116. return "[End of Opponent's Turn] Delete this Digimon. Then, you may play 1 Digimon card with the [Dark Masters] trait, other than [Puppetmon] from your hand without paying the cost.";
  117. }
  118. bool CanSelectCardCondition(CardSource cardSource)
  119. {
  120. if (!cardSource.CardNames.Contains("Puppetmon"))
  121. {
  122. if (cardSource.IsDigimon)
  123. {
  124. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  125. {
  126. if (cardSource.CardTraits.Contains("Dark Masters") || cardSource.CardTraits.Contains("DarkMasters"))
  127. return true;
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. if (CardEffectCommons.IsExistOnBattleArea(card))
  136. {
  137. if (CardEffectCommons.IsOpponentTurn(card))
  138. {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. if (CardEffectCommons.IsExistOnBattleArea(card))
  147. {
  148. return true;
  149. }
  150. return false;
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  153. {
  154. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  155. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  156. {
  157. List<CardSource> selectedCards = new List<CardSource>();
  158. int maxCount = 1;
  159. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  160. selectHandEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition: CanSelectCardCondition,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. maxCount: maxCount,
  166. canNoSelect: true,
  167. canEndNotMax: false,
  168. isShowOpponent: true,
  169. selectCardCoroutine: SelectCardCoroutine,
  170. afterSelectCardCoroutine: null,
  171. mode: SelectHandEffect.Mode.Custom,
  172. cardEffect: activateClass);
  173. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  174. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  175. yield return StartCoroutine(selectHandEffect.Activate());
  176. IEnumerator SelectCardCoroutine(CardSource cardSource)
  177. {
  178. selectedCards.Add(cardSource);
  179. yield return null;
  180. }
  181. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  182. cardSources: selectedCards,
  183. activateClass: activateClass,
  184. payCost: false,
  185. isTapped: false,
  186. root: SelectCardEffect.Root.Hand,
  187. activateETB: true));
  188. }
  189. }
  190. }
  191. #endregion
  192. #region Inherited Effect
  193. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  194. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  195. #endregion
  196. return cardEffects;
  197. }
  198. }
  199. }