BT25_027.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // MachGaogamon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_027 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("DATA SQUAD");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Shared WD/WA
  24. string SharedEffectName = "May return 1 enemy lvl 4 or lower Digimon to hand, by trashing bottom face-down card from Tamer, this Digimon unsuspends";
  25. string SharedEffectHash = "BT25_027_WD_WA";
  26. CardEffectFactory.ActivateClassesForSharedEffects
  27. (ref cardEffects, timing, card,
  28. SharedEffectName,
  29. SharedActivateCoroutine,
  30. SharedEffectDescription,
  31. optional: true,
  32. maxCountPerTurn: 1,
  33. hashValue: SharedEffectHash,
  34. whenDigivolving: true,
  35. whenAttacking: true);
  36. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] You may return 1 of your opponent's level 4 or lower Digimon to the hand. Then, by trashing the bottom face-down card from under any of your Tamers, this Digimon unsuspends.";
  37. bool CanSelectPermanentCondition(Permanent permanent)
  38. {
  39. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  40. && permanent.TopCard.HasLevel
  41. && permanent.TopCard.Level <= 4;
  42. }
  43. bool TamerWithOneFaceDownSource(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  46. && permanent.DigivolutionCards.Any(CanSelectTrashSourceCardCondition);
  47. }
  48. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  49. {
  50. return cardSource.IsFlipped;
  51. }
  52. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  53. {
  54. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  55. {
  56. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  57. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: CanSelectPermanentCondition,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: maxCount,
  64. canNoSelect: true,
  65. canEndNotMax: false,
  66. selectPermanentCoroutine: null,
  67. afterSelectPermanentCoroutine: null,
  68. mode: SelectPermanentEffect.Mode.Bounce,
  69. cardEffect: activateClass);
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. }
  72. if (CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource))
  73. {
  74. bool trashed = false;
  75. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  76. selectPermanentEffect1.SetUp(
  77. selectPlayer: card.Owner,
  78. canTargetCondition: TamerWithOneFaceDownSource,
  79. canTargetCondition_ByPreSelecetedList: null,
  80. canEndSelectCondition: null,
  81. maxCount: 1,
  82. canNoSelect: true,
  83. canEndNotMax: true,
  84. selectPermanentCoroutine: null,
  85. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  86. mode: SelectPermanentEffect.Mode.Custom,
  87. cardEffect: activateClass);
  88. selectPermanentEffect1.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  90. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  91. {
  92. if (permanents.Count == 1)
  93. {
  94. trashed = true;
  95. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  96. }
  97. }
  98. if (trashed && card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanUnsuspend)
  99. {
  100. List<Permanent> thisPermanent = new List<Permanent>() { card.PermanentOfThisCard() };
  101. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(thisPermanent, activateClass).Unsuspend());
  102. }
  103. }
  104. }
  105. #endregion
  106. #region AT
  107. if (timing == EffectTiming.WhenRemoveField)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("Trash the bottom face-down card from 1 Tamer to not leave", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  112. activateClass.SetHashString("BT25_027_AT");
  113. cardEffects.Add(activateClass);
  114. string EffectDescription()
  115. {
  116. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area, by trashing the bottom face-down card from under any of your Tamers, it doesn't leave.";
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  121. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  126. && CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource);
  127. }
  128. IEnumerator ActivateCoroutine(Hashtable hashtable)
  129. {
  130. if (CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource))
  131. {
  132. Permanent thisCardPermanent = card.PermanentOfThisCard();
  133. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  134. selectPermanentEffect.SetUp(
  135. selectPlayer: card.Owner,
  136. canTargetCondition: TamerWithOneFaceDownSource,
  137. canTargetCondition_ByPreSelecetedList: null,
  138. canEndSelectCondition: null,
  139. maxCount: 1,
  140. canNoSelect: true,
  141. canEndNotMax: false,
  142. selectPermanentCoroutine: SelectPermanentCoroutine,
  143. afterSelectPermanentCoroutine: null,
  144. mode: SelectPermanentEffect.Mode.Custom,
  145. cardEffect: activateClass);
  146. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  147. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  148. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  149. {
  150. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: new List<Permanent>() { permanent }[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  151. thisCardPermanent.willBeRemoveField = false;
  152. thisCardPermanent.HideDeleteEffect();
  153. thisCardPermanent.HideHandBounceEffect();
  154. thisCardPermanent.HideDeckBounceEffect();
  155. thisCardPermanent.HideWillRemoveFieldEffect();
  156. yield return null;
  157. }
  158. }
  159. }
  160. }
  161. #endregion
  162. #region Inherited
  163. if (timing == EffectTiming.WhenRemoveField)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("Trash the bottom face-down card from 1 Tamer to not leave", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  168. activateClass.SetHashString("BT25_027_Inherited");
  169. activateClass.SetIsInheritedEffect(true);
  170. cardEffects.Add(activateClass);
  171. string EffectDescription()
  172. {
  173. return "[All Turns] [Once Per Turn] When this Digimon with [Gaogamon] in its name or the [DATA SQUAD] trait would leave the battle area, by trashing the bottom face-down card from under any of your Tamers, it doesn't leave";
  174. }
  175. bool CanUseCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  178. && (card.PermanentOfThisCard().TopCard.ContainsCardName("Gaogamon")
  179. || card.PermanentOfThisCard().TopCard.EqualsTraits("DATA SQUAD"))
  180. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  181. }
  182. bool CanActivateCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  185. && CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource);
  186. }
  187. IEnumerator ActivateCoroutine(Hashtable hashtable)
  188. {
  189. if (CardEffectCommons.HasMatchConditionPermanent(TamerWithOneFaceDownSource))
  190. {
  191. Permanent thisCardPermanent = card.PermanentOfThisCard();
  192. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: TamerWithOneFaceDownSource,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: 1,
  199. canNoSelect: true,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: SelectPermanentCoroutine,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Custom,
  204. cardEffect: activateClass);
  205. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  206. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  207. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  208. {
  209. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: new List<Permanent>() { permanent }[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  210. thisCardPermanent.willBeRemoveField = false;
  211. thisCardPermanent.HideDeleteEffect();
  212. thisCardPermanent.HideHandBounceEffect();
  213. thisCardPermanent.HideDeckBounceEffect();
  214. thisCardPermanent.HideWillRemoveFieldEffect();
  215. yield return null;
  216. }
  217. }
  218. }
  219. }
  220. #endregion
  221. return cardEffects;
  222. }
  223. }
  224. }