BT19_049.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_049 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region When Digivolving
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Henry Wong] from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 [Henry Wong] from your hand without paying the cost.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  26. {
  27. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool IsHenryCardCondition(CardSource cardSource)
  35. {
  36. return cardSource.IsTamer && (cardSource.EqualsCardName("Henry Wong") && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass));
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersHand(card, IsHenryCardCondition) && card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsHenryCardCondition))
  45. {
  46. List<CardSource> selectedCards = new List<CardSource>();
  47. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  48. selectHandEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: IsHenryCardCondition,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. maxCount: 1,
  54. canNoSelect: true,
  55. canEndNotMax: false,
  56. isShowOpponent: true,
  57. selectCardCoroutine: SelectCardCoroutine,
  58. afterSelectCardCoroutine: null,
  59. mode: SelectHandEffect.Mode.Custom,
  60. cardEffect: activateClass);
  61. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  62. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  63. yield return StartCoroutine(selectHandEffect.Activate());
  64. IEnumerator SelectCardCoroutine(CardSource cardSource)
  65. {
  66. selectedCards.Add(cardSource);
  67. yield return null;
  68. }
  69. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  70. }
  71. }
  72. }
  73. #endregion
  74. #region Inherit - When Attacking
  75. if (timing == EffectTiming.OnAllyAttack)
  76. {
  77. ActivateClass activateClass = new ActivateClass();
  78. activateClass.SetUpICardEffect("Suspend 1 opponent's Digimon", CanUseCondition, card);
  79. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  80. activateClass.SetHashString("Suspend1_BT19_049");
  81. activateClass.SetIsInheritedEffect(true);
  82. cardEffects.Add(activateClass);
  83. string EffectDescription()
  84. {
  85. return "[When Attacking] [Once Per Turn] Suspend 1 of your opponent's Digimon.";
  86. }
  87. bool CanUseCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  90. }
  91. bool CanActivateCondition(Hashtable hashtable)
  92. {
  93. if (CardEffectCommons.IsExistOnBattleArea(card))
  94. {
  95. return true;
  96. }
  97. return false;
  98. }
  99. bool CanSelectPermanentCondition(Permanent permanent)
  100. {
  101. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  102. {
  103. return true;
  104. }
  105. return false;
  106. }
  107. IEnumerator ActivateCoroutine(Hashtable hashtable)
  108. {
  109. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  110. {
  111. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  112. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  113. selectPermanentEffect.SetUp(
  114. selectPlayer: card.Owner,
  115. canTargetCondition: CanSelectPermanentCondition,
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. maxCount: 1,
  119. canNoSelect: false,
  120. canEndNotMax: false,
  121. selectPermanentCoroutine: null,
  122. afterSelectPermanentCoroutine: null,
  123. mode: SelectPermanentEffect.Mode.Tap,
  124. cardEffect: activateClass);
  125. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  126. }
  127. }
  128. }
  129. #endregion
  130. return cardEffects;
  131. }
  132. }
  133. }