EX6_056.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.EX6
  9. {
  10. public class EX6_056 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Rush
  16. if(timing == EffectTiming.None)
  17. {
  18. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region On Play
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Trash 4 from the top of your deck & De-Digivolve 2", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] Trash the top 4 cards of your deck. Then, if you have 10 or more cards in your trash, <De-Digivolve 2> 1 of your opponent's Digimon.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if(CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. return true;
  41. }
  42. return false;
  43. }
  44. bool PermanentCondition(Permanent permanent)
  45. {
  46. if(CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent,card))
  47. {
  48. return true;
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable hashtable)
  53. {
  54. if(card.Owner.LibraryCards.Count >= 1)
  55. {
  56. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(4, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  57. }
  58. if(card.Owner.TrashCards.Count >= 10)
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  61. {
  62. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: PermanentCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: CanEndSelectCondition,
  69. maxCount: maxCount,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectPermanentCoroutine,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. bool CanEndSelectCondition(List<Permanent> permanents)
  79. {
  80. if (permanents.Count <= 0)
  81. {
  82. return false;
  83. }
  84. return true;
  85. }
  86. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  87. {
  88. Permanent selectedPermanent = permanent;
  89. if (selectedPermanent != null)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 2, activateClass).Degeneration());
  92. }
  93. yield return null;
  94. }
  95. }
  96. }
  97. yield return null;
  98. }
  99. }
  100. #endregion
  101. #region When Digivolving
  102. if (timing == EffectTiming.OnEnterFieldAnyone)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Trash 4 from the top of your deck & De-Digivolve 2", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  107. cardEffects.Add(activateClass);
  108. string EffectDiscription()
  109. {
  110. return "[When Digivolving] Trash the top 4 cards of your deck. Then, if you have 10 or more cards in your trash, <De-Digivolve 2> 1 of your opponent's Digimon.";
  111. }
  112. bool CanUseCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  115. }
  116. bool CanActivateCondition(Hashtable hashtable)
  117. {
  118. if (CardEffectCommons.IsExistOnBattleArea(card))
  119. {
  120. return true;
  121. }
  122. return false;
  123. }
  124. bool PermanentCondition(Permanent permanent)
  125. {
  126. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  127. {
  128. return true;
  129. }
  130. return false;
  131. }
  132. IEnumerator ActivateCoroutine(Hashtable hashtable)
  133. {
  134. if (card.Owner.LibraryCards.Count >= 1)
  135. {
  136. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(4, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  137. }
  138. if (card.Owner.TrashCards.Count >= 10)
  139. {
  140. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  141. {
  142. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  143. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. selectPermanentEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: PermanentCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: CanEndSelectCondition,
  149. maxCount: maxCount,
  150. canNoSelect: false,
  151. canEndNotMax: false,
  152. selectPermanentCoroutine: SelectPermanentCoroutine,
  153. afterSelectPermanentCoroutine: null,
  154. mode: SelectPermanentEffect.Mode.Custom,
  155. cardEffect: activateClass);
  156. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. bool CanEndSelectCondition(List<Permanent> permanents)
  159. {
  160. if (permanents.Count <= 0)
  161. {
  162. return false;
  163. }
  164. return true;
  165. }
  166. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  167. {
  168. Permanent selectedPermanent = permanent;
  169. if (selectedPermanent != null)
  170. {
  171. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 2, activateClass).Degeneration());
  172. }
  173. yield return null;
  174. }
  175. }
  176. }
  177. yield return null;
  178. }
  179. }
  180. #endregion
  181. #region All Turns
  182. if (timing == EffectTiming.WhenRemoveField)
  183. {
  184. ActivateClass activateClass = new ActivateClass();
  185. activateClass.SetUpICardEffect("Place 1 7GDL from trash to bottom of [Gate of Deadly Sins]", CanUseCondition, card);
  186. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  187. cardEffects.Add(activateClass);
  188. string EffectDiscription()
  189. {
  190. 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.";
  191. }
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. if (CardEffectCommons.IsExistOnBattleArea(card))
  195. {
  196. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  197. {
  198. if (!CardEffectCommons.IsByBattle(hashtable))
  199. {
  200. return true;
  201. }
  202. }
  203. }
  204. return false;
  205. }
  206. bool CanSelect7GDLinTrash(CardSource cardSource)
  207. {
  208. if (cardSource.CardTraits.Contains("SevenGreatDemonLords") || cardSource.CardTraits.Contains("Seven Great Demon Lords"))
  209. {
  210. return true;
  211. }
  212. return false;
  213. }
  214. bool CanSelectPermanentCondition(Permanent permanent)
  215. {
  216. if (CardEffectCommons.IsPermanentExistsOnOwnerBreedingArea(permanent, card))
  217. {
  218. if (permanent.TopCard.CardNames.Contains("Gate of Deadly Sins"))
  219. {
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. bool CanActivateCondition(Hashtable hashtable)
  226. {
  227. if (CardEffectCommons.IsExistOnBattleArea(card))
  228. {
  229. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelect7GDLinTrash))
  230. {
  231. return true;
  232. }
  233. }
  234. return false;
  235. }
  236. IEnumerator ActivateCoroutine(Hashtable hashtable)
  237. {
  238. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelect7GDLinTrash))
  239. {
  240. List<CardSource> selectedCards = new List<CardSource>();
  241. int maxCount = 1;
  242. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  243. selectCardEffect.SetUp(
  244. canTargetCondition: CanSelect7GDLinTrash,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. canNoSelect: () => false,
  248. selectCardCoroutine: SelectCardCoroutine,
  249. afterSelectCardCoroutine: null,
  250. message: "Select 1 card to place at the bottom of digivolution cards.",
  251. maxCount: maxCount,
  252. canEndNotMax: false,
  253. isShowOpponent: true,
  254. mode: SelectCardEffect.Mode.Custom,
  255. root: SelectCardEffect.Root.Trash,
  256. customRootCardList: null,
  257. canLookReverseCard: true,
  258. selectPlayer: card.Owner,
  259. cardEffect: activateClass);
  260. 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.");
  261. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  262. IEnumerator SelectCardCoroutine(CardSource cardSource)
  263. {
  264. selectedCards.Add(cardSource);
  265. yield return null;
  266. }
  267. if (selectedCards.Count >= 1)
  268. {
  269. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition, true))
  270. {
  271. Permanent selectedPermanent = card.Owner.GetBreedingAreaPermanents()[0];
  272. if (selectedPermanent != null)
  273. {
  274. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  275. }
  276. }
  277. }
  278. }
  279. }
  280. }
  281. #endregion
  282. return cardEffects;
  283. }
  284. }
  285. }