BT17_092.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_092 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Trash 1, Draw 2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] By trashing 1 [Morphomon] or [Eosmon] in your hand, <Draw 2>.";
  22. }
  23. bool HasSpecifiedTrashTarget(CardSource source)
  24. {
  25. return source.EqualsCardName("Morphomon") || source.EqualsCardName("Eosmon");
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (isExistOnField(card))
  34. return CardEffectCommons.HasMatchConditionOwnersHand(card, HasSpecifiedTrashTarget);
  35. return false;
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable hashtable)
  38. {
  39. if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasSpecifiedTrashTarget))
  40. {
  41. int maxCount = Math.Min(1, card.Owner.HandCards.Count(HasSpecifiedTrashTarget));
  42. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  43. selectHandEffect.SetUp(
  44. selectPlayer: card.Owner,
  45. canTargetCondition: HasSpecifiedTrashTarget,
  46. canTargetCondition_ByPreSelecetedList: null,
  47. canEndSelectCondition: null,
  48. maxCount: maxCount,
  49. canNoSelect: true,
  50. canEndNotMax: false,
  51. isShowOpponent: false,
  52. selectCardCoroutine: null,
  53. afterSelectCardCoroutine: SelectCardCoroutine,
  54. mode: SelectHandEffect.Mode.Discard,
  55. cardEffect: activateClass);
  56. selectHandEffect.SetUpCustomMessage("Select card to discard.", "The opponent is selecting card to discard.");
  57. yield return StartCoroutine(selectHandEffect.Activate());
  58. IEnumerator SelectCardCoroutine(List<CardSource> selectedCards)
  59. {
  60. if (selectedCards.Count > 0)
  61. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  62. }
  63. }
  64. }
  65. }
  66. #endregion
  67. #region All Turns - Turn off On Plays
  68. if (timing == EffectTiming.None)
  69. {
  70. DisableEffectClass invalidationClass = new DisableEffectClass();
  71. invalidationClass.SetUpICardEffect("Ignore [On Play] Effect of opponent's Tamers", CanUseCondition, card);
  72. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  73. cardEffects.Add(invalidationClass);
  74. bool CanUseCondition(Hashtable hashtable)
  75. {
  76. if (CardEffectCommons.IsExistOnBattleArea(card))
  77. {
  78. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasEosmon))
  79. return true;
  80. }
  81. return false;
  82. }
  83. bool HasEosmon(Permanent permanent)
  84. {
  85. if (permanent.IsDigimon)
  86. return permanent.TopCard.EqualsCardName("Eosmon");
  87. return false;
  88. }
  89. bool InvalidateCondition(ICardEffect cardEffect)
  90. {
  91. if (cardEffect != null)
  92. {
  93. if (cardEffect is ActivateICardEffect)
  94. {
  95. if (cardEffect.EffectSourceCard != null)
  96. {
  97. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(cardEffect.EffectSourceCard.PermanentOfThisCard(), card))
  98. {
  99. if (cardEffect.EffectSourceCard.PermanentOfThisCard().IsTamer)
  100. {
  101. if (!cardEffect.EffectSourceCard.PermanentOfThisCard().TopCard.CanNotBeAffected(invalidationClass))
  102. {
  103. if (cardEffect.IsOnPlay)
  104. {
  105. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasEosmon))
  106. return true;
  107. }
  108. }
  109. }
  110. }
  111. }
  112. }
  113. }
  114. return false;
  115. }
  116. }
  117. #endregion
  118. #region Opponents Turn - Protection
  119. if (timing == EffectTiming.WhenRemoveField)
  120. {
  121. List<Permanent> removedPermanents = new List<Permanent>();
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("Prevent from leaving battle area, by opponents effect", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  125. activateClass.SetHashString("Prevent_BT17_092");
  126. cardEffects.Add(activateClass);
  127. string EffectDiscription()
  128. {
  129. return "[Opponent's Turn] [Once Per Turn] When one of your [Eosmon] would leave the battle area by an opponent's effect, by deleting 1 of your other [Eosmon], prevent it from leaving.";
  130. }
  131. bool isEosmon(Permanent permanent)
  132. {
  133. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  134. return permanent.TopCard.EqualsCardName("Eosmon");
  135. return false;
  136. }
  137. bool HasOtherEosmon(Permanent permanent)
  138. {
  139. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  140. {
  141. foreach (Permanent removed in removedPermanents)
  142. {
  143. if (removed != permanent)
  144. return permanent.TopCard.EqualsCardName("Eosmon");
  145. }
  146. }
  147. return false;
  148. }
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. if (CardEffectCommons.IsOpponentTurn(card))
  152. {
  153. if (CardEffectCommons.IsExistOnBattleArea(card))
  154. {
  155. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, isEosmon))
  156. {
  157. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOpponentEffect(cardEffect, card)))
  158. {
  159. return true;
  160. }
  161. }
  162. }
  163. }
  164. return false;
  165. }
  166. bool CanActivateCondition(Hashtable hashtable)
  167. {
  168. if (CardEffectCommons.IsExistOnBattleArea(card))
  169. {
  170. removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(isEosmon);
  171. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasOtherEosmon);
  172. }
  173. return false;
  174. }
  175. IEnumerator ActivateCoroutine(Hashtable hashtable)
  176. {
  177. if (CardEffectCommons.HasMatchConditionPermanent(HasOtherEosmon))
  178. {
  179. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(HasOtherEosmon));
  180. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  181. selectPermanentEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: HasOtherEosmon,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. maxCount: maxCount,
  187. canNoSelect: false,
  188. canEndNotMax: false,
  189. selectPermanentCoroutine: SelectPermanentCoroutine,
  190. afterSelectPermanentCoroutine: null,
  191. mode: SelectPermanentEffect.Mode.Custom,
  192. cardEffect: activateClass);
  193. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  194. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  195. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  196. {
  197. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  198. targetPermanents: new List<Permanent>() { permanent },
  199. activateClass: activateClass,
  200. successProcess: permanents => SuccessProcess(),
  201. failureProcess: null));
  202. IEnumerator SuccessProcess()
  203. {
  204. foreach (Permanent removed in removedPermanents)
  205. {
  206. removed.willBeRemoveField = false;
  207. removed.HideDeleteEffect();
  208. removed.HideHandBounceEffect();
  209. removed.HideDeckBounceEffect();
  210. removed.HideWillRemoveFieldEffect();
  211. }
  212. yield return null;
  213. }
  214. }
  215. }
  216. }
  217. }
  218. #endregion
  219. #region Security Effect
  220. if (timing == EffectTiming.SecuritySkill)
  221. {
  222. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  223. }
  224. #endregion
  225. return cardEffects;
  226. }
  227. }
  228. }