BT25_084.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Titamon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_084 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool Condition(Permanent permanent)
  17. {
  18. return permanent.TopCard.EqualsCardName("Titamon")
  19. && permanent.TopCard.CardColors.Distinct().Count() != 3;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: Condition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. if (timing == EffectTiming.None)
  24. {
  25. bool Condition(Permanent permanent)
  26. {
  27. return permanent.TopCard.HasTSTraits;
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 5, permanentCondition: Condition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region Shared OP / WD / WA
  33. string SharedHashString = "BT25_084_OP_WD_WA";
  34. string SharedEffectName = "By trashing 1 card in your hand, delete all opponent's highest DP digimon. If entering by effect, trash their top security.";
  35. string SharedEffectDescription(string tag)
  36. => $"[{tag}] [Once Per Turn] By trashing 1 card in your hand, delete all of your opponent's highest DP Digimon. After, if played or digivolved by an effect, trash their top security card.";
  37. CardEffectFactory.ActivateClassesForSharedEffects
  38. (ref cardEffects, timing, card,
  39. SharedEffectName,
  40. SharedActivateCoroutine,
  41. SharedEffectDescription,
  42. additionalActivateCondition: AdditionalActivateCondition,
  43. maxCountPerTurn: 1,
  44. hashValue: SharedHashString,
  45. optional: false,
  46. isSkippable: true,
  47. onPlay: true,
  48. whenDigivolving: true,
  49. whenAttacking: true);
  50. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass) => card.Owner.HandCards.Count() > 0;
  51. bool EnteredByEffect(Hashtable hashtable)
  52. {
  53. return (CardEffectCommons.CanTriggerOnPlay(hashtable, card)
  54. || CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  55. && CardEffectCommons.IsByEffect(hashtable, null);
  56. }
  57. bool StrongestEnemyDigimon(Permanent permanent) => CardEffectCommons.IsMaxDP(permanent, card.Owner.Enemy, null);
  58. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  59. {
  60. bool discarded = false;
  61. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  62. selectHandEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: _ => true,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: 1,
  68. canNoSelect: true,
  69. canEndNotMax: false,
  70. isShowOpponent: true,
  71. selectCardCoroutine: null,
  72. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  73. mode: SelectHandEffect.Mode.Discard,
  74. cardEffect: activateClass);
  75. yield return StartCoroutine(selectHandEffect.Activate());
  76. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  77. {
  78. if (cardSources.Count() >= 1)
  79. {
  80. discarded = true;
  81. yield return null;
  82. }
  83. }
  84. if (discarded)
  85. {
  86. List<Permanent> targetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(StrongestEnemyDigimon);
  87. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(targetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  88. if (EnteredByEffect(hashtable))
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  91. player: card.Owner.Enemy,
  92. destroySecurityCount: 1,
  93. cardEffect: activateClass,
  94. fromTop: true).DestroySecurity());
  95. }
  96. }
  97. else
  98. {
  99. activateClass.RemoveUse();
  100. }
  101. }
  102. #endregion
  103. #region All Turns - When would leave
  104. if (timing == EffectTiming.WhenRemoveField)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Trash 2 cards from hand to prevent this Digimon from leaving play", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  109. activateClass.SetHashString("BT25_084_AT");
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area, by trashing 2 cards in your hand, it doesn't leave.";
  114. }
  115. bool CanUseCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.IsExistOnBattleArea(card)
  118. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  119. }
  120. bool CanActivateCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.IsExistOnBattleArea(card)
  123. && card.Owner.HandCards.Count() >= 2;
  124. }
  125. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  126. {
  127. bool discarded = false;
  128. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  129. selectHandEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: _ => true,
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: 2,
  135. canNoSelect: true,
  136. canEndNotMax: false,
  137. isShowOpponent: true,
  138. selectCardCoroutine: null,
  139. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  140. mode: SelectHandEffect.Mode.Discard,
  141. cardEffect: activateClass);
  142. yield return StartCoroutine(selectHandEffect.Activate());
  143. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  144. {
  145. if (cardSources.Count() >= 2)
  146. {
  147. discarded = true;
  148. yield return null;
  149. }
  150. }
  151. if (discarded)
  152. {
  153. Permanent thisPermanent = card.PermanentOfThisCard();
  154. thisPermanent.willBeRemoveField = false;
  155. thisPermanent.HideDeleteEffect();
  156. thisPermanent.HideHandBounceEffect();
  157. thisPermanent.HideDeckBounceEffect();
  158. thisPermanent.HideWillRemoveFieldEffect();
  159. }
  160. else
  161. {
  162. activateClass.RemoveUse();
  163. }
  164. }
  165. }
  166. #endregion
  167. #region All Turns, when hand trashed
  168. if (timing == EffectTiming.OnDiscardHand)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("Delete 1 of your opponent's lowest DP Digimon", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  173. cardEffects.Add(activateClass);
  174. string EffectDescription()
  175. {
  176. return "[All Turns] When your hand is trashed from, delete 1 of your opponent's lowest DP Digimon.";
  177. }
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.IsExistOnBattleArea(card)
  181. && CardEffectCommons.CanTriggerOnTrashHand(hashtable, null, cardSource => cardSource.Owner == card.Owner);
  182. }
  183. bool CanActivateCondition(Hashtable hashtable)
  184. {
  185. return CardEffectCommons.IsExistOnBattleArea(card);
  186. }
  187. bool IsWeakestEnemyDigimon(Permanent permanent) => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy, null);
  188. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  189. {
  190. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakestEnemyDigimon))
  191. {
  192. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  193. selectPermanentEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: IsWeakestEnemyDigimon,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: 1,
  199. canNoSelect: false,
  200. canEndNotMax: false,
  201. selectPermanentCoroutine: null,
  202. afterSelectPermanentCoroutine: null,
  203. mode: SelectPermanentEffect.Mode.Destroy,
  204. cardEffect: activateClass);
  205. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  206. }
  207. }
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }