P_242.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Rei Katsura
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_242 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Start of Your Main Phase
  12. if (timing == EffectTiming.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Trash 1 [System]/[Life]/[Transmutation] to <Draw 1> and gain 1 memory", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  17. activateClass.SetIsSkippable(true);
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[Start of Your Main Phase] By trashing 1 card with the [System], [Life] or [Transmutation] trait card from your hand, <Draw 1> and gain 1 memory.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  26. && CardEffectCommons.IsOwnerTurn(card);
  27. }
  28. bool CanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  31. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. return cardSource.EqualsTraits("System")
  36. || cardSource.EqualsTraits("Life")
  37. || cardSource.EqualsTraits("Transmutation");
  38. }
  39. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  40. {
  41. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  42. selectHandEffect.SetUp(
  43. selectPlayer: card.Owner,
  44. canTargetCondition: CanSelectCardCondition,
  45. canTargetCondition_ByPreSelecetedList: null,
  46. canEndSelectCondition: null,
  47. maxCount: 1,
  48. canNoSelect: true,
  49. canEndNotMax: false,
  50. isShowOpponent: true,
  51. selectCardCoroutine: null,
  52. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  53. mode: SelectHandEffect.Mode.Discard,
  54. cardEffect: activateClass);
  55. yield return StartCoroutine(selectHandEffect.Activate());
  56. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  57. {
  58. if (cardSources.Count >= 1)
  59. {
  60. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  61. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  62. }
  63. }
  64. }
  65. }
  66. #endregion
  67. #region Main
  68. if (timing == EffectTiming.OnDeclaration)
  69. {
  70. ActivateClass activateClass = new ActivateClass();
  71. activateClass.SetUpICardEffect("By suspending, you may link 1 [System]/[Life]/[Transmutation] from trash for 1 less", CanUseCondition, card);
  72. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  73. cardEffects.Add(activateClass);
  74. string EffectDescription()
  75. => "[Main] By suspending this Tamer, you may link 1 [System], [Life] or [Transmutation] trait Digimon card from your trash to 1 of your Digimon with the cost reduced by 1.";
  76. bool CanUseCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass);
  79. }
  80. bool CanActivateCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  83. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  84. }
  85. bool CanSelectCardCondition(CardSource cardSource)
  86. {
  87. return (cardSource.EqualsTraits("System")
  88. || cardSource.EqualsTraits("Life")
  89. || cardSource.EqualsTraits("Transmutation"))
  90. && cardSource.CanLink(true);
  91. }
  92. bool CanSelectPermanentCondition(Permanent permanent, CardSource cardSource)
  93. {
  94. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  95. && cardSource.CanLinkToTargetPermanent(permanent, true);
  96. }
  97. IEnumerator ActivateCoroutine(Hashtable hashtable)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  100. #region Link Cost Reduction
  101. ICardEffect GetCardEffect(EffectTiming _timing)
  102. {
  103. if (_timing == EffectTiming.None)
  104. {
  105. return CardEffectFactory.GrantedReduceLinkCostClass(
  106. card: card,
  107. reducedCost: 1,
  108. cardSourceCondition: _ => true,
  109. permanentCondition: _ => true,
  110. rootCondition: _ => true
  111. );
  112. }
  113. return null;
  114. }
  115. card.Owner.UntilCalculateFixedCostEffect.Add(GetCardEffect);
  116. #endregion
  117. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  118. {
  119. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  120. selectCardEffect.SetUp(
  121. canTargetCondition: CanSelectCardCondition,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. canNoSelect: () => true,
  125. selectCardCoroutine: SelectCardCoroutine,
  126. afterSelectCardCoroutine: null,
  127. message: "Select 1 card to link",
  128. maxCount: 1,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. mode: SelectCardEffect.Mode.Custom,
  132. root: SelectCardEffect.Root.Trash,
  133. customRootCardList: null,
  134. canLookReverseCard: true,
  135. selectPlayer: card.Owner,
  136. cardEffect: activateClass);
  137. selectCardEffect.SetUpCustomMessage(
  138. "Select 1 card to link.",
  139. "The opponent is selecting 1 card to link.");
  140. yield return StartCoroutine(selectCardEffect.Activate());
  141. IEnumerator SelectCardCoroutine(CardSource cardSource)
  142. {
  143. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, permanent => CanSelectPermanentCondition(permanent, cardSource)))
  144. {
  145. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  146. selectPermanentEffect.SetUp(
  147. selectPlayer: card.Owner,
  148. canTargetCondition: permanent => CanSelectPermanentCondition(permanent, cardSource),
  149. canTargetCondition_ByPreSelecetedList: null,
  150. canEndSelectCondition: null,
  151. maxCount: 1,
  152. canNoSelect: true,
  153. canEndNotMax: false,
  154. selectPermanentCoroutine: SelectPermanentCoroutine,
  155. afterSelectPermanentCoroutine: null,
  156. mode: SelectPermanentEffect.Mode.Custom,
  157. cardEffect: activateClass);
  158. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to link to", "Your opponent is choosing 1 digimon to link to");
  159. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  160. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  161. {
  162. yield return ContinuousController.instance.StartCoroutine(new ILinkCard(true, cardSource, permanent, activateClass).LinkCard());
  163. }
  164. }
  165. }
  166. }
  167. #region Remove Link Cost Reduction
  168. card.Owner.UntilCalculateFixedCostEffect.Remove(GetCardEffect);
  169. #endregion
  170. }
  171. }
  172. #endregion
  173. #region Security
  174. if (timing == EffectTiming.SecuritySkill)
  175. {
  176. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  177. }
  178. #endregion
  179. return cardEffects;
  180. }
  181. }
  182. }