EX7_061.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX7
  6. {
  7. public class EX7_061 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Lilithmon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region All Turns
  23. if (timing == EffectTiming.WhenRemoveField)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Delete 1 Digimon to prevent leaving the battle area", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  28. activateClass.SetHashString("Protection_EX7_061");
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than in battle, if [Lilithmon]/[X Antibody] in its digivolution cards, by deleting 1 other Digimon, prevent it from leaving.";
  33. }
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  37. {
  38. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Lilithmon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  39. {
  40. if (permanent.IsDigimon)
  41. {
  42. return true;
  43. }
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleArea(card))
  51. {
  52. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  53. {
  54. if (!CardEffectCommons.IsByBattle(hashtable))
  55. {
  56. return true;
  57. }
  58. }
  59. }
  60. return false;
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable hashtable)
  74. {
  75. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  76. {
  77. int maxCount = 1;
  78. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  79. selectPermanentEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectPermanentCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: maxCount,
  85. canNoSelect: true,
  86. canEndNotMax: false,
  87. selectPermanentCoroutine: SelectPermanentCoroutine,
  88. afterSelectPermanentCoroutine: null,
  89. mode: SelectPermanentEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  92. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  93. IEnumerator SelectPermanentCoroutine(Permanent _permanent)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { _permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  96. IEnumerator SuccessProcess()
  97. {
  98. card.PermanentOfThisCard().willBeRemoveField = false;
  99. card.PermanentOfThisCard().HideDeleteEffect();
  100. yield return null;
  101. }
  102. }
  103. }
  104. }
  105. }
  106. #endregion
  107. #region All Turns Your Turn
  108. if (timing == EffectTiming.OnDestroyedAnyone)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("Play 1 Digimon or Trash the top card of your opponent's security", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  113. activateClass.SetHashString("PlayDigimon_EX7_061");
  114. cardEffects.Add(activateClass);
  115. string EffectDiscription()
  116. {
  117. return "[All Turns] [Once Per Turn] When another Digimon is deleted, if it's your turn, you may play 1 purple level 4 or lower Digimon card from your trash without paying the cost. If it's your opponent's turn, trash the top card of their security stack.";
  118. }
  119. bool PermanentCondition(Permanent permanent)
  120. {
  121. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  122. {
  123. if (permanent.IsDigimon)
  124. {
  125. if (permanent != card.PermanentOfThisCard())
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. if (CardEffectCommons.IsOwnerTurn(card))
  136. {
  137. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  138. {
  139. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  140. {
  141. return true;
  142. }
  143. }
  144. }
  145. return false;
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  150. {
  151. if (card.Owner.TrashCards.Count >= 1)
  152. {
  153. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  154. {
  155. return true;
  156. }
  157. }
  158. }
  159. return false;
  160. }
  161. bool CanSelectCardInTrash(CardSource cardSource)
  162. {
  163. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  164. {
  165. if (cardSource.HasCardColor(CardColor.Purple))
  166. {
  167. if (cardSource.IsDigimon)
  168. {
  169. if (cardSource.Level <= 4)
  170. {
  171. if (cardSource.HasLevel)
  172. {
  173. return true;
  174. }
  175. }
  176. }
  177. }
  178. }
  179. return false;
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable hashtable)
  182. {
  183. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  184. {
  185. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  186. List<CardSource> selectedCards = new List<CardSource>();
  187. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  188. selectCardEffect.SetUp(
  189. canTargetCondition: CanSelectCardInTrash,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. canNoSelect: () => true,
  193. selectCardCoroutine: SelectCardCoroutine,
  194. afterSelectCardCoroutine: null,
  195. message: "Select 1 card to play.",
  196. maxCount: maxCount,
  197. canEndNotMax: false,
  198. isShowOpponent: true,
  199. mode: SelectCardEffect.Mode.Custom,
  200. root: SelectCardEffect.Root.Trash,
  201. customRootCardList: null,
  202. canLookReverseCard: true,
  203. selectPlayer: card.Owner,
  204. cardEffect: activateClass);
  205. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  206. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  207. yield return StartCoroutine(selectCardEffect.Activate());
  208. IEnumerator SelectCardCoroutine(CardSource cardSource)
  209. {
  210. selectedCards.Add(cardSource);
  211. yield return null;
  212. }
  213. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  214. cardSources: selectedCards,
  215. activateClass: activateClass,
  216. payCost: false,
  217. isTapped: false,
  218. root: SelectCardEffect.Root.Trash,
  219. activateETB: true));
  220. }
  221. }
  222. }
  223. #endregion
  224. #region All Turns Opponent's Turn
  225. if (timing == EffectTiming.OnDestroyedAnyone)
  226. {
  227. ActivateClass activateClass = new ActivateClass();
  228. activateClass.SetUpICardEffect("Play 1 Digimon or Trash the top card of your opponent's security", CanUseCondition, card);
  229. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  230. activateClass.SetHashString("TrashSecurity_EX7_061");
  231. cardEffects.Add(activateClass);
  232. string EffectDiscription()
  233. {
  234. return "[All Turns] [Once Per Turn] When another Digimon is deleted, if it's your turn, you may play 1 purple level 4 or lower Digimon card from your trash without paying the cost. If it's your opponent's turn, trash the top card of their security stack.";
  235. }
  236. bool PermanentCondition(Permanent permanent)
  237. {
  238. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  239. {
  240. if (permanent.IsDigimon)
  241. {
  242. if (permanent != card.PermanentOfThisCard())
  243. {
  244. return true;
  245. }
  246. }
  247. }
  248. return false;
  249. }
  250. bool CanUseCondition(Hashtable hashtable)
  251. {
  252. if (CardEffectCommons.IsOpponentTurn(card))
  253. {
  254. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  255. {
  256. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  257. {
  258. return true;
  259. }
  260. }
  261. }
  262. return false;
  263. }
  264. bool CanActivateCondition(Hashtable hashtable)
  265. {
  266. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  267. {
  268. return true;
  269. }
  270. return false;
  271. }
  272. IEnumerator ActivateCoroutine(Hashtable hashtable)
  273. {
  274. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  275. player: card.Owner.Enemy,
  276. destroySecurityCount: 1,
  277. cardEffect: activateClass,
  278. fromTop: true).DestroySecurity());
  279. }
  280. }
  281. #endregion
  282. return cardEffects;
  283. }
  284. }
  285. }