EX11_018.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Ryugumon
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_018 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Evade
  13. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  14. {
  15. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region Decode
  19. if (timing == EffectTiming.WhenRemoveField)
  20. {
  21. bool SourceCondition(CardSource source)
  22. {
  23. return source.HasLevel
  24. && source.Level <= 5
  25. && source.HasAquaTraits;
  26. }
  27. string[] decodeStrings = { "(Lv.5 or lower Aqua or Sea Animal)", "Lv.5 or lower w/[Aqua]/[Sea Animal] in any trait" };
  28. cardEffects.Add(CardEffectFactory.DecodeSelfEffect(card: card, isInheritedEffect: false, decodeStrings: decodeStrings, sourceCondition: SourceCondition, condition: null));
  29. }
  30. #endregion
  31. #region Shared OP / WD / WA
  32. string SharedHashString = "EX11_018_OP_WD_WA";
  33. string SharedEffectName = "Place an [Aqua] or [Sea Animal] in any of it's traits as this Digimon's bottom source to unsuspend 1 of your digimon.";
  34. string SharedEffectDescription(string tag)
  35. => $"[{tag}] [Once Per Turn] By placing 1 Digimon card with [Aqua] or [Sea Animal] in any of its traits from your hand as this Digimon's bottom digivolution card, 1 of your Digimon unsuspends.";
  36. bool SharedCanActivateCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleArea(card)
  39. && CardEffectCommons.HasMatchConditionOwnersHand(card, IsAquaDigimonCardCondition);
  40. }
  41. bool IsAquaDigimonCardCondition(CardSource cardSource) => cardSource.IsDigimon && cardSource.HasAquaTraits;
  42. bool IsYourDigimonCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  43. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  44. {
  45. List<CardSource> selectedCards = new List<CardSource>();
  46. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  47. selectHandEffect.SetUp(
  48. selectPlayer: card.Owner,
  49. canTargetCondition: IsAquaDigimonCardCondition,
  50. canTargetCondition_ByPreSelecetedList: null,
  51. canEndSelectCondition: null,
  52. maxCount: 1,
  53. canNoSelect: false,
  54. canEndNotMax: false,
  55. isShowOpponent: true,
  56. selectCardCoroutine: SelectCardCoroutine,
  57. afterSelectCardCoroutine: null,
  58. mode: SelectHandEffect.Mode.Custom,
  59. cardEffect: activateClass);
  60. selectHandEffect.SetUpCustomMessage("Select 1 card to place as the bottom digivolution card.", "The opponent is selecting 1 card to place as the bottom digivolution card.");
  61. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  62. IEnumerator SelectCardCoroutine(CardSource cardSource)
  63. {
  64. selectedCards.Add(cardSource);
  65. yield return null;
  66. }
  67. if (selectedCards.Count > 0)
  68. {
  69. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: IsYourDigimonCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: null,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.UnTap,
  82. cardEffect: activateClass);
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. }
  85. }
  86. #endregion
  87. #region On Play
  88. if (timing == EffectTiming.OnEnterFieldAnyone)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  92. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("On Play"));
  93. activateClass.SetHashString(SharedHashString);
  94. cardEffects.Add(activateClass);
  95. bool CanUseCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  98. && CardEffectCommons.IsExistOnBattleArea(card);
  99. }
  100. }
  101. #endregion
  102. #region When Digivolving
  103. if (timing == EffectTiming.OnEnterFieldAnyone)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  107. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Digivolving"));
  108. activateClass.SetHashString(SharedHashString);
  109. cardEffects.Add(activateClass);
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card)
  113. && CardEffectCommons.IsExistOnBattleArea(card);
  114. }
  115. }
  116. #endregion
  117. #region When Attacking
  118. if (timing == EffectTiming.OnAllyAttack)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  122. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Attacking"));
  123. activateClass.SetHashString(SharedHashString);
  124. cardEffects.Add(activateClass);
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  128. && CardEffectCommons.IsExistOnBattleArea(card);
  129. }
  130. }
  131. #endregion
  132. #region All Turns
  133. if (timing == EffectTiming.OnAddDigivolutionCards)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Bottom deck 1 opponent's digimon with as many or fewer sources", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  138. activateClass.SetHashString("EX11_018_OnAddDigivolutionCards");
  139. cardEffects.Add(activateClass);
  140. string EffectDescription()
  141. => "[All Turns] [Once Per Turn] When effects add to this Digimon's digivolution cards, return 1 of your opponent's Digimon with as many of fewer digivolution cards as this Digimon to the bottom of the deck.";
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  145. && CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  146. hashtable,
  147. permanent => permanent == card.PermanentOfThisCard(),
  148. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  149. null);
  150. }
  151. bool CanActivateCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  154. }
  155. bool CanSelectPermanentCondition(Permanent permanent)
  156. {
  157. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  158. && permanent.DigivolutionCards.Count <= card.PermanentOfThisCard().DigivolutionCards.Count;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable hashtable)
  161. {
  162. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition));
  163. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  164. selectPermanentEffect.SetUp(
  165. selectPlayer: card.Owner,
  166. canTargetCondition: CanSelectPermanentCondition,
  167. canTargetCondition_ByPreSelecetedList: null,
  168. canEndSelectCondition: null,
  169. maxCount: maxCount,
  170. canNoSelect: false,
  171. canEndNotMax: false,
  172. selectPermanentCoroutine: null,
  173. afterSelectPermanentCoroutine: null,
  174. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  175. cardEffect: activateClass);
  176. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to bottom deck.", "The opponent is selecting 1 digimon to bottom deck.");
  177. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  178. }
  179. }
  180. #endregion
  181. return cardEffects;
  182. }
  183. }
  184. }