BT24_024.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Submarimon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_024 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Armadillomon") ||
  19. (targetPermanent.TopCard.IsLevel3 && targetPermanent.TopCard.HasTSTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Armor Purge
  25. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  26. {
  27. cardEffects.Add(CardEffectFactory.ArmorPurgeEffect(card));
  28. }
  29. #endregion
  30. #region When Attacking
  31. if (timing == EffectTiming.OnAllyAttack)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("Play one [Ts] Tamer for cost reduced by 2.", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  36. activateClass.SetHashString("BT24_024_WA_Play_Tamer");
  37. cardEffects.Add(activateClass);
  38. string EffectDescription()
  39. => "[When Attacking] [Once Per Turn] You may play 1 Tamer card with the [TS] trait from your hand with the play cost reduced by 2.";
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleArea(card) &&
  47. CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayTamerCondition);
  48. }
  49. bool CanPlayTamerCondition(CardSource cardSource)
  50. {
  51. return cardSource.IsTamer &&
  52. cardSource.HasTSTraits &&
  53. CardEffectCommons.CanPlayAsNewPermanent(
  54. cardSource: cardSource,
  55. payCost: false,
  56. cardEffect: activateClass
  57. );
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  60. {
  61. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayTamerCondition))
  62. {
  63. List<CardSource> selectedCards = new List<CardSource>();
  64. int maxCount = 1;
  65. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  66. selectHandEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: CanPlayTamerCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: maxCount,
  72. canNoSelect: false,
  73. canEndNotMax: false,
  74. isShowOpponent: true,
  75. selectCardCoroutine: SelectCardCoroutine,
  76. afterSelectCardCoroutine: null,
  77. mode: SelectHandEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  80. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  81. yield return StartCoroutine(selectHandEffect.Activate());
  82. IEnumerator SelectCardCoroutine(CardSource cardSource)
  83. {
  84. selectedCards.Add(cardSource);
  85. yield return null;
  86. }
  87. #region reduce play cost
  88. ChangeCostClass changeCostClass = new ChangeCostClass();
  89. changeCostClass.SetUpICardEffect("Play Cost -2", CanUseCondition1, card);
  90. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  91. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  92. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  93. ICardEffect GetCardEffect(EffectTiming _timing)
  94. {
  95. if (_timing == EffectTiming.None)
  96. {
  97. return changeCostClass;
  98. }
  99. return null;
  100. }
  101. bool CanUseCondition1(Hashtable hashtable)
  102. {
  103. return true;
  104. }
  105. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  106. {
  107. if (CardSourceCondition(cardSource))
  108. {
  109. if (RootCondition(root))
  110. {
  111. if (PermanentsCondition(targetPermanents))
  112. {
  113. Cost -= 2;
  114. }
  115. }
  116. }
  117. return Cost;
  118. }
  119. bool PermanentsCondition(List<Permanent> targetPermanents)
  120. {
  121. if (targetPermanents == null)
  122. {
  123. return true;
  124. }
  125. else
  126. {
  127. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  128. {
  129. return true;
  130. }
  131. }
  132. return false;
  133. }
  134. bool CardSourceCondition(CardSource cardSource)
  135. {
  136. if (cardSource != null)
  137. {
  138. if (cardSource.Owner == card.Owner)
  139. {
  140. if (cardSource.IsTamer)
  141. {
  142. if (cardSource.HasTSTraits)
  143. {
  144. return true;
  145. }
  146. }
  147. }
  148. }
  149. return false;
  150. }
  151. bool RootCondition(SelectCardEffect.Root root)
  152. {
  153. return true;
  154. }
  155. bool isUpDown()
  156. {
  157. return true;
  158. }
  159. #endregion
  160. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  161. cardSources: selectedCards,
  162. activateClass: activateClass,
  163. payCost: true,
  164. isTapped: false,
  165. root: SelectCardEffect.Root.Hand,
  166. activateETB: true
  167. ));
  168. #region release reducing play cost
  169. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  170. #endregion
  171. }
  172. }
  173. }
  174. #endregion
  175. return cardEffects;
  176. }
  177. }
  178. }