BT24_061.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //Vademon
  4. namespace DCGO.CardEffects.BT24
  5. {
  6. public class BT24_061 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel4 &&
  17. targetPermanent.TopCard.HasTSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  21. card: card, condition: null));
  22. }
  23. #endregion
  24. #region Shared OP/WD
  25. string SharedEffectName() => "Return opponent's Digimon to top deck.";
  26. string SharedEffectDescription(string tag) => $"[{tag}] Return 1 of your opponent's play cost 3 or lower Digimon or Tamers to the top of the deck.";
  27. bool SharedCanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  30. }
  31. bool CanSelectPermanentConditionShared(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  34. && (permanent.IsDigimon || permanent.IsTamer)
  35. && permanent.TopCard.HasPlayCost
  36. && permanent.TopCard.GetCostItself <= 3;
  37. }
  38. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  39. {
  40. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared))
  41. {
  42. int maxCount = 1;
  43. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  44. selectPermanentEffect.SetUp(
  45. selectPlayer: card.Owner,
  46. canTargetCondition: CanSelectPermanentConditionShared,
  47. canTargetCondition_ByPreSelecetedList: null,
  48. canEndSelectCondition: null,
  49. maxCount: maxCount,
  50. canNoSelect: false,
  51. canEndNotMax: false,
  52. selectPermanentCoroutine: null,
  53. afterSelectPermanentCoroutine: null,
  54. mode: SelectPermanentEffect.Mode.PutLibraryTop,
  55. cardEffect: activateClass);
  56. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to the top of the deck.", "The opponent is selecting 1 Digimon to return to the top of the deck.");
  57. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  58. }
  59. }
  60. #endregion
  61. #region On Play
  62. if (timing == EffectTiming.OnEnterFieldAnyone)
  63. {
  64. ActivateClass activateClass = new ActivateClass();
  65. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  66. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  67. cardEffects.Add(activateClass);
  68. bool CanUseCondition(Hashtable hashtable)
  69. {
  70. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  71. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  72. }
  73. }
  74. #endregion
  75. #region When Digivolving
  76. if (timing == EffectTiming.OnEnterFieldAnyone)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  80. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  81. cardEffects.Add(activateClass);
  82. bool CanUseCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  85. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  86. }
  87. }
  88. #endregion
  89. #region When Attacking - ESS
  90. if (timing == EffectTiming.OnAllyAttack)
  91. {
  92. ActivateClass activateClass = new ActivateClass();
  93. activateClass.SetUpICardEffect("<De-Digivolve 1> 1 of your opponent's Digimon", CanUseCondition, card);
  94. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  95. activateClass.SetIsInheritedEffect(true);
  96. activateClass.SetHashString("BT24_061_Inherited");
  97. cardEffects.Add(activateClass);
  98. string EffectDescription()
  99. {
  100. return "[When Attacking] (Once Per Turn) <De-Digivolve 1> 1 of your opponent's Digimon.";
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  105. && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  106. }
  107. bool CanSelectPermanentCondition(Permanent permanent)
  108. {
  109. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  110. }
  111. bool CanActivateCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable hashtable)
  116. {
  117. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  118. {
  119. Permanent selectedPermanent = null;
  120. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  121. selectPermanentEffect.SetUp(
  122. selectPlayer: card.Owner,
  123. canTargetCondition: CanSelectPermanentCondition,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. maxCount: 1,
  127. canNoSelect: false,
  128. canEndNotMax: false,
  129. selectPermanentCoroutine: SelectPermanentCoroutine,
  130. afterSelectPermanentCoroutine: null,
  131. mode: SelectPermanentEffect.Mode.Custom,
  132. cardEffect: activateClass);
  133. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  134. "The opponent is selecting 1 Digimon to De-Digivolve.");
  135. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  136. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  137. {
  138. selectedPermanent = permanent;
  139. yield return null;
  140. }
  141. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(
  142. selectedPermanent, 1, activateClass).Degeneration());
  143. }
  144. }
  145. }
  146. #endregion
  147. return cardEffects;
  148. }
  149. }
  150. }