BT20_096.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_096 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Trash Main
  12. if (timing == EffectTiming.OnDeclaration)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Return this card to the bottom of the deck to delete 1 opponent Digimon.", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Trash] [Main] If you have 4 or fewer cards in your hand, by paying 6 cost, return this card to the bottom of the deck and delete 1 of your opponent's unsuspended Digimon.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. if (CardEffectCommons.IsOwnerTurn(card))
  25. {
  26. if (CardEffectCommons.IsExistOnTrash(card))
  27. {
  28. if (card.Owner.HandCards.Count <= 4)
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  39. {
  40. if (!permanent.IsSuspended)
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  48. {
  49. if (card.Owner.MaxMemoryCost >= 6)
  50. {
  51. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-6, activateClass));
  52. List<CardSource> cardSources = new List<CardSource>() { card };
  53. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  54. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(cardSources, "Deck Bottom Card", true, true));
  55. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  56. {
  57. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  58. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  59. selectPermanentEffect.SetUp(
  60. selectPlayer: card.Owner,
  61. canTargetCondition: CanSelectPermanentCondition,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. maxCount: maxCount,
  65. canNoSelect: false,
  66. canEndNotMax: false,
  67. selectPermanentCoroutine: null,
  68. afterSelectPermanentCoroutine: null,
  69. mode: SelectPermanentEffect.Mode.Destroy,
  70. cardEffect: activateClass);
  71. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  72. }
  73. }
  74. }
  75. }
  76. #endregion
  77. #region Main
  78. if (timing == EffectTiming.OptionSkill)
  79. {
  80. ActivateClass activateClass = new ActivateClass();
  81. activateClass.SetUpICardEffect("Trash 1, Delete 1 opponent Level 4< Digimon.", CanUseCondition, card);
  82. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  83. cardEffects.Add(activateClass);
  84. string EffectDiscription()
  85. {
  86. return "[Main] Trash 1 card in your hand. Then, delete 1 of your opponent's level 4 or lower Digimon.";
  87. }
  88. bool CanSelectPermanentCondition(Permanent permanent)
  89. {
  90. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  91. {
  92. if (permanent.TopCard.HasLevel)
  93. {
  94. if (permanent.Level <= 4)
  95. {
  96. return true;
  97. }
  98. }
  99. }
  100. return false;
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  107. {
  108. if (card.Owner.HandCards.Count >= 1)
  109. {
  110. int discardCount = Math.Min(1, card.Owner.HandCards.Count);
  111. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  112. selectHandEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: (cardSource) => true,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: discardCount,
  118. canNoSelect: false,
  119. canEndNotMax: false,
  120. isShowOpponent: true,
  121. selectCardCoroutine: null,
  122. afterSelectCardCoroutine: null,
  123. mode: SelectHandEffect.Mode.Discard,
  124. cardEffect: activateClass);
  125. yield return StartCoroutine(selectHandEffect.Activate());
  126. }
  127. List<Permanent> selectedPermanents = new List<Permanent>();
  128. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  129. {
  130. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  131. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  132. selectPermanentEffect.SetUp(
  133. selectPlayer: card.Owner,
  134. canTargetCondition: CanSelectPermanentCondition,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. maxCount: maxCount,
  138. canNoSelect: false,
  139. canEndNotMax: false,
  140. selectPermanentCoroutine: SelectPermanentCoroutine,
  141. afterSelectPermanentCoroutine: null,
  142. mode: SelectPermanentEffect.Mode.Custom,
  143. cardEffect: activateClass);
  144. selectPermanentEffect.SetUpCustomMessage("Select 1 level 4 Digimon to delete.", "The opponent is selecting 1 level 4 Digimon to delete.");
  145. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  146. }
  147. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  148. {
  149. selectedPermanents.Add(permanent);
  150. yield return null;
  151. }
  152. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  153. selectedPermanents,
  154. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  155. }
  156. }
  157. #endregion
  158. #region Security Skill
  159. if (timing == EffectTiming.SecuritySkill)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("Delete 1 of your opponent's level 6 or lower Digimon.", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  164. activateClass.SetIsSecurityEffect(true);
  165. cardEffects.Add(activateClass);
  166. string EffectDiscription()
  167. {
  168. return "[Security] Delete 1 of your opponent's level 6 or lower Digimon.";
  169. }
  170. bool CanSelectPermanentCondition(Permanent permanent)
  171. {
  172. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  173. {
  174. if (permanent.Level <= 6)
  175. {
  176. if (permanent.TopCard.HasLevel)
  177. {
  178. return true;
  179. }
  180. }
  181. }
  182. return false;
  183. }
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  189. {
  190. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  191. {
  192. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  193. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  194. selectPermanentEffect.SetUp(
  195. selectPlayer: card.Owner,
  196. canTargetCondition: CanSelectPermanentCondition,
  197. canTargetCondition_ByPreSelecetedList: null,
  198. canEndSelectCondition: null,
  199. maxCount: maxCount,
  200. canNoSelect: false,
  201. canEndNotMax: false,
  202. selectPermanentCoroutine: null,
  203. afterSelectPermanentCoroutine: null,
  204. mode: SelectPermanentEffect.Mode.Destroy,
  205. cardEffect: activateClass);
  206. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  207. }
  208. }
  209. }
  210. #endregion
  211. return cardEffects;
  212. }
  213. }
  214. }