BT21_082.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //BT21_082 Takuya
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_082 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start of main
  14. if(timing == EffectTiming.OnStartMainPhase)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Digivolve for reduced cost to hybrid or hero", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return "[Start of Your Main Phase] 1 of your Digimon or Tamers may digivolve into a Digimon card with the [Hybrid] or [Hero] trait in the hand. For each of your red Tamers with different names, reduce this effect's digivolution cost by 1.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  27. {
  28. if(permanent.IsDigimon || permanent.IsTamer)
  29. {
  30. foreach (CardSource cardSource in card.Owner.HandCards)
  31. {
  32. if (CanSelectCardCondition(cardSource))
  33. {
  34. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanSelectCardCondition(CardSource cardSource)
  45. {
  46. return cardSource.EqualsTraits("Hybrid") || cardSource.EqualsTraits("Hero");
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsOwnerTurn(card) &&
  51. CardEffectCommons.IsExistOnBattleArea(card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleArea(card);
  56. }
  57. int costReduction()
  58. {
  59. List<CardSource> cards = card.Owner.GetBattleAreaPermanents()
  60. .Filter<Permanent>(permanent => permanent.TopCard.CardColors.Contains(CardColor.Red) && permanent.IsTamer)
  61. .Map(x => x.TopCard);
  62. return Combinations.GetUniqueNameCardCount(cards);
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. Permanent selectedPermanent = null;
  69. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: maxCount,
  77. canNoSelect: true,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: SelectPermanentCoroutine,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectPermanentEffect.SetUpCustomMessage("Select 1 card to digivolve", "The opponent is selecting 1 card to digivolve");
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  86. {
  87. selectedPermanent = permanent;
  88. yield return null;
  89. }
  90. if (selectedPermanent != null)
  91. {
  92. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  93. targetPermanent: selectedPermanent,
  94. cardCondition: CanSelectCardCondition,
  95. payCost: true,
  96. reduceCostTuple: (reduceCost: costReduction(), reduceCostCardCondition: null),
  97. fixedCostTuple: null,
  98. ignoreDigivolutionRequirementFixedCost: -1,
  99. isHand: true,
  100. activateClass: activateClass,
  101. successProcess: null));
  102. }
  103. }
  104. }
  105. }
  106. #endregion
  107. #region Security
  108. if (timing == EffectTiming.SecuritySkill)
  109. {
  110. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  111. }
  112. #endregion
  113. #region Inherit
  114. if(timing == EffectTiming.OnLoseSecurity)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect("Play tamer on remove security", CanUseCondition, card);
  118. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  119. activateClass.SetHashString("BT21_082Play");
  120. activateClass.SetIsInheritedEffect(true);
  121. cardEffects.Add(activateClass);
  122. string EffectDescription()
  123. {
  124. return "[Your Turn] [Once Per Turn] When your opponent's security stack is removed from, you may play 1 red Tamer card from your hand without paying the cost.";
  125. }
  126. bool CanUseCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.IsOwnerTurn(card) &&
  129. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner.Enemy) &&
  130. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  131. }
  132. bool CanActivateCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  135. }
  136. bool CanPlayCondition(CardSource cardSource)
  137. {
  138. return cardSource.IsTamer && cardSource.HasCardColor(CardColor.Red) && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  139. }
  140. IEnumerator ActivateCoroutine(Hashtable hashtable)
  141. {
  142. List<CardSource> selectedCards = new List<CardSource>();
  143. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  144. selectHandEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: CanPlayCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: 1,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. isShowOpponent: true,
  153. selectCardCoroutine: SelectCardCoroutine,
  154. afterSelectCardCoroutine: null,
  155. mode: SelectHandEffect.Mode.Custom,
  156. cardEffect: activateClass);
  157. selectHandEffect.SetUpCustomMessage("Select 1 Tamer card to play.",
  158. "The opponent is selecting 1 Tamer card to play.");
  159. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  160. yield return StartCoroutine(selectHandEffect.Activate());
  161. IEnumerator SelectCardCoroutine(CardSource cardSource)
  162. {
  163. selectedCards.Add(cardSource);
  164. yield return null;
  165. }
  166. yield return ContinuousController.instance.StartCoroutine(
  167. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  168. payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  169. }
  170. }
  171. #endregion
  172. return cardEffects;
  173. }
  174. }
  175. }