ImperialdramonPaladinMode_BT17_077.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class ImperialdramonPaladinMode_BT17_077 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if(targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 6)
  18. return targetPermanent.TopCard.ContainsCardName("Imperialdramon");
  19. return false;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 5,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. #endregion
  29. #region Blast Digivolve
  30. if (timing == EffectTiming.OnCounterTiming)
  31. {
  32. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  33. }
  34. #endregion
  35. #region When Attacking
  36. if (timing == EffectTiming.OnAllyAttack)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Return 1 to bottom of deck, unsusped this digimon", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[When Attacking] By returning 1 of your opponent's Digimon with no digivolution cards to the bottom of the deck, unsuspend this Digimon.";
  45. }
  46. bool IsOpponentsDigimon(Permanent permanent)
  47. {
  48. if(CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  49. return permanent.DigivolutionCards.Count == 0;
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  55. return CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon);
  56. return false;
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon))
  65. {
  66. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsOpponentsDigimon));
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: IsOpponentsDigimon,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount,
  74. canNoSelect: true,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectedBottomDeck,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to bottom deck.", "The opponent is selecting 1 Digimon to bottom deck.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator SelectedBottomDeck(Permanent bottomDeckedPermanent)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeckBouncePeremanentAndProcessAccordingToResult(
  85. targetPermanents: new List<Permanent>() { bottomDeckedPermanent },
  86. activateClass: activateClass,
  87. successProcess: SuccessProcess(),
  88. failureProcess: null));
  89. IEnumerator SuccessProcess()
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  92. new List<Permanent> { card.PermanentOfThisCard() },
  93. activateClass).Unsuspend());
  94. }
  95. }
  96. }
  97. }
  98. }
  99. #endregion
  100. #region On Play/When Digivolving Shared
  101. bool HasWhiteLevelSeven(CardSource source)
  102. {
  103. if (source.CardColors.Contains(CardColor.White))
  104. return source.HasLevel && source.Level == 7;
  105. return false;
  106. }
  107. #endregion
  108. #region On Play
  109. if (timing == EffectTiming.OnEnterFieldAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Trash digivolution sources, Return all cards in trash, Memory +3", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  114. cardEffects.Add(activateClass);
  115. string EffectDiscription()
  116. {
  117. return "[On Play] Trash all digivolution cards of all of your opponent's Digimon. Then, return all cards from your or your opponent's trash to the bottom of the deck. If this effect returned a white level 7 card, gain 3 memory.";
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  126. }
  127. IEnumerator ActivateCoroutine(Hashtable hashtable)
  128. {
  129. foreach (Permanent selectedPermanent in card.Owner.Enemy.GetBattleAreaDigimons())
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  132. targetPermanent: selectedPermanent,
  133. trashCount: selectedPermanent.DigivolutionCards.Count,
  134. isFromTop: true,
  135. activateClass: activateClass));
  136. }
  137. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  138. {
  139. new SelectionElement<bool>(message: $"Your Trash", value : true, spriteIndex: 0),
  140. new SelectionElement<bool>(message: $"Opponents Trash", value : false, spriteIndex: 1),
  141. };
  142. string selectPlayerMessage = "Will you return cards from your or your opponent's trash?";
  143. string notSelectPlayerMessage = "The opponent is choosing to return cards from your or their trash.";
  144. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  145. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  146. bool willReturnYourTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  147. List<CardSource> returnedSources = willReturnYourTrash ? card.Owner.TrashCards.Clone() : card.Owner.Enemy.TrashCards.Clone();
  148. if (returnedSources.Count >= 1)
  149. {
  150. if (returnedSources.Count == 1)
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(returnedSources));
  153. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(returnedSources, "Deck Bottom Cards", true, true));
  154. }
  155. else
  156. {
  157. int maxCount = returnedSources.Count;
  158. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  159. selectCardEffect.SetUp(
  160. canTargetCondition: (cardSource) => true,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. canNoSelect: () => false,
  164. selectCardCoroutine: null,
  165. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  166. message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  167. maxCount: maxCount,
  168. canEndNotMax: false,
  169. isShowOpponent: false,
  170. mode: SelectCardEffect.Mode.Custom,
  171. root: SelectCardEffect.Root.Custom,
  172. customRootCardList: returnedSources,
  173. canLookReverseCard: true,
  174. selectPlayer: card.Owner,
  175. cardEffect: activateClass);
  176. selectCardEffect.SetNotShowCard();
  177. selectCardEffect.SetNotAddLog();
  178. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  179. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  180. {
  181. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  182. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(cardSources, "Deck Bottom Cards", true, true));
  183. }
  184. }
  185. }
  186. if (returnedSources.Count(HasWhiteLevelSeven) > 0)
  187. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(3, activateClass));
  188. }
  189. }
  190. #endregion
  191. #region When Digivolving
  192. if (timing == EffectTiming.OnEnterFieldAnyone)
  193. {
  194. ActivateClass activateClass = new ActivateClass();
  195. activateClass.SetUpICardEffect("Trash digivolution sources, Return all cards in trash, Memory +3", CanUseCondition, card);
  196. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  197. cardEffects.Add(activateClass);
  198. string EffectDiscription()
  199. {
  200. return "[When Digivolving] Trash all digivolution cards of all of your opponent's Digimon. Then, return all cards from your or your opponent's trash to the bottom of the deck. If this effect returned a white level 7 card, gain 3 memory.";
  201. }
  202. bool CanUseCondition(Hashtable hashtable)
  203. {
  204. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  209. }
  210. IEnumerator ActivateCoroutine(Hashtable hashtable)
  211. {
  212. foreach (Permanent selectedPermanent in card.Owner.Enemy.GetBattleAreaDigimons())
  213. {
  214. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  215. targetPermanent: selectedPermanent,
  216. trashCount: selectedPermanent.DigivolutionCards.Count,
  217. isFromTop: true,
  218. activateClass: activateClass));
  219. }
  220. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  221. {
  222. new SelectionElement<bool>(message: $"Your Trash", value : true, spriteIndex: 0),
  223. new SelectionElement<bool>(message: $"Opponents Trash", value : false, spriteIndex: 1),
  224. };
  225. string selectPlayerMessage = "Will you return cards from your or your opponent's trash?";
  226. string notSelectPlayerMessage = "The opponent is choosing to return cards from your or their trash.";
  227. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  228. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  229. bool willReturnYourTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  230. List<CardSource> returnedSources = willReturnYourTrash ? card.Owner.TrashCards.Clone() : card.Owner.Enemy.TrashCards.Clone();
  231. if (returnedSources.Count >= 1)
  232. {
  233. if (returnedSources.Count == 1)
  234. {
  235. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(returnedSources));
  236. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(returnedSources, "Deck Bottom Cards", true, true));
  237. }
  238. else
  239. {
  240. int maxCount = returnedSources.Count;
  241. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  242. selectCardEffect.SetUp(
  243. canTargetCondition: (cardSource) => true,
  244. canTargetCondition_ByPreSelecetedList: null,
  245. canEndSelectCondition: null,
  246. canNoSelect: () => false,
  247. selectCardCoroutine: null,
  248. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  249. message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  250. maxCount: maxCount,
  251. canEndNotMax: false,
  252. isShowOpponent: false,
  253. mode: SelectCardEffect.Mode.Custom,
  254. root: SelectCardEffect.Root.Custom,
  255. customRootCardList: returnedSources,
  256. canLookReverseCard: true,
  257. selectPlayer: card.Owner,
  258. cardEffect: activateClass);
  259. selectCardEffect.SetNotShowCard();
  260. selectCardEffect.SetNotAddLog();
  261. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  262. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  263. {
  264. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  265. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(cardSources, "Deck Bottom Cards", true, true));
  266. }
  267. }
  268. }
  269. if (returnedSources.Count(HasWhiteLevelSeven) > 0)
  270. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(3, activateClass));
  271. }
  272. }
  273. #endregion
  274. return cardEffects;
  275. }
  276. }
  277. }