EX4_055.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX4
  6. {
  7. public class EX4_055 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play 1 [Keenan Crier] from hand", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[When Digivolving] If you don't have [Keenan Crier] in play, you may play 1 [Keenan Crier] from your hand without paying the cost.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource != null)
  25. {
  26. if (cardSource.CardNames.Contains("Keenan Crier") || cardSource.CardNames.Contains("KeenanCrier"))
  27. {
  28. if (cardSource.Owner == card.Owner)
  29. {
  30. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (card.Owner.HandCards.Count >= 1)
  48. {
  49. if (card.Owner.GetBattleAreaPermanents().Count((permanent) => permanent.TopCard.CardNames.Contains("Keenan Crier") || permanent.TopCard.CardNames.Contains("KeenanCrier")) == 0)
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  60. {
  61. List<CardSource> selectedCards = new List<CardSource>();
  62. int maxCount = 1;
  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: maxCount,
  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. selectedCards.Add(cardSource);
  83. yield return null;
  84. }
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  86. }
  87. }
  88. }
  89. if (timing == EffectTiming.OnDestroyedAnyone)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect("Opponent trashes 1 card from hand", CanUseCondition, card);
  93. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  94. activateClass.SetIsInheritedEffect(true);
  95. cardEffects.Add(activateClass);
  96. string EffectDiscription()
  97. {
  98. return "[On Deletion] If deleted outside of a battle, your opponent trashes 1 card in their hand.";
  99. }
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  103. }
  104. bool CanActivateCondition(Hashtable hashtable)
  105. {
  106. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  107. {
  108. if (!CardEffectCommons.IsByBattle(hashtable))
  109. {
  110. if (card.Owner.Enemy.HandCards.Count >= 1)
  111. {
  112. return true;
  113. }
  114. }
  115. }
  116. return false;
  117. }
  118. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  119. {
  120. if (card.Owner.Enemy.HandCards.Count >= 1)
  121. {
  122. int discardCount = Math.Min(1, card.Owner.HandCards.Count);
  123. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  124. selectHandEffect.SetUp(
  125. selectPlayer: card.Owner.Enemy,
  126. canTargetCondition: (cardSource) => true,
  127. canTargetCondition_ByPreSelecetedList: null,
  128. canEndSelectCondition: null,
  129. maxCount: discardCount,
  130. canNoSelect: false,
  131. canEndNotMax: false,
  132. isShowOpponent: true,
  133. selectCardCoroutine: null,
  134. afterSelectCardCoroutine: null,
  135. mode: SelectHandEffect.Mode.Discard,
  136. cardEffect: activateClass);
  137. yield return StartCoroutine(selectHandEffect.Activate());
  138. }
  139. }
  140. }
  141. return cardEffects;
  142. }
  143. }
  144. }