P_234.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Yujin Ozora
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_234 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Reveal 4, add 1, bot deck rest", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. => "[On Play] Reveal the top 4 cards of your deck. Add 1 [System], [Navi], [Tool] or [Leviathan] trait card among them to the hand. Return the rest to the bottom of the deck.";
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. return cardSource.EqualsTraits("System")
  25. || cardSource.EqualsTraits("Navi")
  26. || cardSource.EqualsTraits("Tool")
  27. || cardSource.EqualsTraits("Leviathan");
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleArea(card)
  32. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  33. }
  34. bool CanActivateCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.IsExistOnBattleArea(card);
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable hashtable)
  39. {
  40. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  41. revealCount: 4,
  42. simplifiedSelectCardConditions:
  43. new SimplifiedSelectCardConditionClass[]
  44. {
  45. new SimplifiedSelectCardConditionClass(
  46. canTargetCondition:CanSelectCardCondition,
  47. message: "Select 1 card with the [System], [Navi], [Tool] or [Leviathan] trait.",
  48. mode: SelectCardEffect.Mode.AddHand,
  49. maxCount: 1,
  50. selectCardCoroutine: null)
  51. },
  52. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  53. activateClass: activateClass
  54. ));
  55. }
  56. }
  57. #endregion
  58. #region Your Turn - Link card trashed
  59. if (timing == EffectTiming.OnLinkCardDiscarded)
  60. {
  61. ActivateClass activateClass = new ActivateClass();
  62. activateClass.SetUpICardEffect("By suspending, you may link from hand for -2 cost", CanUseCondition, card);
  63. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  64. cardEffects.Add(activateClass);
  65. string EffectDescription()
  66. => "[Your Turn] When effect trash any of your Digimon's link cards, by suspending this Tamer, you may link 1 [System], [Navi], [Tool] or [Leviathan] trait card from your hand to 1 of your Digimon with the cost reduced by 2.";
  67. bool CanUseCondition(Hashtable hashtable)
  68. {
  69. return CardEffectCommons.IsExistOnBattleArea(card)
  70. && CardEffectCommons.IsOwnerTurn(card)
  71. && CardEffectCommons.CanTriggerOnTrashLinkedCard(
  72. hashtable,
  73. perm => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(perm, card),
  74. cardEffect => cardEffect != null,
  75. source => source != null);
  76. }
  77. bool CanActivateCondition(Hashtable hashtable)
  78. {
  79. return CardEffectCommons.IsExistOnBattleArea(card)
  80. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  81. }
  82. bool CanSelectCardCondition(CardSource cardSource)
  83. {
  84. return (cardSource.EqualsTraits("System")
  85. || cardSource.EqualsTraits("Navi")
  86. || cardSource.EqualsTraits("Tool")
  87. || cardSource.EqualsTraits("Leviathan"))
  88. && cardSource.CanLink(true);
  89. }
  90. bool CanSelectPermanentCondition(Permanent permanent, CardSource cardSource)
  91. {
  92. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  93. && cardSource.CanLinkToTargetPermanent(permanent, true);
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable hashtable)
  96. {
  97. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  98. #region Link Cost Reduction
  99. ICardEffect GetCardEffect(EffectTiming _timing)
  100. {
  101. if (_timing == EffectTiming.None)
  102. {
  103. return CardEffectFactory.GrantedReduceLinkCostClass(
  104. card: card,
  105. reducedCost: 2,
  106. cardSourceCondition: _ => true,
  107. permanentCondition: _ => true,
  108. rootCondition: _ => true
  109. );
  110. }
  111. return null;
  112. }
  113. card.Owner.UntilCalculateFixedCostEffect.Add(GetCardEffect);
  114. #endregion
  115. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  116. {
  117. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  118. selectHandEffect.SetUp(
  119. selectPlayer: card.Owner,
  120. canTargetCondition: CanSelectCardCondition,
  121. canTargetCondition_ByPreSelecetedList: null,
  122. canEndSelectCondition: null,
  123. maxCount: 1,
  124. canNoSelect: true,
  125. canEndNotMax: false,
  126. isShowOpponent: true,
  127. selectCardCoroutine: SelectCardCoroutine,
  128. afterSelectCardCoroutine: null,
  129. mode: SelectHandEffect.Mode.Custom,
  130. cardEffect: activateClass);
  131. selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  132. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  133. yield return StartCoroutine(selectHandEffect.Activate());
  134. IEnumerator SelectCardCoroutine(CardSource cardSource)
  135. {
  136. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, permanent => CanSelectPermanentCondition(permanent, cardSource)))
  137. {
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: permanent => CanSelectPermanentCondition(permanent, cardSource),
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: 1,
  145. canNoSelect: true,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: SelectPermanentCoroutine,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Custom,
  150. cardEffect: activateClass);
  151. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to link to", "Your opponent is choosing 1 digimon to link to");
  152. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  153. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(new ILinkCard(true, cardSource, permanent, activateClass).LinkCard());
  156. }
  157. }
  158. }
  159. }
  160. #region Remove Link Cost Reduction
  161. card.Owner.UntilCalculateFixedCostEffect.Remove(GetCardEffect);
  162. #endregion
  163. }
  164. }
  165. #endregion
  166. #region Security
  167. if (timing == EffectTiming.SecuritySkill)
  168. {
  169. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  170. }
  171. #endregion
  172. return cardEffects;
  173. }
  174. }
  175. }