BT13_109.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_109 : 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 6 or higher Digimon. Then, 1 of your Digimon may digivolve into [Belphemon: Sleep Mode] from your trash without paying the cost.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent.Level >= 6)
  27. {
  28. if (permanent.TopCard.HasLevel)
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectPermanentCondition1(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  39. {
  40. foreach (CardSource cardSource in permanent.TopCard.Owner.TrashCards)
  41. {
  42. if (CanSelectCardCondition(cardSource))
  43. {
  44. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanSelectCardCondition(CardSource cardSource)
  54. {
  55. return cardSource.CardNames.Contains("Belphemon: Sleep Mode") || cardSource.CardNames.Contains("Belphemon:SleepMode");
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  64. {
  65. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  66. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectPermanentCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: false,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: null,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Destroy,
  78. cardEffect: activateClass);
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. }
  81. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  82. {
  83. Permanent selectedPermanent = null;
  84. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  85. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  86. selectPermanentEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: CanSelectPermanentCondition1,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: maxCount,
  92. canNoSelect: false,
  93. canEndNotMax: false,
  94. selectPermanentCoroutine: SelectPermanentCoroutine,
  95. afterSelectPermanentCoroutine: null,
  96. mode: SelectPermanentEffect.Mode.Custom,
  97. cardEffect: activateClass);
  98. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  101. {
  102. selectedPermanent = permanent;
  103. yield return null;
  104. }
  105. if (selectedPermanent != null)
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  108. targetPermanent: selectedPermanent,
  109. cardCondition: CanSelectCardCondition,
  110. payCost: false,
  111. reduceCostTuple: null,
  112. fixedCostTuple: null,
  113. ignoreDigivolutionRequirementFixedCost: -1,
  114. isHand: false,
  115. activateClass: activateClass,
  116. successProcess: null));
  117. }
  118. }
  119. }
  120. }
  121. if (timing == EffectTiming.SecuritySkill)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect($"Trash 1 card from hand to delete 1 Digimon", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  126. activateClass.SetIsSecurityEffect(true);
  127. cardEffects.Add(activateClass);
  128. string EffectDiscription()
  129. {
  130. return "[Security] By trashing 1 Digimon card in your hand, delete 1 of your opponent's Digimon whose level is less than or equal to the trashed card.";
  131. }
  132. bool CanSelectCardCondition(CardSource cardSource)
  133. {
  134. if (cardSource != null)
  135. {
  136. if (cardSource.IsDigimon)
  137. {
  138. if (cardSource.Owner == card.Owner)
  139. {
  140. return true;
  141. }
  142. }
  143. }
  144. return false;
  145. }
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  151. {
  152. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  153. {
  154. CardSource discardedCard = null;
  155. int discardCount = 1;
  156. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  157. selectHandEffect.SetUp(
  158. selectPlayer: card.Owner,
  159. canTargetCondition: CanSelectCardCondition,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. maxCount: discardCount,
  163. canNoSelect: true,
  164. canEndNotMax: false,
  165. isShowOpponent: true,
  166. selectCardCoroutine: null,
  167. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  168. mode: SelectHandEffect.Mode.Discard,
  169. cardEffect: activateClass);
  170. yield return StartCoroutine(selectHandEffect.Activate());
  171. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  172. {
  173. if (cardSources.Count >= 1)
  174. {
  175. discardedCard = cardSources[0];
  176. yield return null;
  177. }
  178. }
  179. if (discardedCard != null)
  180. {
  181. bool CanSelectPermanentCondition(Permanent permanent)
  182. {
  183. if (discardedCard.HasLevel)
  184. {
  185. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  186. {
  187. if (permanent.Level <= discardedCard.Level)
  188. {
  189. if (permanent.TopCard.HasLevel)
  190. {
  191. return true;
  192. }
  193. }
  194. }
  195. }
  196. return false;
  197. }
  198. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  199. {
  200. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  201. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  202. selectPermanentEffect.SetUp(
  203. selectPlayer: card.Owner,
  204. canTargetCondition: CanSelectPermanentCondition,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. maxCount: maxCount,
  208. canNoSelect: false,
  209. canEndNotMax: false,
  210. selectPermanentCoroutine: null,
  211. afterSelectPermanentCoroutine: null,
  212. mode: SelectPermanentEffect.Mode.Destroy,
  213. cardEffect: activateClass);
  214. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  215. }
  216. }
  217. }
  218. }
  219. }
  220. return cardEffects;
  221. }
  222. }
  223. }