BT21_082.cs 9.6 KB

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