P_166.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.P
  4. {
  5. public class P_166 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region On Play/When Digivolving Shared
  11. bool SelectDigimonToSuspend(Permanent permanent)
  12. {
  13. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  14. }
  15. bool CanSelectDigimonToDigivolveCondition(CardSource cardSource)
  16. {
  17. return cardSource.IsDigimon && (cardSource.ContainsTraits("Avian") || cardSource.ContainsTraits("Bird"));
  18. }
  19. bool DigimonIsSuspended(Permanent permanent)
  20. {
  21. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  22. {
  23. if (permanent.IsSuspended)
  24. {
  25. if (permanent.IsDigimon)
  26. {
  27. if (permanent != card.PermanentOfThisCard())
  28. {
  29. return true;
  30. }
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanActivateSuspendCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. return CardEffectCommons.HasMatchConditionPermanent(SelectDigimonToSuspend);
  41. }
  42. return false;
  43. }
  44. #endregion
  45. #region On Play
  46. if (timing == EffectTiming.OnEnterFieldAnyone)
  47. {
  48. ActivateClass activateClass = new ActivateClass();
  49. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  50. activateClass.SetUpActivateClass(CanActivateSuspendCondition, ActivateCoroutine, -1, false, EffectDescription());
  51. cardEffects.Add(activateClass);
  52. string EffectDescription()
  53. {
  54. return "[On Play] You may suspend 1 Digimon. Then, if it's your turn, this Digimon may digivolve into a Digimon card with [Avian] or [Bird] in any of its traits in the hand. For every other suspended Digimon, reduce this effect's digivolution cost by 1.";
  55. }
  56. bool CanUseCondition(Hashtable hashtable)
  57. {
  58. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable hashtable)
  61. {
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: SelectDigimonToSuspend,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: 1,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: null,
  72. afterSelectPermanentCoroutine: null,
  73. mode: SelectPermanentEffect.Mode.Tap,
  74. cardEffect: activateClass);
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. if (CardEffectCommons.IsOwnerTurn(card))
  77. {
  78. int suspendedCount = CardEffectCommons.MatchConditionPermanentCount(DigimonIsSuspended);
  79. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  80. targetPermanent: card.PermanentOfThisCard(),
  81. cardCondition: CanSelectDigimonToDigivolveCondition,
  82. payCost: true,
  83. reduceCostTuple: (reduceCost: suspendedCount, reduceCostCardCondition: null),
  84. fixedCostTuple: null,
  85. ignoreDigivolutionRequirementFixedCost: -1,
  86. isHand: true,
  87. activateClass: activateClass,
  88. successProcess: null));
  89. }
  90. }
  91. }
  92. #endregion
  93. #region When Digivolving
  94. if (timing == EffectTiming.OnEnterFieldAnyone)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateSuspendCondition, ActivateCoroutine, -1, false, EffectDescription());
  99. cardEffects.Add(activateClass);
  100. string EffectDescription()
  101. {
  102. return "[When Digivolving] You may suspend 1 Digimon. Then, if it's your turn, this Digimon may digivolve into a Digimon card with [Avian] or [Bird] in any of its traits in the hand. For every other suspended Digimon, reduce this effect's digivolution cost by 1.";
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  107. }
  108. IEnumerator ActivateCoroutine(Hashtable hashtable)
  109. {
  110. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  111. selectPermanentEffect.SetUp(
  112. selectPlayer: card.Owner,
  113. canTargetCondition: SelectDigimonToSuspend,
  114. canTargetCondition_ByPreSelecetedList: null,
  115. canEndSelectCondition: null,
  116. maxCount: 1,
  117. canNoSelect: true,
  118. canEndNotMax: false,
  119. selectPermanentCoroutine: null,
  120. afterSelectPermanentCoroutine: null,
  121. mode: SelectPermanentEffect.Mode.Tap,
  122. cardEffect: activateClass);
  123. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  124. if (CardEffectCommons.IsOwnerTurn(card))
  125. {
  126. int suspendedCount = CardEffectCommons.MatchConditionPermanentCount(DigimonIsSuspended);
  127. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  128. targetPermanent: card.PermanentOfThisCard(),
  129. cardCondition: CanSelectDigimonToDigivolveCondition,
  130. payCost: true,
  131. reduceCostTuple: (reduceCost: suspendedCount, reduceCostCardCondition: null),
  132. fixedCostTuple: null,
  133. ignoreDigivolutionRequirementFixedCost: -1,
  134. isHand: true,
  135. activateClass: activateClass,
  136. successProcess: null));
  137. }
  138. }
  139. }
  140. #endregion
  141. #region Inherited Effect
  142. if (timing == EffectTiming.None)
  143. {
  144. bool Condition()
  145. {
  146. return CardEffectCommons.IsOwnerTurn(card);
  147. }
  148. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(
  149. changeValue: 2000,
  150. isInheritedEffect: true,
  151. card: card,
  152. condition: Condition));
  153. }
  154. #endregion
  155. return cardEffects;
  156. }
  157. }
  158. }