EX6_061.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.EX6
  7. {
  8. public class EX6_061 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region All Turns - When Played - Once per turn
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("By trashing 1 card in hand, return sources, then delete 1 digimon", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  19. activateClass.SetHashString("AllTurns_EX6_061");
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[All Turns] [Once Per Turn] When an opponent's Digimon or one of your Digimon with the [Seven Great Demon Lords] trait is played, by trashing 1 card in your hand, return the bottom 3 digivolution cards of 1 of your opponent's Digimon to the bottom of the deck. Then, if your opponent has as many or less total Digimon and Tamers as you, delete 1 of your opponent's Digimon with no digivolution cards.";
  24. }
  25. bool PlayedDigimonConditions(Permanent permanent)
  26. {
  27. if (permanent.IsDigimon)
  28. {
  29. if (CardEffectCommons.IsOwnerPermanent(permanent, card))
  30. {
  31. if (permanent.TopCard.ContainsTraits("Seven Great Demon Lords"))
  32. return true;
  33. }
  34. else
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  37. }
  38. }
  39. return false;
  40. }
  41. bool SelectOpponentsDigimonCondition(Permanent permanent)
  42. {
  43. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  44. }
  45. bool SelectOpponentsDigimonWithoutSourcesCondition(Permanent permanent)
  46. {
  47. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) => permanent.IsDigimon && permanent.HasNoDigivolutionCards))
  48. {
  49. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. bool PermanentCondition(Permanent permanent)
  57. {
  58. return (permanent.IsDigimon || permanent.IsTamer);
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  63. return true;
  64. if(CardEffectCommons.CanTriggerOnPermanentPlay(hashtable,PlayedDigimonConditions))
  65. return true;
  66. return false;
  67. }
  68. bool CanActivateCondition(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  71. {
  72. if(card.Owner.HandCards.Count > 0)
  73. return true;
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable hashtable)
  78. {
  79. List<CardSource> discarded = new List<CardSource>();
  80. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  81. selectHandEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: (cardSource) => true,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: 1,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. isShowOpponent: true,
  90. selectCardCoroutine: null,
  91. afterSelectCardCoroutine: AfterSelectionCoroutine,
  92. mode: SelectHandEffect.Mode.Discard,
  93. cardEffect: activateClass);
  94. yield return StartCoroutine(selectHandEffect.Activate());
  95. IEnumerator AfterSelectionCoroutine(List<CardSource> cardSources)
  96. {
  97. discarded = cardSources.Clone();
  98. yield return null;
  99. }
  100. if (discarded.Count >=1)
  101. {
  102. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. int suspendCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SelectOpponentsDigimonCondition));
  104. selectPermanentEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: SelectOpponentsDigimonCondition,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: suspendCount,
  110. canNoSelect: false,
  111. canEndNotMax: false,
  112. selectPermanentCoroutine: SelectPermanentCoroutine,
  113. afterSelectPermanentCoroutine: null,
  114. mode: SelectPermanentEffect.Mode.Custom,
  115. cardEffect: activateClass);
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. }
  118. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  119. {
  120. List<CardSource> targetCards = new List<CardSource>();
  121. for (int i = 0; i < 3; i++)
  122. {
  123. if (permanent.DigivolutionCards.Count >= i + 1)
  124. {
  125. int index = false ? i : permanent.DigivolutionCards.Count - 1 - i;
  126. CardSource trashTargetCard = permanent.DigivolutionCards[index];
  127. targetCards.Add(trashTargetCard);
  128. }
  129. }
  130. yield return ContinuousController.instance.StartCoroutine(new ReturnToLibraryBottomDigivolutionCardsClass(
  131. permanent,
  132. targetCards, CardEffectCommons.CardEffectHashtable(activateClass)).ReturnToLibraryBottomDigivolutionCards());
  133. }
  134. if (card.Owner.GetBattleAreaPermanents().Count(PermanentCondition) >= card.Owner.Enemy.GetBattleAreaPermanents().Count(PermanentCondition))
  135. {
  136. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  137. int suspendCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SelectOpponentsDigimonWithoutSourcesCondition));
  138. selectPermanentEffect.SetUp(
  139. selectPlayer: card.Owner,
  140. canTargetCondition: SelectOpponentsDigimonWithoutSourcesCondition,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: null,
  143. maxCount: suspendCount,
  144. canNoSelect: false,
  145. canEndNotMax: false,
  146. selectPermanentCoroutine: null,
  147. afterSelectPermanentCoroutine: null,
  148. mode: SelectPermanentEffect.Mode.Destroy,
  149. cardEffect: activateClass);
  150. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  151. }
  152. }
  153. }
  154. #endregion
  155. #region All Turns
  156. if (timing == EffectTiming.WhenRemoveField)
  157. {
  158. ActivateClass activateClass = new ActivateClass();
  159. activateClass.SetUpICardEffect("Place 1 7GDL from trash to bottom of [Gate of Deadly Sins]", CanUseCondition, card);
  160. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  161. cardEffects.Add(activateClass);
  162. string EffectDiscription()
  163. {
  164. return "[All Turns] When this Digimon would leave the battle area other than in battle, place 1 card with the [Seven Great Demon Lord] trait from your trash as the bottom digivolution cards of one of your [Gate of Deadly Sins] in your breeding area.";
  165. }
  166. bool CanUseCondition(Hashtable hashtable)
  167. {
  168. if (CardEffectCommons.IsExistOnBattleArea(card))
  169. {
  170. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  171. {
  172. if (!CardEffectCommons.IsByBattle(hashtable))
  173. {
  174. return true;
  175. }
  176. }
  177. }
  178. return false;
  179. }
  180. bool CanSelect7GDLinTrash(CardSource cardSource)
  181. {
  182. if (cardSource.CardTraits.Contains("SevenGreatDemonLords") || cardSource.CardTraits.Contains("Seven Great Demon Lords"))
  183. {
  184. return true;
  185. }
  186. return false;
  187. }
  188. bool CanSelectPermanentCondition(Permanent permanent)
  189. {
  190. if (CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  191. {
  192. if (permanent.TopCard.CardNames.Contains("Gate of Deadly Sins"))
  193. {
  194. return true;
  195. }
  196. }
  197. return false;
  198. }
  199. bool CanActivateCondition(Hashtable hashtable)
  200. {
  201. if (CardEffectCommons.IsExistOnBattleArea(card))
  202. {
  203. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelect7GDLinTrash))
  204. {
  205. return true;
  206. }
  207. }
  208. return false;
  209. }
  210. IEnumerator ActivateCoroutine(Hashtable hashtable)
  211. {
  212. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelect7GDLinTrash))
  213. {
  214. List<CardSource> selectedCards = new List<CardSource>();
  215. int maxCount = 1;
  216. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  217. selectCardEffect.SetUp(
  218. canTargetCondition: CanSelect7GDLinTrash,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. canNoSelect: () => false,
  222. selectCardCoroutine: SelectCardCoroutine,
  223. afterSelectCardCoroutine: null,
  224. message: "Select 1 card to place at the bottom of digivolution cards.",
  225. maxCount: maxCount,
  226. canEndNotMax: false,
  227. isShowOpponent: true,
  228. mode: SelectCardEffect.Mode.Custom,
  229. root: SelectCardEffect.Root.Trash,
  230. customRootCardList: null,
  231. canLookReverseCard: true,
  232. selectPlayer: card.Owner,
  233. cardEffect: activateClass);
  234. selectCardEffect.SetUpCustomMessage("Select 1 card to place at the bottom of digivolution cards.", "The opponent is selecting 1 card to place at the bottom of digivolution cards.");
  235. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  236. IEnumerator SelectCardCoroutine(CardSource cardSource)
  237. {
  238. selectedCards.Add(cardSource);
  239. yield return null;
  240. }
  241. if (selectedCards.Count >= 1)
  242. {
  243. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition, true))
  244. {
  245. Permanent selectedPermanent = card.Owner.GetBreedingAreaPermanents()[0];
  246. if (selectedPermanent != null)
  247. {
  248. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  249. }
  250. }
  251. }
  252. }
  253. }
  254. }
  255. #endregion
  256. return cardEffects;
  257. }
  258. }
  259. }