EX3_072.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX3
  6. {
  7. public class EX3_072 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OptionSkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Main] Delete 1 of your opponent's level 4 or lower Digimon. By deleting 1 of your Digimon, delete 1 of your opponent's level 6 or lower Digimon instead.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  25. {
  26. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  27. {
  28. if (permanent.CanBeDestroyedBySkill(activateClass))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  39. }
  40. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  41. {
  42. int maxLevel = 4;
  43. bool CanSelectPermanentCondition1(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  46. {
  47. if (permanent.Level <= maxLevel)
  48. {
  49. if (permanent.TopCard.HasLevel)
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: CanSelectPermanentCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: maxCount,
  67. canNoSelect: true,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetUpCustomMessage("Select your 1 Digimon to delete.", "The opponent is selecting opponent's 1 Digimon to delete.");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  76. {
  77. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  78. IEnumerator SuccessProcess()
  79. {
  80. maxLevel = 6;
  81. yield return null;
  82. }
  83. }
  84. }
  85. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  86. {
  87. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  88. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  89. selectPermanentEffect.SetUp(
  90. selectPlayer: card.Owner,
  91. canTargetCondition: CanSelectPermanentCondition1,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. maxCount: maxCount,
  95. canNoSelect: false,
  96. canEndNotMax: false,
  97. selectPermanentCoroutine: null,
  98. afterSelectPermanentCoroutine: null,
  99. mode: SelectPermanentEffect.Mode.Destroy,
  100. cardEffect: activateClass);
  101. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  102. }
  103. }
  104. }
  105. if (timing == EffectTiming.SecuritySkill)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect($"Play 1 [Guilmon] from trash", CanUseCondition, card);
  109. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  110. activateClass.SetIsSecurityEffect(true);
  111. cardEffects.Add(activateClass);
  112. string EffectDiscription()
  113. {
  114. return "[Security] You may play 1 [Guilmon] from your trash without paying the cost.";
  115. }
  116. bool CanSelectCardCondition(CardSource cardSource)
  117. {
  118. if (cardSource != null)
  119. {
  120. if (cardSource.Owner == card.Owner)
  121. {
  122. if (cardSource.CardNames.Contains("Guilmon"))
  123. {
  124. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  125. {
  126. return true;
  127. }
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  136. }
  137. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  138. {
  139. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  140. {
  141. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  142. List<CardSource> selectedCards = new List<CardSource>();
  143. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  144. selectCardEffect.SetUp(
  145. canTargetCondition: CanSelectCardCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. canNoSelect: () => true,
  149. selectCardCoroutine: SelectCardCoroutine,
  150. afterSelectCardCoroutine: null,
  151. message: "Select 1 card to play.",
  152. maxCount: maxCount,
  153. canEndNotMax: false,
  154. isShowOpponent: true,
  155. mode: SelectCardEffect.Mode.Custom,
  156. root: SelectCardEffect.Root.Trash,
  157. customRootCardList: null,
  158. canLookReverseCard: true,
  159. selectPlayer: card.Owner,
  160. cardEffect: activateClass);
  161. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  162. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  163. yield return StartCoroutine(selectCardEffect.Activate());
  164. IEnumerator SelectCardCoroutine(CardSource cardSource)
  165. {
  166. selectedCards.Add(cardSource);
  167. yield return null;
  168. }
  169. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  170. }
  171. }
  172. }
  173. return cardEffects;
  174. }
  175. }
  176. }