EX6_058.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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_058 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Blocker
  16. if (timing == EffectTiming.None)
  17. {
  18. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(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("Delete 1 opponent Digimon with the lowest DP", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] Delete 1 of your opponent's Digimon with the lowest DP. For each level of the Digimon deleted by this effect, trash the top card of your deck.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnPlay(hashtable,card);
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  39. }
  40. bool CanActivateCondition(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.IsExistOnBattleArea(card))
  43. {
  44. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  45. {
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  54. List<Permanent> deleteTargetPermanentsClone = new List<Permanent>();
  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: SelectPermanentCoroutine,
  68. afterSelectPermanentCoroutine: null,
  69. mode: SelectPermanentEffect.Mode.Custom,
  70. cardEffect: activateClass);
  71. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  72. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  73. IEnumerator SelectPermanentCoroutine(Permanent _permanent)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { _permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  76. IEnumerator SuccessProcess()
  77. {
  78. if (card.Owner.LibraryCards.Count >= 1)
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(_permanent.LevelJustBeforeRemoveField, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. #endregion
  88. #region When Digivolving
  89. if (timing == EffectTiming.OnEnterFieldAnyone)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect("Delete 1 opponent Digimon with the lowest DP", CanUseCondition, card);
  93. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. {
  97. return "[When Digivolving] Delete 1 of your opponent's Digimon with the lowest DP. For each level of the Digimon deleted by this effect, trash the top card of your deck.";
  98. }
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  102. }
  103. bool CanSelectPermanentCondition(Permanent permanent)
  104. {
  105. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  106. }
  107. bool CanActivateCondition(Hashtable hashtable)
  108. {
  109. if (CardEffectCommons.IsExistOnBattleArea(card))
  110. {
  111. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. IEnumerator ActivateCoroutine(Hashtable hashtable)
  119. {
  120. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  121. List<Permanent> deleteTargetPermanentsClone = new List<Permanent>();
  122. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  123. {
  124. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  125. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  126. selectPermanentEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectPermanentCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: maxCount,
  132. canNoSelect: false,
  133. canEndNotMax: false,
  134. selectPermanentCoroutine: SelectPermanentCoroutine,
  135. afterSelectPermanentCoroutine: null,
  136. mode: SelectPermanentEffect.Mode.Custom,
  137. cardEffect: activateClass);
  138. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  139. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  140. IEnumerator SelectPermanentCoroutine(Permanent _permanent)
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { _permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  143. IEnumerator SuccessProcess()
  144. {
  145. if (card.Owner.LibraryCards.Count >= 1)
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(_permanent.LevelJustBeforeRemoveField, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  148. }
  149. }
  150. }
  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. }