EX11_052.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. // HeavyMetaldramon
  7. namespace DCGO.CardEffects.EX11
  8. {
  9. public class EX11_052 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. static bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.IsLevel5
  20. && (targetPermanent.TopCard.EqualsTraits("Dark Dragon")
  21. || targetPermanent.TopCard.EqualsTraits("Evil Dragon"));
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  24. }
  25. #endregion
  26. #region OP/WD Shared
  27. string SharedEffectName = "Discard 2, delete 1 opponent unsuspended digimon, conditionally play a [Evil]/[Dark Dragon]/[Evil Dragon] trait digimon from trash for free.";
  28. string SharedEffectDescription(string tag) => $"[{tag}] Trash 2 cards in your hand and delete 1 of your opponent's unsuspended Digimon. Then, if you have 4 or fewer cards in your hand, you may play 1 level 5 or lower [Evil], [Dark Dragon] or [Evil Dragon] trait Digimon card from your trash without paying the cost.";
  29. bool SharedCanActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  30. {
  31. return CardEffectCommons.IsExistOnBattleArea(card);
  32. }
  33. bool CanSelectPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  36. && !permanent.IsSuspended;
  37. }
  38. bool CanSelectCardCondition(CardSource cardSource)
  39. {
  40. return cardSource.IsDigimon
  41. && cardSource.HasLevel
  42. && cardSource.Level <= 5
  43. && (cardSource.EqualsTraits("Evil")
  44. || cardSource.EqualsTraits("Dark Dragon")
  45. || cardSource.EqualsTraits("Evil Dragon"));
  46. }
  47. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  48. {
  49. if (card.Owner.HandCards.Count >= 1)
  50. {
  51. int discardCount = Math.Min(2, card.Owner.HandCards.Count);
  52. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  53. selectHandEffect.SetUp(
  54. selectPlayer: card.Owner,
  55. canTargetCondition: (cardSource) => true,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. maxCount: discardCount,
  59. canNoSelect: false,
  60. canEndNotMax: false,
  61. isShowOpponent: true,
  62. selectCardCoroutine: null,
  63. afterSelectCardCoroutine: null,
  64. mode: SelectHandEffect.Mode.Discard,
  65. cardEffect: activateClass);
  66. yield return StartCoroutine(selectHandEffect.Activate());
  67. }
  68. if(CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  69. {
  70. int maxCount = 1;
  71. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  72. selectPermanentEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectPermanentCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: maxCount,
  78. canNoSelect: false,
  79. canEndNotMax: false,
  80. selectPermanentCoroutine: null,
  81. afterSelectPermanentCoroutine: null,
  82. mode: SelectPermanentEffect.Mode.Destroy,
  83. cardEffect: activateClass);
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. }
  86. if(card.Owner.HandCards.Count <= 4
  87. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  88. {
  89. CardSource selectedCard = null;
  90. #region Select Digimon
  91. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  92. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition));
  93. selectCardEffect.SetUp(
  94. canTargetCondition: CanSelectCardCondition,
  95. canTargetCondition_ByPreSelecetedList: null,
  96. canEndSelectCondition: null,
  97. canNoSelect: () => true,
  98. selectCardCoroutine: SelectCardCoroutine,
  99. afterSelectCardCoroutine: null,
  100. message: "Select 1 Digimon card to play.",
  101. maxCount: maxCount,
  102. canEndNotMax: false,
  103. isShowOpponent: true,
  104. mode: SelectCardEffect.Mode.Custom,
  105. root: SelectCardEffect.Root.Trash,
  106. customRootCardList: null,
  107. canLookReverseCard: true,
  108. selectPlayer: card.Owner,
  109. cardEffect: activateClass);
  110. IEnumerator SelectCardCoroutine(CardSource cardSource)
  111. {
  112. selectedCard = cardSource;
  113. yield return null;
  114. }
  115. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card to play.", "The opponent is selecting 1 Digimon card to play.");
  116. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  117. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  118. #endregion
  119. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  120. cardSources: new List<CardSource>() { selectedCard },
  121. activateClass: activateClass,
  122. payCost: false,
  123. isTapped: false,
  124. root: SelectCardEffect.Root.Trash,
  125. activateETB: true)
  126. );
  127. }
  128. }
  129. #endregion
  130. #region On Play
  131. if (timing == EffectTiming.OnEnterFieldAnyone)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  135. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  136. cardEffects.Add(activateClass);
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  140. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  141. }
  142. }
  143. #endregion
  144. #region When Digivolving
  145. if (timing == EffectTiming.OnEnterFieldAnyone)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  149. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  150. cardEffects.Add(activateClass);
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  154. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  155. }
  156. }
  157. #endregion
  158. #region End of Attack
  159. if (timing == EffectTiming.OnEndAttack)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  163. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("End of Attack"));
  164. cardEffects.Add(activateClass);
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleArea(card)
  168. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  169. }
  170. }
  171. #endregion
  172. #region All Turns
  173. if (timing == EffectTiming.WhenRemoveField)
  174. {
  175. ActivateClass activateClass = new ActivateClass();
  176. activateClass.SetUpICardEffect("If 4 or less cards in hand, trash opponent's security.", CanUseCondition, card);
  177. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  178. activateClass.SetHashString("EX11_052_AT");
  179. cardEffects.Add(activateClass);
  180. string EffectDiscription()
  181. {
  182. return "[All Turns] [Once Per Turn] When any of your [Dark Dragon] or [Evil Dragon] trait Digimon would leave the battle area, if you have 4 or fewer cards in your hand, trash your opponent's top security card.";
  183. }
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  187. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  192. && card.Owner.HandCards.Count <= 4;
  193. }
  194. bool PermanentCondition(Permanent permanent)
  195. {
  196. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  197. && (permanent.TopCard.EqualsTraits("Dark Dragon")
  198. || permanent.TopCard.EqualsTraits("Evil Dragon"));
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable hashtable)
  201. {
  202. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  203. player: card.Owner.Enemy,
  204. destroySecurityCount: 1,
  205. cardEffect: activateClass,
  206. fromTop: true).DestroySecurity());
  207. }
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }