BT12_018.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT12
  5. {
  6. public class BT12_018 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnAllyAttack)
  12. {
  13. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  14. }
  15. if (timing == EffectTiming.OnEnterFieldAnyone)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Delete 1 Digimon with 6000 DP or less", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[When Digivolving] Delete 1 of your opponent's Digimon with 6000 DP or less.";
  24. }
  25. bool CanSelectPermanentCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  28. {
  29. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  39. }
  40. bool CanActivateCondition(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.IsExistOnBattleArea(card))
  43. {
  44. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  52. {
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  54. {
  55. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: maxCount,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: null,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Destroy,
  68. cardEffect: activateClass);
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. }
  71. }
  72. }
  73. if (timing == EffectTiming.OnAllyAttack)
  74. {
  75. ActivateClass activateClass = new ActivateClass();
  76. activateClass.SetUpICardEffect("Delete 1 Digimon with 6000 DP or less, or trash the top card of opponent's security", CanUseCondition, card);
  77. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  78. cardEffects.Add(activateClass);
  79. string EffectDiscription()
  80. {
  81. return "[When Attacking] Delete 1 of your opponent's Digimon with 6000 DP or less. If no Digimon was deleted by this effect, trash the top card of your opponent's security stack.";
  82. }
  83. bool CanSelectPermanentCondition(Permanent permanent)
  84. {
  85. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  86. {
  87. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  88. {
  89. return true;
  90. }
  91. }
  92. return false;
  93. }
  94. bool CanUseCondition(Hashtable hashtable)
  95. {
  96. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  97. }
  98. bool CanActivateCondition(Hashtable hashtable)
  99. {
  100. if (CardEffectCommons.IsExistOnBattleArea(card))
  101. {
  102. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  103. {
  104. return true;
  105. }
  106. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  114. {
  115. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  116. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  117. {
  118. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  119. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  120. selectPermanentEffect.SetUp(
  121. selectPlayer: card.Owner,
  122. canTargetCondition: CanSelectPermanentCondition,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. maxCount: maxCount,
  126. canNoSelect: false,
  127. canEndNotMax: false,
  128. selectPermanentCoroutine: null,
  129. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  130. mode: SelectPermanentEffect.Mode.Custom,
  131. cardEffect: activateClass);
  132. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  135. {
  136. deleteTargetPermanents = permanents.Clone();
  137. yield return null;
  138. }
  139. }
  140. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: null, failureProcess: FailureProcess));
  141. IEnumerator FailureProcess()
  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. }
  151. return cardEffects;
  152. }
  153. }
  154. }