BT25_029.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // MirageGaogamon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_029 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Alt Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent) => permanent.TopCard.ContainsCardName("Gaogamon") || permanent.TopCard.EqualsTraits("DATA SQUAD");
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 5));
  18. }
  19. #endregion
  20. #region Reboot
  21. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  22. #endregion
  23. #region Blocker
  24. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  25. #endregion
  26. #region Evade
  27. if (timing == EffectTiming.WhenPermanentWouldBeDeleted) cardEffects.Add(CardEffectFactory.EvadeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  28. #endregion
  29. #endregion
  30. #region Shared WD/WA
  31. string SharedEffectName = "May return 1 enemy level 5 or lower digimon to hand, then by trashing bottom face down under a tamer, return 1 enemy lowest level digimon to hand";
  32. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] You may return 1 of your opponent's level 5 or lower Digimon to the hand. Then, by trashing the bottom face-down card under any of your Tamers, return 1 of your opponent's lowest level Digimon to the hand.";
  33. string SharedHashValue = "BT25_029_WD_WA";
  34. CardEffectFactory.ActivateClassesForSharedEffects
  35. (ref cardEffects, timing, card,
  36. SharedEffectName,
  37. SharedActivateCoroutine,
  38. SharedEffectDescription,
  39. maxCountPerTurn: 1,
  40. hashValue: SharedHashValue,
  41. optional: false,
  42. isSkippable: true,
  43. whenDigivolving: true,
  44. whenAttacking: true);
  45. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  46. {
  47. bool Level5OrLowerPermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  48. && permanent.TopCard.HasLevel
  49. && permanent.Level <= 5;
  50. bool TamerWithFaceDownCardCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  51. && permanent.HasFaceDownDigivolutionCards;
  52. bool LowestLevelPermanentCondition(Permanent permanent) => CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  53. bool Used = false;
  54. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, Level5OrLowerPermanentCondition))
  55. {
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: Level5OrLowerPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: 1,
  63. canNoSelect: true,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: null,
  66. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  67. mode: SelectPermanentEffect.Mode.Bounce,
  68. cardEffect: activateClass);
  69. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to return to hand", "The opponent is selecting 1 Digimon to return to hand");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  72. {
  73. if (permanents.Count > 0)
  74. Used = true;
  75. yield return null;
  76. }
  77. }
  78. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, TamerWithFaceDownCardCondition))
  79. {
  80. Permanent selectedPermanent = null;
  81. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: TamerWithFaceDownCardCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: 1,
  88. canNoSelect: true,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: SelectPermanentCoroutine,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  95. {
  96. selectedPermanent = permanent;
  97. yield return null;
  98. }
  99. selectPermanentEffect.SetUpCustomMessage("Select 1 of your tamers to trash bottom face down card", "The opponent is selecting 1 of their tamers to trash bottom face down card");
  100. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  101. if (selectedPermanent != null)
  102. {
  103. Used = true;
  104. var cardToTrash = selectedPermanent.DigivolutionCards.Last(x => x.IsFaceDown);
  105. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsAndProcessAccordingToResult(
  106. targetPermanent: selectedPermanent,
  107. targetDigivolutionCards: new List<CardSource>() { cardToTrash },
  108. activateClass: activateClass,
  109. successProcess: SuccessProcess,
  110. failureProcess: null));
  111. IEnumerator SuccessProcess(List<CardSource> cardSources)
  112. {
  113. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, LowestLevelPermanentCondition))
  114. {
  115. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  116. selectPermanentEffect.SetUp(
  117. selectPlayer: card.Owner,
  118. canTargetCondition: LowestLevelPermanentCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. maxCount: 1,
  122. canNoSelect: false,
  123. canEndNotMax: false,
  124. selectPermanentCoroutine: null,
  125. afterSelectPermanentCoroutine: null,
  126. mode: SelectPermanentEffect.Mode.Bounce,
  127. cardEffect: activateClass);
  128. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's lowest level Digimon to return to hand", "The opponent is selecting 1 lowest level Digimon to return to hand");
  129. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  130. }
  131. }
  132. }
  133. }
  134. if (!Used) activateClass.RemoveUse();
  135. }
  136. #endregion
  137. #region All Turns
  138. #region All Turns Shared
  139. string AllTurnsSharedHashValue = "BT25-029-OnAddHand-OnTrashTamerCards";
  140. string AllTurnsSharedEffectName = "You may unsuspend this digimon";
  141. string AllTurnsSharedDescription = "[All Turns] [Once Per Turn] When effects add cards to your opponent's hand or trash cards from under your Tamers, this Digimon may unsuspend.";
  142. IEnumerator SharedActivateCoroutine1(Hashtable hashtable, ActivateClass activateClass)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  145. permanents: new List<Permanent>() { card.PermanentOfThisCard() },
  146. cardEffect: activateClass
  147. ).Unsuspend());
  148. }
  149. #endregion
  150. #region All Turns - On Add Hand
  151. if (timing == EffectTiming.OnAddHand)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect(AllTurnsSharedEffectName, CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine1(hash, activateClass), 1, true, AllTurnsSharedDescription);
  156. activateClass.SetHashString(AllTurnsSharedHashValue);
  157. cardEffects.Add(activateClass);
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  161. && CardEffectCommons.CanTriggerWhenAddHand(hashtable, player => player == card.Owner.Enemy, cardEffect => cardEffect != null);
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  166. }
  167. }
  168. #endregion
  169. #region All Turns - On Trash Tamer Cards
  170. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect(AllTurnsSharedEffectName, CanUseCondition, card);
  174. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine1(hash, activateClass), 1, true, AllTurnsSharedDescription);
  175. activateClass.SetHashString(AllTurnsSharedHashValue);
  176. cardEffects.Add(activateClass);
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  180. && CardEffectCommons.CanTriggerOnTrashDigivolutionCard(hashtable, IsYourTamerCondition, cardEffect => cardEffect != null, null);
  181. }
  182. bool CanActivateCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  185. }
  186. bool IsYourTamerCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card);
  187. }
  188. #endregion
  189. #endregion
  190. return cardEffects;
  191. }
  192. }
  193. }