BT24_049.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //Parrotmon
  5. namespace DCGO.CardEffects.BT24
  6. {
  7. public class BT24_049 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel4
  18. && targetPermanent.TopCard.HasTSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Fortitude
  24. if (timing == EffectTiming.OnDestroyedAnyone)
  25. {
  26. cardEffects.Add(CardEffectFactory.FortitudeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Shared OP/WD
  30. string SharedEffectName() => "Suspend 1, if by effect, bounce 1 suspended.";
  31. string SharedEffectDescription(string tag) => $"[{tag}] You may suspend 1 of your opponent's Digimon. Then, if played by effects, you may return 1 of their suspended Digimon with the lowest DP to the hand.";
  32. bool OpponentsDigimon(Permanent permanent)
  33. {
  34. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  35. }
  36. bool OpponentsTappedDigimon(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  39. && permanent.IsSuspended;
  40. }
  41. bool IsMinDPSuspended(Permanent permanent)
  42. {
  43. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy, OpponentsTappedDigimon);
  44. }
  45. bool SharedCanActivateCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  48. }
  49. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  50. {
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: OpponentsDigimon,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: true,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: null,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Tap,
  63. cardEffect: activateClass);
  64. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  65. if (CardEffectCommons.IsByEffect(hashtable, null) && CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  66. {
  67. if (CardEffectCommons.HasMatchConditionPermanent(IsMinDPSuspended))
  68. {
  69. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsMinDPSuspended));
  70. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect1.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: IsMinDPSuspended,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: maxCount,
  77. canNoSelect: true,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: null,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Bounce,
  82. cardEffect: activateClass);
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  84. }
  85. }
  86. }
  87. #endregion
  88. #region On Play
  89. if (timing == EffectTiming.OnEnterFieldAnyone)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  93. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  94. cardEffects.Add(activateClass);
  95. bool CanUseCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  98. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  99. }
  100. }
  101. #endregion
  102. #region When Digivolving
  103. if (timing == EffectTiming.OnEnterFieldAnyone)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  107. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  108. cardEffects.Add(activateClass);
  109. bool CanUseCondition(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  112. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  113. }
  114. }
  115. #endregion
  116. #region ESS
  117. if (timing == EffectTiming.OnEndBattle)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect("Trash top security", CanUseCondition, card);
  121. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  122. activateClass.SetHashString("TrashSecurity_BT24_049");
  123. activateClass.SetIsInheritedEffect(true);
  124. cardEffects.Add(activateClass);
  125. string EffectDescription()
  126. {
  127. return "[All Turns] [Once Per Turn] When this Digimon deletes your opponent's Digimon in battle, trash their top security card.";
  128. }
  129. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  130. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  134. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  135. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  140. }
  141. IEnumerator ActivateCoroutine(Hashtable hashtable)
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  144. player: card.Owner.Enemy,
  145. destroySecurityCount: 1,
  146. cardEffect: activateClass,
  147. fromTop: true).DestroySecurity());
  148. }
  149. }
  150. #endregion
  151. return cardEffects;
  152. }
  153. }
  154. }