BT22_058.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Dreammon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_058 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Link Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasAppmonTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  20. }
  21. #endregion
  22. #region Link Effect
  23. if (timing == EffectTiming.OnDeclaration)
  24. {
  25. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  26. }
  27. #endregion
  28. #region Alternative Digivolution Condition
  29. if (timing == EffectTiming.None)
  30. {
  31. bool PermanentCondition(Permanent targetPermanent)
  32. {
  33. return targetPermanent.TopCard.EqualsTraits("Stnd.");
  34. }
  35. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  36. permanentCondition: PermanentCondition,
  37. digivolutionCost: 2,
  38. ignoreDigivolutionRequirement: false,
  39. card: card,
  40. condition: null)
  41. );
  42. }
  43. #endregion
  44. #region All Turns - When Linked
  45. if (timing == EffectTiming.WhenLinked)
  46. {
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect("1 digimon cannot be bounced to deck or hand", CanUseCondition, card);
  49. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  50. activateClass.SetHashString("BT22_058_BounceImmunity");
  51. cardEffects.Add(activateClass);
  52. string EffectDiscription()
  53. {
  54. return "[All Turns] [Once Per Turn] When this Digimon gets linked, your opponent's effects can't return 1 of your Digimon to hands or decks until their turn ends.";
  55. }
  56. bool PermanentCondition(Permanent permanent)
  57. {
  58. return permanent == card.PermanentOfThisCard();
  59. }
  60. bool CardCondition(CardSource source)
  61. {
  62. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  63. }
  64. bool CanUseCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  67. CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, CardCondition);
  68. }
  69. bool CanActivateCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  72. }
  73. bool MyDigimonCondition(Permanent permanent)
  74. {
  75. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable hashtable)
  78. {
  79. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, MyDigimonCondition))
  80. {
  81. Permanent selectedPermanent = null;
  82. #region Select Permanent
  83. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, MyDigimonCondition));
  84. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  85. selectPermanentEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: MyDigimonCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: maxCount,
  91. canNoSelect: false,
  92. canEndNotMax: false,
  93. selectPermanentCoroutine: SelectPermanentCoroutine,
  94. afterSelectPermanentCoroutine: null,
  95. mode: SelectPermanentEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. selectedPermanent = permanent;
  100. yield return null;
  101. }
  102. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain bounce immunity", "The opponent is selecting 1 Digimon gain bounce immunity.");
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. #endregion
  105. if (selectedPermanent != null)
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(
  108. CardEffectCommons.GainCanNotReturnToDeck(selectedPermanent, null, EffectDuration.UntilOpponentTurnEnd, activateClass, "Can not be bounced to deck"));
  109. yield return ContinuousController.instance.StartCoroutine(
  110. CardEffectCommons.GainCanNotReturnToHand(selectedPermanent, null, EffectDuration.UntilOpponentTurnEnd, activateClass, "Can not be bounced to hand"));
  111. }
  112. }
  113. }
  114. }
  115. #endregion
  116. #region When Linked
  117. if (timing == EffectTiming.WhenLinked)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect("De-Digivolve 1", CanUseCondition, card);
  121. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  122. activateClass.SetIsLinkedEffect(true);
  123. cardEffects.Add(activateClass);
  124. string EffectDiscription() => "[When Linking] <De-Digivolve 1> 1 of your opponent's Digimon. (Trash the top card. You can't trash past level 3 cards.)";
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  128. }
  129. bool CanActivateCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  132. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, OpponentCondition);
  133. }
  134. bool OpponentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  135. IEnumerator ActivateCoroutine(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, OpponentCondition))
  138. {
  139. Permanent selectedPermanent = null;
  140. #region Select Permanent
  141. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, OpponentCondition));
  142. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  143. selectPermanentEffect.SetUp(
  144. selectPlayer: card.Owner,
  145. canTargetCondition: OpponentCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. maxCount: maxCount,
  149. canNoSelect: false,
  150. canEndNotMax: false,
  151. selectPermanentCoroutine: SelectPermanentCoroutine,
  152. afterSelectPermanentCoroutine: null,
  153. mode: SelectPermanentEffect.Mode.Custom,
  154. cardEffect: activateClass);
  155. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  156. {
  157. selectedPermanent = permanent;
  158. yield return null;
  159. }
  160. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to de-digivolve.", "The opponent is selecting 1 Digimon to de-digivolve.");
  161. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  162. #endregion
  163. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(
  164. new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  165. }
  166. }
  167. }
  168. #endregion
  169. return cardEffects;
  170. }
  171. }
  172. }