EX12_071.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Saneiketsu Invitation
  4. namespace DCGO.CardEffects.EX12
  5. {
  6. public class EX12_071 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Use Req
  12. if (timing == EffectTiming.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.UseRequirements(card, CardCondition));
  15. bool CardCondition(CardSource cardSource)
  16. {
  17. return cardSource.EqualsTraits("SW");
  18. }
  19. }
  20. #endregion
  21. #region Main
  22. if (timing == EffectTiming.OptionSkill)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Trash 1 [SW] to <Draw 2> and place in battle area", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  27. cardEffects.Add(activateClass);
  28. string EffectDescription()
  29. {
  30. return "[Main] By trashing 1 [SW] trait card from your hand, <Draw 2>. After, place this card in the battle area.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. return cardSource.EqualsTraits("SW");
  39. }
  40. IEnumerator ActivateCoroutine(Hashtable hashtable)
  41. {
  42. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  43. selectHandEffect.SetUp(
  44. selectPlayer: card.Owner,
  45. canTargetCondition: CanSelectCardCondition,
  46. canTargetCondition_ByPreSelecetedList: null,
  47. canEndSelectCondition: null,
  48. maxCount: 1,
  49. canNoSelect: true,
  50. canEndNotMax: false,
  51. isShowOpponent: true,
  52. selectCardCoroutine: null,
  53. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  54. mode: SelectHandEffect.Mode.Discard,
  55. cardEffect: activateClass);
  56. yield return StartCoroutine(selectHandEffect.Activate());
  57. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  58. {
  59. if (cardSources.Count >= 1)
  60. {
  61. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  62. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  63. }
  64. }
  65. }
  66. }
  67. #endregion
  68. #region Delay
  69. if (timing == EffectTiming.OnEnterFieldAnyone)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("May digivolve 1 of your [SW] Digimon into a [Saneiketsu] for free", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  74. cardEffects.Add(activateClass);
  75. string EffectDescription()
  76. {
  77. return "[All Turns] When any of your [SW] trait Digimon are played, <Delay> .\r\n• 1 of your [SW] trait Digimon may digivolve into a [Saneiketsu] trait Digimon card in the hand without paying the cost.";
  78. }
  79. bool CanUseCondition(Hashtable hashtable)
  80. {
  81. return CardEffectCommons.CanDeclareOptionDelayEffect(card)
  82. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition);
  83. }
  84. bool PermanentCondition(Permanent permanent)
  85. {
  86. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  87. && permanent.TopCard.EqualsTraits("SW");
  88. }
  89. bool CanSelectCardCondition(CardSource cardSource)
  90. {
  91. return cardSource.IsDigimon
  92. && cardSource.EqualsTraits("Saneiketsu");
  93. }
  94. bool CanSelectPermanentCondition(Permanent permanent)
  95. {
  96. if (PermanentCondition(permanent))
  97. {
  98. foreach (CardSource cardSource in card.Owner.HandCards)
  99. {
  100. if (CanSelectCardCondition(cardSource)
  101. && cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  102. return true;
  103. }
  104. }
  105. return false;
  106. }
  107. IEnumerator ActivateCoroutine(Hashtable hashtable)
  108. {
  109. yield return ContinuousController.instance.StartCoroutine(
  110. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  111. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  112. activateClass: activateClass, successProcess: _ => SuccessProcess(),
  113. failureProcess: null));
  114. IEnumerator SuccessProcess()
  115. {
  116. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  117. {
  118. Permanent selectedPermanent = null;
  119. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: CanSelectPermanentCondition,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: 1,
  126. canNoSelect: true,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: SelectPermanentCoroutine,
  129. afterSelectPermanentCoroutine: null,
  130. mode: SelectPermanentEffect.Mode.Custom,
  131. cardEffect: activateClass);
  132. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  133. "The opponent is selecting 1 Digimon that will digivolve.");
  134. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  135. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  136. {
  137. selectedPermanent = permanent;
  138. yield return null;
  139. }
  140. if (selectedPermanent != null)
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  143. targetPermanent: selectedPermanent,
  144. cardCondition: CanSelectCardCondition,
  145. payCost: false,
  146. reduceCostTuple: null,
  147. fixedCostTuple: null,
  148. ignoreDigivolutionRequirementFixedCost: -1,
  149. isHand: true,
  150. activateClass: activateClass,
  151. successProcess: null));
  152. }
  153. }
  154. }
  155. }
  156. }
  157. #endregion
  158. #region Security
  159. if (timing == EffectTiming.SecuritySkill)
  160. {
  161. string EffectDescription() => "[Security] Activate this card's [Main] effect.";
  162. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: "Trash 1 [SW] to <Draw 2> and place in battle area", effectDiscription: EffectDescription());
  163. }
  164. #endregion
  165. return cardEffects;
  166. }
  167. }
  168. }