BT25_093.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Ignition Flare
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_093 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Link Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. static bool PermanentCondition(Permanent targetPermanent) => targetPermanent.TopCard.HasTSTraits;
  18. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  19. }
  20. #endregion
  21. #region Link
  22. if (timing == EffectTiming.OnDeclaration)
  23. {
  24. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  25. }
  26. #endregion
  27. #region Use Requirement
  28. if (timing == EffectTiming.None)
  29. {
  30. bool CardCondition(CardSource cardSource) => cardSource.HasTSTraits;
  31. cardEffects.Add(CardEffectFactory.UseRequirements(card, CardCondition));
  32. }
  33. #endregion
  34. #endregion
  35. #region Main
  36. if (timing == EffectTiming.OptionSkill)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Delete all opponent digimon with lowest DP, if this didnt delete trash 1 opponent option card in battle area. Then you may link this to 1 of your digimon", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  41. cardEffects.Add(activateClass);
  42. string EffectDescription()
  43. => "[Main] Delete all of your opponent's Digimon with the lowest DP. If this effect didn't delete, trash 1 of your opponent's Option cards in the battle area. Then, you may link this card to 1 of your Digimon on the field without paying the cost.";
  44. bool CanUseCondition(Hashtable hashtable)
  45. => CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  46. bool CanSelectOwnerPermamentCondition(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsOwnerPermanent(permanent, card)
  49. && permanent.IsDigimon
  50. && card.CanLinkToTargetPermanent(permanent, false, true);
  51. }
  52. bool CanSelectEnemyOptionCondition(Permanent permanent)
  53. => CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  54. && permanent.IsOption;
  55. bool CanSelectEnemyPermamentCondition(Permanent permanent)
  56. => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy, null);
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. IEnumerator DeletionFailureProcess()
  60. {
  61. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectEnemyOptionCondition))
  62. {
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectEnemyOptionCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: 1,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: null,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Destroy,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 option in battle area to trash", "The opponent is selecting 1 option in battle area to trash.");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. }
  79. }
  80. // Delete all opponent digimon with lowest DP, if didnt delete, trash 1 opponent option
  81. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectEnemyPermamentCondition))
  82. {
  83. List<Permanent> targetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().FindAll(CanSelectEnemyPermamentCondition);
  84. if (targetPermanents.Any())
  85. {
  86. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  87. targetPermanents: targetPermanents,
  88. activateClass: activateClass,
  89. successProcess: null,
  90. failureProcess: DeletionFailureProcess));
  91. }
  92. }
  93. else yield return ContinuousController.instance.StartCoroutine(DeletionFailureProcess());
  94. // Link to 1 Owner digimon on the field
  95. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnerPermamentCondition, true))
  96. {
  97. Permanent selectedPermament = null;
  98. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  99. selectPermanentEffect.SetUp(
  100. selectPlayer: card.Owner,
  101. canTargetCondition: CanSelectOwnerPermamentCondition,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. maxCount: 1,
  105. canNoSelect: true,
  106. canEndNotMax: false,
  107. selectPermanentCoroutine: SelectPermanentCoroutine,
  108. afterSelectPermanentCoroutine: null,
  109. mode: SelectPermanentEffect.Mode.Custom,
  110. cardEffect: activateClass);
  111. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  112. {
  113. selectedPermament = permanent;
  114. yield return null;
  115. }
  116. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to link this card to", "The opponent is selecting 1 Digimon to link this card to.");
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddLinkCard(
  119. addedLinkCard: card,
  120. cardEffect: activateClass));
  121. }
  122. }
  123. }
  124. #endregion
  125. #region Security
  126. if (timing == EffectTiming.SecuritySkill)
  127. {
  128. string EffectDiscription() => "[Security] Activate this card's [Main] effect.";
  129. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Delete all opponent digimon with lowest DP, if this didnt delete trash 1 opponent option card in battle area. Then you may link this to 1 of your digimon", effectDiscription: EffectDiscription());
  130. }
  131. #endregion
  132. #region Link ESS
  133. if (timing == EffectTiming.OnAllyAttack)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Delete 1 enemy digimon with equal or less DP", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  138. activateClass.SetHashString("BT25-093-Linked-WA");
  139. activateClass.SetIsLinkedEffect(true);
  140. cardEffects.Add(activateClass);
  141. string EffectDescription() => "[When Attacking] [Once Per Turn] Delete 1 of your opponent's Digimon with as much DP as this Digimon or less.";
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleArea(card)
  145. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleArea(card);
  150. }
  151. bool ValidOpponentDigimon(Permanent permanent)
  152. {
  153. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  154. && permanent.HasDP
  155. && permanent.DP <= card.PermanentOfThisCard().DP;
  156. }
  157. IEnumerator ActivateCoroutine(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.HasMatchConditionPermanent(ValidOpponentDigimon))
  160. {
  161. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  162. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(ValidOpponentDigimon));
  163. selectPermanentEffect.SetUp(
  164. selectPlayer: card.Owner,
  165. canTargetCondition: ValidOpponentDigimon,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canEndSelectCondition: null,
  168. maxCount: maxCount,
  169. canNoSelect: false,
  170. canEndNotMax: false,
  171. selectPermanentCoroutine: null,
  172. afterSelectPermanentCoroutine: null,
  173. mode: SelectPermanentEffect.Mode.Destroy,
  174. cardEffect: activateClass);
  175. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent digimon with as much DP as this Digimon or less to delete", "The opponent is selecting 1 opponent digimon with as much DP as this Digimon or less to delete.");
  176. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  177. }
  178. }
  179. }
  180. #endregion
  181. return cardEffects;
  182. }
  183. }
  184. }