EX9_038.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Kuwagamon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_038 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel3 &&
  19. targetPermanent.TopCard.EqualsTraits("DM");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 2,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. #endregion
  29. #region Training
  30. if (timing == EffectTiming.OnDeclaration)
  31. {
  32. cardEffects.Add(CardEffectFactory.TrainingEffect(card: card));
  33. }
  34. #endregion
  35. #region Shared OP / WA
  36. string SharedEffectName = "Place 1 hand card as FD bottom source, suspend 1 digimon";
  37. string SharedEffectDescription(string tag) => $"[{tag}] By placing 1 card in your hand face down as this Digimon's bottom digivolution card, suspend 1 of your opponent's Digimon. It can't unsuspend in their next unsuspend phase.";
  38. bool SharedCanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  41. && card.Owner.HandCards.Count >= 1;
  42. }
  43. bool SharedCanSelectPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  46. }
  47. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  48. {
  49. CardSource selectedCard = null;
  50. int maxCount = Math.Min(1, card.Owner.HandCards.Count);
  51. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  52. selectHandEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: _ => true,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: maxCount,
  58. canNoSelect: true,
  59. canEndNotMax: true,
  60. isShowOpponent: false,
  61. selectCardCoroutine: SelectCardCoroutine,
  62. afterSelectCardCoroutine: null,
  63. mode: SelectHandEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. selectHandEffect.SetUpCustomMessage("Select 1 card to add as FD Source", "The opponent is selecting 1 card to add as FD source");
  66. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  67. IEnumerator SelectCardCoroutine(CardSource cardSource)
  68. {
  69. selectedCard = cardSource;
  70. yield return null;
  71. }
  72. if (selectedCard != null)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  75. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  76. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedCanSelectPermanentCondition))
  77. {
  78. Permanent selectedPermanent = null;
  79. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermanentCondition));
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: SharedCanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: maxCount1,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: SelectPermanentCoroutine,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend", "The opponent is selecting 1 Digimon to suspend");
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  96. {
  97. selectedPermanent = permanent;
  98. yield return null;
  99. }
  100. if (selectedPermanent != null)
  101. {
  102. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  103. {
  104. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { selectedPermanent }, hashtable).Tap());
  105. }
  106. bool PermanentCondition(Permanent permanent)
  107. {
  108. return permanent == selectedPermanent;
  109. }
  110. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspendPlayerEffect(
  111. permanentCondition: PermanentCondition,
  112. effectDuration: EffectDuration.UntilOwnerActivePhase,
  113. activateClass: activateClass,
  114. isOnlyActivePhase: true,
  115. effectName: "Your Digimon can't unsuspend"));
  116. }
  117. }
  118. }
  119. }
  120. #endregion
  121. #region On Play
  122. if (timing == EffectTiming.OnEnterFieldAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  126. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("On Play"));
  127. cardEffects.Add(activateClass);
  128. bool CanUseCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  131. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  132. }
  133. }
  134. #endregion
  135. #region When Attacking
  136. if (timing == EffectTiming.OnAllyAttack)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  140. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("When Attacking"));
  141. cardEffects.Add(activateClass);
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  145. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  146. }
  147. }
  148. #endregion
  149. #region ESS
  150. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  151. {
  152. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  153. }
  154. #endregion
  155. return cardEffects;
  156. }
  157. }
  158. }