BT21_082.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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<Permanent> cards = new List<Permanent>();
  60. foreach (Permanent selection in card.Owner.GetBattleAreaPermanents().Filter<Permanent>(permanent=>permanent.TopCard.CardColors.Contains(CardColor.Red) && permanent.IsTamer))
  61. {
  62. if (!cards.Some(permanent => permanent.TopCard.HasSameCardName(selection.TopCard)))
  63. cards.Add(selection);
  64. }
  65. return cards.Count;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable hashtable)
  68. {
  69. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  70. {
  71. Permanent selectedPermanent = null;
  72. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to digivolve", "The opponent is selecting 1 digimon to digivolve");
  87. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  88. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  89. {
  90. selectedPermanent = permanent;
  91. yield return null;
  92. }
  93. if (selectedPermanent != null)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  96. targetPermanent: selectedPermanent,
  97. cardCondition: CanSelectCardCondition,
  98. payCost: true,
  99. reduceCostTuple: (reduceCost: costReduction(), reduceCostCardCondition: null),
  100. fixedCostTuple: null,
  101. ignoreDigivolutionRequirementFixedCost: -1,
  102. isHand: true,
  103. activateClass: activateClass,
  104. successProcess: null));
  105. }
  106. }
  107. }
  108. }
  109. #endregion
  110. #region Security
  111. if (timing == EffectTiming.SecuritySkill)
  112. {
  113. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  114. }
  115. #endregion
  116. #region Inherit
  117. if(timing == EffectTiming.OnLoseSecurity)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect("Play tamer on remove security", CanUseCondition, card);
  121. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  122. activateClass.SetHashString("BT21_082Play");
  123. activateClass.SetIsInheritedEffect(true);
  124. cardEffects.Add(activateClass);
  125. string EffectDescription()
  126. {
  127. 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.";
  128. }
  129. bool CanUseCondition(Hashtable hashtable)
  130. {
  131. return CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner.Enemy) && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  132. }
  133. bool CanActivateCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  136. }
  137. bool CanPlayCondition(CardSource cardSource)
  138. {
  139. return cardSource.IsTamer && cardSource.CardColors.Contains(CardColor.Red) && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  140. }
  141. IEnumerator ActivateCoroutine(Hashtable hashtable)
  142. {
  143. List<CardSource> selectedCards = new List<CardSource>();
  144. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  145. selectHandEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanPlayCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: 1,
  151. canNoSelect: true,
  152. canEndNotMax: false,
  153. isShowOpponent: true,
  154. selectCardCoroutine: SelectCardCoroutine,
  155. afterSelectCardCoroutine: null,
  156. mode: SelectHandEffect.Mode.Custom,
  157. cardEffect: activateClass);
  158. selectHandEffect.SetUpCustomMessage("Select 1 Tamer card to play.",
  159. "The opponent is selecting 1 Tamer card to play.");
  160. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  161. yield return StartCoroutine(selectHandEffect.Activate());
  162. IEnumerator SelectCardCoroutine(CardSource cardSource)
  163. {
  164. selectedCards.Add(cardSource);
  165. yield return null;
  166. }
  167. yield return ContinuousController.instance.StartCoroutine(
  168. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  169. payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  170. }
  171. }
  172. #endregion
  173. return cardEffects;
  174. }
  175. }
  176. }