BT24_034.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Aegiomon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_034 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Elecmon") ||
  19. (targetPermanent.TopCard.IsLevel3 && targetPermanent.TopCard.HasTSTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 2, false, card, null));
  22. }
  23. #endregion
  24. #region Barrier
  25. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  26. {
  27. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Shared WM / OP / WD
  31. string SharedEffectName() => "By adding top security to hand, Play [TS] tamer";
  32. string SharedEffectDescription(string tag) => $"[{tag}] By adding your top security card to the hand, you may play 1 [TS] trait Tamer card from your hand without paying the cost. This effect can't play cards with the same name as any of your Tamers.";
  33. bool SharedCanActivateCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  36. card.Owner.SecurityCards.Count() > 0;
  37. }
  38. bool ValidTamer(CardSource cardSource, ActivateClass activateClass)
  39. {
  40. var tamersOnField = card.Owner.GetFieldPermanents().Filter(x => x.IsTamer).Select(x => x.TopCard);
  41. var fieldNames = tamersOnField
  42. .SelectMany(x => x.CardNames)
  43. .Select(n => n.ToLowerInvariant())
  44. .ToHashSet();
  45. var sourceNames = cardSource.CardNames
  46. .Select(n => n.ToLowerInvariant());
  47. return cardSource.IsTamer &&
  48. cardSource.HasTSTraits &&
  49. !sourceNames.Any(n => fieldNames.Contains(n)) &&
  50. CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  51. }
  52. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  53. {
  54. CardSource topCard = card.Owner.SecurityCards[0];
  55. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  56. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(player: card.Owner, refSkillInfos: ref ContinuousController.instance.nullSkillInfos, activateClass).ReduceSecurity());
  57. if (card.Owner.HandCards.Contains(topCard) && card.Owner.HandCards.Count((cardSource) => ValidTamer(cardSource, activateClass)) >= 1)
  58. {
  59. List<CardSource> selectedCards = new List<CardSource>();
  60. int maxCount = 1;
  61. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  62. selectHandEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: (cardSource) => ValidTamer(cardSource, activateClass),
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: true,
  69. canEndNotMax: false,
  70. isShowOpponent: true,
  71. selectCardCoroutine: SelectCardCoroutine,
  72. afterSelectCardCoroutine: null,
  73. mode: SelectHandEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  76. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  77. yield return StartCoroutine(selectHandEffect.Activate());
  78. IEnumerator SelectCardCoroutine(CardSource cardSource)
  79. {
  80. selectedCards.Add(cardSource);
  81. yield return null;
  82. }
  83. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  84. cardSources: selectedCards,
  85. activateClass: activateClass,
  86. payCost: false,
  87. isTapped: false,
  88. root: SelectCardEffect.Root.Hand,
  89. activateETB: true));
  90. }
  91. }
  92. #endregion
  93. #region When Moving
  94. if (timing == EffectTiming.OnMove)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  98. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDescription("When Moving"));
  99. cardEffects.Add(activateClass);
  100. bool PermanentCondition(Permanent permanent)
  101. {
  102. return permanent == card.PermanentOfThisCard();
  103. }
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  107. CardEffectCommons.CanTriggerOnMove(hashtable, PermanentCondition);
  108. }
  109. }
  110. #endregion
  111. #region On Play
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  116. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDescription("On Play"));
  117. cardEffects.Add(activateClass);
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  121. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  122. }
  123. }
  124. #endregion
  125. #region When Digivolving
  126. if (timing == EffectTiming.OnEnterFieldAnyone)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  130. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDescription("When Digivolving"));
  131. cardEffects.Add(activateClass);
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  135. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  136. }
  137. }
  138. #endregion
  139. #region ESS Barrier
  140. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  141. {
  142. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: true, card: card, condition: null));
  143. }
  144. #endregion
  145. return cardEffects;
  146. }
  147. }
  148. }