BT15_031.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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_031 : 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.HasCardColor(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 level 5 or lower Digimon to hand.";
  43. }
  44. string SharedEffectDescription(string tag)
  45. {
  46. return $"[{tag}] Return 1 of your opponent's level 5 or lower Digimon to the hand.";
  47. }
  48. bool CanSelectPermanentCondition(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  51. && permanent.TopCard.HasLevel
  52. && permanent.Level <= 5;
  53. }
  54. bool SharedCanActivateCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.IsExistOnBattleArea(card);
  57. }
  58. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  61. {
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectPermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: null,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Bounce,
  75. cardEffect: activateClass);
  76. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  77. }
  78. }
  79. #endregion
  80. #region On Play
  81. if (timing == EffectTiming.OnEnterFieldAnyone)
  82. {
  83. ActivateClass activateClass = new ActivateClass();
  84. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  85. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  86. cardEffects.Add(activateClass);
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  90. && CardEffectCommons.IsExistOnBattleArea(card);
  91. }
  92. }
  93. #endregion
  94. #region When Attacking
  95. if (timing == EffectTiming.OnAllyAttack)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  99. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hash) => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Attacking"));
  100. cardEffects.Add(activateClass);
  101. bool CanUseCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  104. && CardEffectCommons.IsExistOnBattleArea(card);
  105. }
  106. }
  107. #endregion
  108. #region End of Opponent's Turn
  109. if (timing == EffectTiming.OnEndTurn)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Delete this Digimon and play 1 Digimon from hand", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  114. cardEffects.Add(activateClass);
  115. string EffectDiscription()
  116. {
  117. return "[End of Opponent's Turn] Delete this Digimon. Then, you may play 1 Digimon card with the [Dark Masters] trait, other than [MetalSeadramon], from your hand without paying the cost.";
  118. }
  119. bool CanSelectCardCondition(CardSource cardSource)
  120. {
  121. if (!cardSource.CardNames.Contains("MetalSeadramon"))
  122. {
  123. if (cardSource.IsDigimon)
  124. {
  125. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  126. {
  127. if (cardSource.CardTraits.Contains("Dark Masters"))
  128. {
  129. return true;
  130. }
  131. if (cardSource.CardTraits.Contains("DarkMasters"))
  132. {
  133. return true;
  134. }
  135. }
  136. }
  137. }
  138. return false;
  139. }
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. if (CardEffectCommons.IsExistOnBattleArea(card))
  143. {
  144. if (CardEffectCommons.IsOpponentTurn(card))
  145. {
  146. return true;
  147. }
  148. }
  149. return false;
  150. }
  151. bool CanActivateCondition(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.IsExistOnBattleArea(card))
  154. {
  155. return true;
  156. }
  157. return false;
  158. }
  159. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  160. {
  161. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  162. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  163. {
  164. List<CardSource> selectedCards = new List<CardSource>();
  165. int maxCount = 1;
  166. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  167. selectHandEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSelectCardCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: maxCount,
  173. canNoSelect: true,
  174. canEndNotMax: false,
  175. isShowOpponent: true,
  176. selectCardCoroutine: SelectCardCoroutine,
  177. afterSelectCardCoroutine: null,
  178. mode: SelectHandEffect.Mode.Custom,
  179. cardEffect: activateClass);
  180. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  181. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  182. yield return StartCoroutine(selectHandEffect.Activate());
  183. IEnumerator SelectCardCoroutine(CardSource cardSource)
  184. {
  185. selectedCards.Add(cardSource);
  186. yield return null;
  187. }
  188. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  189. cardSources: selectedCards,
  190. activateClass: activateClass,
  191. payCost: false,
  192. isTapped: false,
  193. root: SelectCardEffect.Root.Hand,
  194. activateETB: true));
  195. }
  196. }
  197. }
  198. #endregion
  199. #region Inherited Effect
  200. if (timing == EffectTiming.None)
  201. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  202. #endregion
  203. return cardEffects;
  204. }
  205. }
  206. }