BT21_017.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Dimetromon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_017 : 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 Tamer with [Owen Dreadnought] in its name from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. => "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 [Owen Dreadnought] from your hand without paying the cost.";
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  24. {
  25. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  26. {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  35. {
  36. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  37. {
  38. if (card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1)
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanSelectCardCondition(CardSource source)
  47. {
  48. if (source.IsTamer)
  49. {
  50. if (source.EqualsCardName("Owen Dreadnought"))
  51. {
  52. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: source, payCost: false, cardEffect: activateClass))
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. IEnumerator ActivateCoroutine(Hashtable hashtable)
  61. {
  62. CardSource selectedCard = null;
  63. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  64. selectHandEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectCardCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: 1,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. selectCardCoroutine: SelectCardCoroutine,
  74. afterSelectCardCoroutine: null,
  75. mode: SelectHandEffect.Mode.Custom,
  76. cardEffect: activateClass);
  77. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  78. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  79. yield return StartCoroutine(selectHandEffect.Activate());
  80. IEnumerator SelectCardCoroutine(CardSource cardSource)
  81. {
  82. selectedCard = cardSource;
  83. yield return null;
  84. }
  85. if (selectedCard != null)
  86. {
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  88. }
  89. }
  90. }
  91. #endregion
  92. #region Your Turn (ESS)
  93. if (timing == EffectTiming.OnLoseSecurity)
  94. {
  95. ActivateClass activateClass = new ActivateClass();
  96. activateClass.SetUpICardEffect("Gain 1 memory", CanUseCondition, card);
  97. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  98. activateClass.SetIsInheritedEffect(true);
  99. activateClass.SetHashString("GainMemory_BT21_017");
  100. cardEffects.Add(activateClass);
  101. string EffectDiscription()
  102. => "[Your Turn] [Once Per Turn] When your opponent's security stack is removed from, gain 1 memory.";
  103. bool CanUseCondition(Hashtable hashtable)
  104. {
  105. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  106. {
  107. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, PlayerCondition))
  108. {
  109. if (CardEffectCommons.IsOwnerTurn(card))
  110. {
  111. return true;
  112. }
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanActivateCondition(Hashtable hashtable)
  118. {
  119. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  120. {
  121. return true;
  122. }
  123. return false;
  124. }
  125. bool PlayerCondition(Player player)
  126. {
  127. if (player == card.Owner.Enemy)
  128. {
  129. return true;
  130. }
  131. return false;
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable hashtable)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  136. }
  137. }
  138. #endregion
  139. return cardEffects;
  140. }
  141. }
  142. }