BT21_009.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Gatchmon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_009 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Link Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasAppmonTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 1, card: card));
  20. }
  21. #endregion
  22. #region Link
  23. if (timing == EffectTiming.OnDeclaration)
  24. {
  25. /// <summary>
  26. /// Used to link a card
  27. /// </summary>
  28. /// <param name="card">Reference to this card</param>
  29. /// <param name="condition">OPTIONAL - Function to check for effect conditions</param>
  30. /// <author>Mike Bunch</author>
  31. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  32. }
  33. #endregion
  34. #region Alternative Digivolution Condition
  35. if (timing == EffectTiming.None)
  36. {
  37. bool PermanentCondition(Permanent targetPermanent)
  38. {
  39. if (targetPermanent.TopCard.IsLevel2)
  40. {
  41. if (targetPermanent.TopCard.EqualsTraits("Appmon") || targetPermanent.TopCard.EqualsTraits("Hero"))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  49. permanentCondition: PermanentCondition,
  50. digivolutionCost: 0,
  51. ignoreDigivolutionRequirement: false,
  52. card: card,
  53. condition: null)
  54. );
  55. }
  56. #endregion
  57. #region Your Turn - When Linked
  58. if (timing == EffectTiming.WhenLinked)
  59. {
  60. ActivateClass activateClass = new ActivateClass();
  61. activateClass.SetUpICardEffect("Play 1 [Haru Shinkai]", CanUseCondition, card);
  62. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  63. activateClass.SetHashString("WhenLinked_BT21_009");
  64. cardEffects.Add(activateClass);
  65. string EffectDiscription()
  66. => "[Your Turn] [Once Per Turn] When this Digimon gets linked, if you have 1 or fewer Tamers, you may play 1 [Haru Shinkai] from your hand without paying the cost.";
  67. bool LinkPermanentCondition(Permanent permanent)
  68. {
  69. return permanent == card.PermanentOfThisCard();
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. if (isExistOnField(card))
  74. {
  75. if (CardEffectCommons.CanTriggerWhenLinked(hashtable, LinkPermanentCondition, null))
  76. {
  77. return true;
  78. }
  79. }
  80. return false;
  81. }
  82. bool CanActivateCondition(Hashtable hashtable)
  83. {
  84. if (isExistOnField(card))
  85. {
  86. if (CardEffectCommons.IsOwnerTurn(card))
  87. {
  88. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  89. {
  90. if (card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1)
  91. {
  92. return true;
  93. }
  94. }
  95. }
  96. }
  97. return false;
  98. }
  99. bool CanSelectCardCondition(CardSource source)
  100. {
  101. if (source.IsTamer)
  102. {
  103. if (source.EqualsCardName("Haru Shinkai"))
  104. {
  105. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: source, payCost: false, cardEffect: activateClass))
  106. {
  107. return true;
  108. }
  109. }
  110. }
  111. return false;
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable hashtable)
  114. {
  115. CardSource selectedCard = null;
  116. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  117. selectHandEffect.SetUp(
  118. selectPlayer: card.Owner,
  119. canTargetCondition: CanSelectCardCondition,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. maxCount: 1,
  123. canNoSelect: true,
  124. canEndNotMax: false,
  125. isShowOpponent: true,
  126. selectCardCoroutine: SelectCardCoroutine,
  127. afterSelectCardCoroutine: null,
  128. mode: SelectHandEffect.Mode.Custom,
  129. cardEffect: activateClass);
  130. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  131. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  132. yield return StartCoroutine(selectHandEffect.Activate());
  133. IEnumerator SelectCardCoroutine(CardSource cardSource)
  134. {
  135. selectedCard = cardSource;
  136. yield return null;
  137. }
  138. if (selectedCard != null)
  139. {
  140. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  141. }
  142. }
  143. }
  144. #endregion
  145. #region Link ESS
  146. #region Raid
  147. if (timing == EffectTiming.OnAllyAttack)
  148. {
  149. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null, isLinkedEffect: true));
  150. }
  151. #endregion
  152. #endregion
  153. return cardEffects;
  154. }
  155. }
  156. }