BT15_079.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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_079 : 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 "Delete 1 unsuspended Digimon.";
  43. }
  44. string SharedEffectDescription(string tag)
  45. {
  46. return $"[{tag}] Delete 1 of your opponent's unsuspended Digimon.";
  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.Destroy,
  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 On End Opponents 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 [Piedmon] from your hand without paying the cost.";
  117. }
  118. bool CanSelectCardCondition(CardSource cardSource)
  119. {
  120. if (!cardSource.CardNames.Contains("Piedmon"))
  121. {
  122. if (cardSource.IsDigimon)
  123. {
  124. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  125. {
  126. if (cardSource.CardTraits.Contains("Dark Masters"))
  127. {
  128. return true;
  129. }
  130. if (cardSource.CardTraits.Contains("DarkMasters"))
  131. {
  132. return true;
  133. }
  134. }
  135. }
  136. }
  137. return false;
  138. }
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.IsExistOnBattleArea(card))
  142. {
  143. if (CardEffectCommons.IsOpponentTurn(card))
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.IsExistOnBattleArea(card))
  153. {
  154. return true;
  155. }
  156. return false;
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  161. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  162. {
  163. List<CardSource> selectedCards = new List<CardSource>();
  164. int maxCount = 1;
  165. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  166. selectHandEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectCardCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: maxCount,
  172. canNoSelect: true,
  173. canEndNotMax: false,
  174. isShowOpponent: true,
  175. selectCardCoroutine: SelectCardCoroutine,
  176. afterSelectCardCoroutine: null,
  177. mode: SelectHandEffect.Mode.Custom,
  178. cardEffect: activateClass);
  179. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  180. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  181. yield return StartCoroutine(selectHandEffect.Activate());
  182. IEnumerator SelectCardCoroutine(CardSource cardSource)
  183. {
  184. selectedCards.Add(cardSource);
  185. yield return null;
  186. }
  187. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  188. cardSources: selectedCards,
  189. activateClass: activateClass,
  190. payCost: false,
  191. isTapped: false,
  192. root: SelectCardEffect.Root.Hand,
  193. activateETB: true));
  194. }
  195. }
  196. }
  197. #endregion
  198. #region Inherited Effect
  199. if (timing == EffectTiming.OnDestroyedAnyone)
  200. {
  201. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: true, card: card, condition: null));
  202. }
  203. #endregion
  204. return cardEffects;
  205. }
  206. }
  207. }