P_158.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.P
  4. {
  5. public class P_158 : 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
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Reveal the top 4 cards of your deck", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[On Play] Reveal the top 4 cards of your deck. Add 1 card with the [D-Reaper] trait among them to the hand. Return the rest to the bottom of the deck.";
  20. }
  21. bool CanSelectCardCondition(CardSource cardSource)
  22. {
  23. return cardSource.EqualsTraits("D-Reaper");
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. if (CardEffectCommons.IsExistOnBattleArea(card))
  32. {
  33. if (card.Owner.LibraryCards.Count >= 1)
  34. {
  35. return true;
  36. }
  37. }
  38. return false;
  39. }
  40. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  41. {
  42. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  43. revealCount: 4,
  44. simplifiedSelectCardConditions:
  45. new SimplifiedSelectCardConditionClass[]
  46. {
  47. new SimplifiedSelectCardConditionClass(
  48. canTargetCondition:CanSelectCardCondition,
  49. message: "Select 1 card with the [D-Reaper] trait.",
  50. mode: SelectCardEffect.Mode.AddHand,
  51. maxCount: 1,
  52. selectCardCoroutine: null)
  53. },
  54. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  55. activateClass: activateClass
  56. ));
  57. }
  58. }
  59. #endregion
  60. #region Main
  61. if (timing == EffectTiming.OnDeclaration)
  62. {
  63. ActivateClass activateClass = new ActivateClass();
  64. activateClass.SetUpICardEffect("Play 1 Digimon card with the [D-Reaper] trait", CanUseCondition, card);
  65. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  66. cardEffects.Add(activateClass);
  67. string EffectDiscription()
  68. {
  69. return "[Main] By returning this Tamer to the bottom of the deck, you may play 1 Digimon card with the [D-Reaper] trait and play cost of 3 or less from your hand without paying the cost. For each digivolution card of 1 of your [Mother D-Reaper], add 1 to the maximum play cost you may play with this effect.";
  70. }
  71. int getMaxCost()
  72. {
  73. int cost = 3;
  74. int maxCost = 0;
  75. foreach(Permanent permanent in card.Owner.GetBattleAreaPermanents().Filter(IsMotherDReaper))
  76. {
  77. if(permanent.DigivolutionCards.Count > maxCost)
  78. maxCost = permanent.DigivolutionCards.Count;
  79. }
  80. return cost + maxCost;
  81. }
  82. bool IsMotherDReaper(Permanent permanent)
  83. {
  84. return permanent.TopCard.EqualsCardName("Mother D-Reaper");
  85. }
  86. bool HasDReaper(CardSource cardSource)
  87. {
  88. if (cardSource.EqualsTraits("D-Reaper"))
  89. {
  90. if (cardSource.IsDigimon)
  91. {
  92. if (cardSource.GetCostItself <= getMaxCost())
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.IsExistOnBattleArea(card);
  101. }
  102. IEnumerator ActivateCoroutine(Hashtable hashtable)
  103. {
  104. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeckBouncePeremanentAndProcessAccordingToResult(
  105. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  106. activateClass: activateClass,
  107. successProcess: SuccessProcess(),
  108. failureProcess: null));
  109. IEnumerator SuccessProcess()
  110. {
  111. if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasDReaper))
  112. {
  113. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  114. selectHandEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: HasDReaper,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: 1,
  120. canNoSelect: true,
  121. canEndNotMax: false,
  122. isShowOpponent: true,
  123. selectCardCoroutine: null,
  124. afterSelectCardCoroutine: SelectCardCoroutine,
  125. mode: SelectHandEffect.Mode.Custom,
  126. cardEffect: activateClass);
  127. selectHandEffect.SetUpCustomMessage(
  128. "Select 1 Digimon to play.",
  129. "The opponent is selecting 1 Digimon to play.");
  130. yield return StartCoroutine(selectHandEffect.Activate());
  131. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  132. {
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  134. cardSources: cardSources,
  135. activateClass: activateClass,
  136. payCost: false,
  137. isTapped: false,
  138. root: SelectCardEffect.Root.Hand,
  139. activateETB: true));
  140. }
  141. }
  142. }
  143. }
  144. }
  145. #endregion
  146. #region Security Effect
  147. if (timing == EffectTiming.SecuritySkill)
  148. {
  149. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  150. }
  151. #endregion
  152. return cardEffects;
  153. }
  154. }
  155. }