BT11_097.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT11
  5. {
  6. public class BT11_097 : 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.OptionSkill)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  15. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[Main] Delete 1 of your opponent's Digimon with 8000 DP or less. Then, if you have a red Tamer in play, activate 1 of the [On Deletion] effects of 1 of your red Digimon with [Vaccine] in its traits.";
  20. }
  21. bool CanSelectPermanentCondition(Permanent permanent)
  22. {
  23. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  24. {
  25. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  26. {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. bool CanSelectPermanentCondition1(Permanent permanent)
  33. {
  34. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  35. {
  36. if (permanent.TopCard.CardColors.Contains(CardColor.Red))
  37. {
  38. if (permanent.TopCard.CardTraits.Contains("Vaccine"))
  39. {
  40. List<ICardEffect> candidateEffects = permanent.EffectList(EffectTiming.OnDestroyedAnyone)
  41. .Clone()
  42. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsOnDeletion);
  43. if (candidateEffects.Count >= 1)
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: null,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Destroy,
  73. cardEffect: activateClass);
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. }
  76. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Red) && permanent.IsTamer))
  77. {
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  79. {
  80. Permanent selectedPermanent = null;
  81. int maxCount = 1;
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition1,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: null,
  92. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon whose [On Deletion] effect will activate.", "The opponent is selecting 1 Digimon whose [On Deletion] effect will activate.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  98. {
  99. foreach (Permanent permanent in permanents)
  100. {
  101. selectedPermanent = permanent;
  102. }
  103. yield return null;
  104. }
  105. if (selectedPermanent != null)
  106. {
  107. List<ICardEffect> candidateEffects = selectedPermanent.EffectList(EffectTiming.OnDestroyedAnyone)
  108. .Clone()
  109. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsOnDeletion);
  110. if (candidateEffects.Count >= 1)
  111. {
  112. ICardEffect selectedEffect = null;
  113. if (candidateEffects.Count == 1)
  114. {
  115. selectedEffect = candidateEffects[0];
  116. }
  117. else
  118. {
  119. List<SkillInfo> skillInfos = candidateEffects
  120. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  121. List<CardSource> cardSources = candidateEffects
  122. .Map(cardEffect => cardEffect.EffectSourceCard);
  123. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  124. selectCardEffect.SetUp(
  125. canTargetCondition: (cardSource) => true,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. canNoSelect: () => false,
  129. selectCardCoroutine: null,
  130. afterSelectCardCoroutine: null,
  131. message: "Select 1 effect to activate.",
  132. maxCount: 1,
  133. canEndNotMax: false,
  134. isShowOpponent: false,
  135. mode: SelectCardEffect.Mode.Custom,
  136. root: SelectCardEffect.Root.Custom,
  137. customRootCardList: cardSources,
  138. canLookReverseCard: true,
  139. selectPlayer: card.Owner,
  140. cardEffect: activateClass);
  141. selectCardEffect.SetNotShowCard();
  142. selectCardEffect.SetUpSkillInfos(skillInfos);
  143. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  144. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  145. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  146. {
  147. if (selectedIndexes.Count == 1)
  148. {
  149. selectedEffect = candidateEffects[selectedIndexes[0]];
  150. yield return null;
  151. }
  152. }
  153. }
  154. if (selectedEffect != null)
  155. {
  156. Hashtable effectHashtable = CardEffectCommons.OnDeletionHashtable(
  157. new List<Permanent>() { selectedPermanent },
  158. null,
  159. null,
  160. false);
  161. card.Owner.TrashCards.Add(selectedPermanent.TopCard);
  162. card.Owner.TrashCards.Add(selectedEffect.EffectSourceCard);
  163. selectedEffect.EffectSourceCard.PermanentJustBeforeRemoveField = selectedPermanent;
  164. selectedPermanent.TopCard.PermanentJustBeforeRemoveField = selectedPermanent;
  165. bool canUse = selectedEffect.CanUse(effectHashtable);
  166. card.Owner.TrashCards.Remove(selectedPermanent.TopCard);
  167. card.Owner.TrashCards.Remove(selectedEffect.EffectSourceCard);
  168. selectedEffect.EffectSourceCard.PermanentJustBeforeRemoveField = null;
  169. selectedPermanent.TopCard.PermanentJustBeforeRemoveField = null;
  170. if (canUse)
  171. {
  172. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. if (timing == EffectTiming.SecuritySkill)
  182. {
  183. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  184. card: card,
  185. cardEffects: ref cardEffects,
  186. effectName: $"Delete 1 Digimon with 8000 DP or less and activate 1 [On Deletion] effect");
  187. }
  188. return cardEffects;
  189. }
  190. }
  191. }