BT25_093.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. => (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) || CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  48. && card.CanLinkToTargetPermanent(permanent, false, true);
  49. bool CanSelectEnemyOptionCondition(Permanent permanent)
  50. => CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)
  51. && permanent.IsOption;
  52. bool CanSelectEnemyPermamentCondition(Permanent permanent)
  53. => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy, null);
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. IEnumerator DeletionFailureProcess()
  57. {
  58. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectEnemyOptionCondition))
  59. {
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: CanSelectEnemyOptionCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: 1,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: null,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Destroy,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetUpCustomMessage("Select 1 option in battle area to trash", "The opponent is selecting 1 option in battle area to trash.");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. }
  76. }
  77. // Delete all opponent digimon with lowest DP, if didnt delete, trash 1 opponent option
  78. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectEnemyPermamentCondition))
  79. {
  80. List<Permanent> targetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().FindAll(CanSelectEnemyPermamentCondition);
  81. if (targetPermanents.Any())
  82. {
  83. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  84. targetPermanents: targetPermanents,
  85. activateClass: activateClass,
  86. successProcess: null,
  87. failureProcess: DeletionFailureProcess));
  88. }
  89. }
  90. else yield return ContinuousController.instance.StartCoroutine(DeletionFailureProcess());
  91. // Link to 1 Owner digimon on the field
  92. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectOwnerPermamentCondition))
  93. {
  94. Permanent selectedPermament = null;
  95. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, CanSelectOwnerPermamentCondition));
  96. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  97. selectPermanentEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectOwnerPermamentCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: true,
  104. canEndNotMax: false,
  105. selectPermanentCoroutine: SelectPermanentCoroutine,
  106. afterSelectPermanentCoroutine: null,
  107. mode: SelectPermanentEffect.Mode.Custom,
  108. cardEffect: activateClass);
  109. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  110. {
  111. selectedPermament = permanent;
  112. yield return null;
  113. }
  114. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to link this card to", "The opponent is selecting 1 Digimon to link this card to.");
  115. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  116. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddLinkCard(
  117. addedLinkCard: card,
  118. cardEffect: activateClass));
  119. }
  120. }
  121. }
  122. #endregion
  123. #region Security
  124. if (timing == EffectTiming.SecuritySkill)
  125. {
  126. string EffectDiscription() => "[Security] Activate this card's [Main] effect.";
  127. 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());
  128. }
  129. #endregion
  130. #region Link ESS
  131. if (timing == EffectTiming.OnAllyAttack)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect("Delete 1 enemy digimon with equal or less DP", CanUseCondition, card);
  135. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  136. activateClass.SetHashString("BT25-093-Linked-WA");
  137. activateClass.SetIsLinkedEffect(true);
  138. cardEffects.Add(activateClass);
  139. string EffectDescription() => "[When Attacking] [Once Per Turn] Delete 1 of your opponent's Digimon with as much DP as this Digimon or less.";
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.IsExistOnBattleArea(card)
  143. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  144. }
  145. bool CanActivateCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.IsExistOnBattleArea(card);
  148. }
  149. bool ValidOpponentDigimon(Permanent permanent)
  150. {
  151. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  152. && permanent.HasDP
  153. && permanent.DP <= card.PermanentOfThisCard().DP;
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable hashtable)
  156. {
  157. if (CardEffectCommons.HasMatchConditionPermanent(ValidOpponentDigimon))
  158. {
  159. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  160. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(ValidOpponentDigimon));
  161. selectPermanentEffect.SetUp(
  162. selectPlayer: card.Owner,
  163. canTargetCondition: ValidOpponentDigimon,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. maxCount: maxCount,
  167. canNoSelect: false,
  168. canEndNotMax: false,
  169. selectPermanentCoroutine: null,
  170. afterSelectPermanentCoroutine: null,
  171. mode: SelectPermanentEffect.Mode.Destroy,
  172. cardEffect: activateClass);
  173. 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.");
  174. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  175. }
  176. }
  177. }
  178. #endregion
  179. return cardEffects;
  180. }
  181. }
  182. }