BT23_068.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Grandracmon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_068 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel5
  18. && (targetPermanent.TopCard.HasCSTraits || targetPermanent.TopCard.HasUndeadTraits);
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 4,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region SoM/OD Shared
  30. const string SharedEffectDescription = "1 of your Digimon may digivolve into a level 6 or lower [Undead] or [Dark Animal] trait Digimon card in the trash without paying the cost.";
  31. bool SharedCanSelectDigiCardCondition(CardSource cardSource)
  32. {
  33. return cardSource.IsDigimon &&
  34. cardSource.HasLevel && cardSource.Level <= 6 &&
  35. (cardSource.HasUndeadTraits || cardSource.HasDarkAnimalTraits);
  36. }
  37. bool SharedCanSelectPermanentCondition(Permanent permanent, ActivateClass activateClass)
  38. {
  39. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  40. {
  41. // Loop thru the trash cards looking for a valid digi target
  42. foreach (CardSource cardSource in card.Owner.TrashCards)
  43. {
  44. // does it have undead or dark animal trait?
  45. if (SharedCanSelectDigiCardCondition(cardSource))
  46. {
  47. // can this digimon digivolve into it?
  48. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  58. {
  59. Permanent selectedPermanent = null;
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: (permanent) => SharedCanSelectPermanentCondition(permanent, activateClass),
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: 1,
  67. canNoSelect: true,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  76. {
  77. selectedPermanent = permanent;
  78. yield return null;
  79. }
  80. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCanSelectDigiCardCondition);
  81. if (canSelectTrash)
  82. {
  83. yield return ContinuousController.instance.StartCoroutine(
  84. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  85. targetPermanent: selectedPermanent,
  86. cardCondition: SharedCanSelectDigiCardCondition,
  87. payCost: false,
  88. reduceCostTuple: null,
  89. fixedCostTuple: null,
  90. ignoreDigivolutionRequirementFixedCost: -1,
  91. isHand: false,
  92. activateClass: activateClass,
  93. successProcess: null));
  94. }
  95. }
  96. #endregion
  97. #region Start of Main Phase
  98. if (timing == EffectTiming.OnStartMainPhase)
  99. {
  100. ActivateClass activateClass = new ActivateClass();
  101. activateClass.SetUpICardEffect("Digivolve into level 6 or lower", CanUseCondition, card);
  102. activateClass.SetUpActivateClass(CanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  103. cardEffects.Add(activateClass);
  104. string EffectDiscription()
  105. {
  106. return "[Start of your Main Phase] " + SharedEffectDescription;
  107. }
  108. bool CanUseCondition(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.IsExistOnBattleArea(card))
  111. {
  112. if (CardEffectCommons.IsOwnerTurn(card))
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. bool CanActivateCondition(Hashtable hashtable)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  122. {
  123. if (CardEffectCommons.HasMatchConditionPermanent((permanent) => SharedCanSelectPermanentCondition(permanent, activateClass)))
  124. {
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. }
  131. #endregion
  132. #region On Deletion
  133. if (timing == EffectTiming.OnDestroyedAnyone)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Digivolve into level 6 or lower", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  138. cardEffects.Add(activateClass);
  139. string EffectDiscription()
  140. {
  141. return "[On Deletion] " + SharedEffectDescription;
  142. }
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  150. {
  151. if (CardEffectCommons.HasMatchConditionPermanent((permanent) => SharedCanSelectPermanentCondition(permanent, activateClass)))
  152. {
  153. return true;
  154. }
  155. }
  156. return false;
  157. }
  158. }
  159. #endregion
  160. #region When Digivolving
  161. if (timing == EffectTiming.OnEnterFieldAnyone)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect("Play 1 level 4 or lower Digimon from trash", CanUseCondition, card);
  165. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  166. cardEffects.Add(activateClass);
  167. string EffectDiscription()
  168. {
  169. return "[When Digivolving] You may play 1 level 4 or lower purple Digimon card from your trash without paying the cost.";
  170. }
  171. bool CanSelectCardCondition(CardSource cardSource)
  172. {
  173. if (cardSource.IsDigimon)
  174. {
  175. if (cardSource.HasCardColor(CardColor.Purple))
  176. {
  177. if (cardSource.HasLevel && cardSource.Level <= 4)
  178. {
  179. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  180. {
  181. return true;
  182. }
  183. }
  184. }
  185. }
  186. return false;
  187. }
  188. bool CanUseCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  191. }
  192. bool CanActivateCondition(Hashtable hashtable)
  193. {
  194. if (CardEffectCommons.IsExistOnBattleArea(card))
  195. {
  196. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  197. {
  198. return true;
  199. }
  200. }
  201. return false;
  202. }
  203. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  204. {
  205. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  206. {
  207. List<CardSource> selectedCards = new List<CardSource>();
  208. int maxCount = 1;
  209. if (card.Owner.TrashCards.Count(CanSelectCardCondition) <= maxCount)
  210. {
  211. maxCount = card.Owner.TrashCards.Count(CanSelectCardCondition);
  212. }
  213. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  214. selectCardEffect.SetUp(
  215. canTargetCondition: CanSelectCardCondition,
  216. canTargetCondition_ByPreSelecetedList: null,
  217. canEndSelectCondition: null,
  218. canNoSelect: () => true,
  219. selectCardCoroutine: SelectCardCoroutine,
  220. afterSelectCardCoroutine: null,
  221. message: "Select 1 card to play.",
  222. maxCount: maxCount,
  223. canEndNotMax: false,
  224. isShowOpponent: true,
  225. mode: SelectCardEffect.Mode.Custom,
  226. root: SelectCardEffect.Root.Trash,
  227. customRootCardList: null,
  228. canLookReverseCard: true,
  229. selectPlayer: card.Owner,
  230. cardEffect: activateClass);
  231. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  232. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  233. yield return StartCoroutine(selectCardEffect.Activate());
  234. IEnumerator SelectCardCoroutine(CardSource cardSource)
  235. {
  236. selectedCards.Add(cardSource);
  237. yield return null;
  238. }
  239. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  240. cardSources: selectedCards,
  241. activateClass: activateClass,
  242. payCost: false,
  243. isTapped: false,
  244. root: SelectCardEffect.Root.Trash,
  245. activateETB: true));
  246. }
  247. }
  248. }
  249. #endregion
  250. #region All Turns
  251. if (timing == EffectTiming.OnEnterFieldAnyone)
  252. {
  253. ActivateClass activateClass = new ActivateClass();
  254. activateClass.SetUpICardEffect("Delete opponent's lowest level Digimon", CanUseCondition, card);
  255. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  256. activateClass.SetHashString("AT_BT23-068");
  257. cardEffects.Add(activateClass);
  258. string EffectDescription()
  259. {
  260. return "[All Turns][Once Per Turn] When any of your Digimon digivolve from the trash, delete all of your opponent's lowest level Digimon.";
  261. }
  262. bool CanUseCondition(Hashtable hashtable)
  263. {
  264. if (CardEffectCommons.IsExistOnBattleArea(card))
  265. {
  266. if (CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, DigivolveToPermanentCondition, TrashRootCondition))
  267. {
  268. return true;
  269. }
  270. }
  271. return false;
  272. }
  273. bool CanActivateCondition(Hashtable hashtable)
  274. {
  275. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  276. }
  277. bool TrashRootCondition(SelectCardEffect.Root root)
  278. {
  279. return root == SelectCardEffect.Root.Trash;
  280. }
  281. bool DigivolveToPermanentCondition(Permanent permanent)
  282. {
  283. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  284. }
  285. bool OpponentMinLevelPermanentCondition(Permanent permanent)
  286. {
  287. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  288. CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  289. }
  290. IEnumerator ActivateCoroutine(Hashtable hashtable)
  291. {
  292. List<Permanent> destroyTargetPermanents =
  293. card.Owner.Enemy.GetBattleAreaDigimons().Filter(OpponentMinLevelPermanentCondition);
  294. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  295. destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  296. }
  297. }
  298. #endregion
  299. return cardEffects;
  300. }
  301. }
  302. }