BT11_064.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT11
  5. {
  6. public class BT11_064 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.CardNames.Contains("Greymon");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.None)
  20. {
  21. ChangeCostClass changeCostClass = new ChangeCostClass();
  22. changeCostClass.SetUpICardEffect($"Reduce Digivolution Cost", CanUseCondition, card);
  23. changeCostClass.SetUpChangeCostClass(
  24. changeCostFunc: ChangeCost,
  25. cardSourceCondition: CardSourceCondition,
  26. rootCondition: RootCondition,
  27. isUpDown: isUpDown,
  28. isCheckAvailability: () => false,
  29. isChangePayingCost: () => true);
  30. cardEffects.Add(changeCostClass);
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (CardEffectCommons.IsOwnerTurn(card))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  43. {
  44. if (CardSourceCondition(cardSource))
  45. {
  46. if (RootCondition(root))
  47. {
  48. if (PermanentsCondition(targetPermanents))
  49. {
  50. Cost -= cardSource.CardColors.Count;
  51. }
  52. }
  53. }
  54. return Cost;
  55. }
  56. bool PermanentsCondition(List<Permanent> targetPermanents)
  57. {
  58. if (targetPermanents != null)
  59. {
  60. if (targetPermanents.Count(PermanentCondition) >= 1)
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. bool PermanentCondition(Permanent targetPermanent)
  68. {
  69. return targetPermanent == card.PermanentOfThisCard();
  70. }
  71. bool CardSourceCondition(CardSource cardSource)
  72. {
  73. return cardSource.HasGreymonName;
  74. }
  75. bool RootCondition(SelectCardEffect.Root root)
  76. {
  77. return true;
  78. }
  79. bool isUpDown()
  80. {
  81. return true;
  82. }
  83. }
  84. if (timing == EffectTiming.WhenPermanentWouldBeDeleted || timing == EffectTiming.WhenReturntoHandAnyone || timing == EffectTiming.WhenReturntoLibraryAnyone)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Prevent this Digimon from being deleted or returned to hand or deck by effects", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  89. activateClass.SetIsInheritedEffect(true);
  90. activateClass.SetHashString("Substitute_BT11_064");
  91. cardEffects.Add(activateClass);
  92. string EffectDiscription()
  93. {
  94. return "[All Turns] When this Digimon with [Greymon] or [Omnimon] in its name would be deleted or returned to your hand or deck by an effect, by placing 1 [X Antibody] from this Digimon's digivolution cards at the bottom of its owner's deck, prevent this Digimon from leaving play.";
  95. }
  96. bool CanSelectCardCondition(CardSource cardSource)
  97. {
  98. if (cardSource.CardNames.Contains("X Antibody"))
  99. {
  100. return true;
  101. }
  102. if (cardSource.CardNames.Contains("XAntibody"))
  103. {
  104. return true;
  105. }
  106. return false;
  107. }
  108. bool CanUseCondition(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.IsExistOnBattleArea(card))
  111. {
  112. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  113. {
  114. if (CardEffectCommons.IsByEffect(hashtable, null))
  115. {
  116. if (card.PermanentOfThisCard().TopCard.HasGreymonName)
  117. {
  118. return true;
  119. }
  120. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"))
  121. {
  122. return true;
  123. }
  124. }
  125. }
  126. }
  127. return false;
  128. }
  129. bool CanActivateCondition(Hashtable hashtable)
  130. {
  131. if (CardEffectCommons.IsExistOnBattleArea(card))
  132. {
  133. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  134. {
  135. return true;
  136. }
  137. }
  138. return false;
  139. }
  140. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  141. {
  142. if (CardEffectCommons.IsExistOnBattleArea(card))
  143. {
  144. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  145. {
  146. bool returnedToLibrary = false;
  147. List<CardSource> selectedCards = new List<CardSource>();
  148. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  149. selectCardEffect.SetUp(
  150. canTargetCondition: CanSelectCardCondition,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. canNoSelect: () => true,
  154. selectCardCoroutine: SelectCardCoroutine,
  155. afterSelectCardCoroutine: null,
  156. message: "Select 1 digivolution card to return to the bottom of deck.",
  157. maxCount: 1,
  158. canEndNotMax: false,
  159. isShowOpponent: true,
  160. mode: SelectCardEffect.Mode.Custom,
  161. root: SelectCardEffect.Root.Custom,
  162. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  163. canLookReverseCard: true,
  164. selectPlayer: card.Owner,
  165. cardEffect: null);
  166. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to return to the bottom of deck.", "The opponent is selecting 1 digivolution card to return to the bottom of deck.");
  167. selectCardEffect.SetNotShowCard();
  168. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  169. IEnumerator SelectCardCoroutine(CardSource cardSource)
  170. {
  171. selectedCards.Add(cardSource);
  172. yield return null;
  173. }
  174. if (selectedCards.Count >= 1)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(new ReturnToLibraryBottomDigivolutionCardsClass(
  177. card.PermanentOfThisCard(),
  178. selectedCards, CardEffectCommons.CardEffectHashtable(activateClass)).ReturnToLibraryBottomDigivolutionCards());
  179. returnedToLibrary = true;
  180. }
  181. if (returnedToLibrary)
  182. {
  183. if (CardEffectCommons.IsExistOnBattleArea(card))
  184. {
  185. Permanent selectedPermanent = card.PermanentOfThisCard();
  186. selectedPermanent.willBeRemoveField = false;
  187. selectedPermanent.HideDeleteEffect();
  188. selectedPermanent.HideHandBounceEffect();
  189. selectedPermanent.HideDeckBounceEffect();
  190. }
  191. }
  192. }
  193. }
  194. }
  195. }
  196. return cardEffects;
  197. }
  198. }
  199. }