EX10_036.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Magneticdramon
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_036 : 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 Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool Condition()
  16. {
  17. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, permanent =>
  18. permanent.TopCard.EqualsCardName("Close")
  19. );
  20. }
  21. static bool PermanentCondition(Permanent targetPermanent)
  22. {
  23. return targetPermanent.TopCard.EqualsCardName("Proganomon");
  24. }
  25. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 6, ignoreDigivolutionRequirement: false, card: card, condition: Condition));
  26. }
  27. #endregion
  28. #region Fragment
  29. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  30. {
  31. string EffectDiscription()
  32. {
  33. return "<Fragment <3>> (When this Digimon would be deleted, by trashing any 3 of its digivolution cards, it isn’t deleted.)";
  34. }
  35. cardEffects.Add(CardEffectFactory.FragmentSelfEffect(isInheritedEffect: false, card: card, condition: null, trashValue: 3, effectName: "Fragment <3>", effectDiscription: EffectDiscription()));
  36. }
  37. #endregion
  38. #region When Digivolving - Add Sources OPT
  39. if (timing == EffectTiming.OnEnterFieldAnyone)
  40. {
  41. ActivateClass activateClass = new ActivateClass();
  42. activateClass.SetUpICardEffect("Place 3 cards from trash as bottom sources", CanUseCondition, card);
  43. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  44. activateClass.SetHashString("WDWA_EX10_036");
  45. cardEffects.Add(activateClass);
  46. string EffectDiscription()
  47. {
  48. return "[When Digivolving] [Once Per Turn] By placing 3 [Mineral] or [Rock] trait cards from your trash as this Digimon's bottom digivolution cards, it unsuspends.";
  49. }
  50. bool HasProperTrait(CardSource source)
  51. {
  52. return source.EqualsTraits("Mineral") || source.EqualsTraits("Rock");
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  57. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  58. }
  59. bool CanActivateCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  62. CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, HasProperTrait) >= 3;
  63. }
  64. IEnumerator ActivateCoroutine(Hashtable hashtable)
  65. {
  66. List<CardSource> selectedCards = new List<CardSource>();
  67. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  68. selectCardEffect.SetUp(
  69. canTargetCondition: HasProperTrait,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: CanEndSelectCondition,
  72. canNoSelect: () => false,
  73. selectCardCoroutine: SelectCardCoroutine,
  74. afterSelectCardCoroutine: null,
  75. message: "Select [Mineral] or [Rock] to place on bottom of digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  76. maxCount: 3,
  77. canEndNotMax: false,
  78. isShowOpponent: true,
  79. mode: SelectCardEffect.Mode.Custom,
  80. root: SelectCardEffect.Root.Trash,
  81. customRootCardList: null,
  82. canLookReverseCard: true,
  83. selectPlayer: card.Owner,
  84. cardEffect: activateClass);
  85. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  86. selectCardEffect.SetUpCustomMessage("Select [Mineral] or [Rock] to place on bottom of digivolution cards.", "The opponent is selecting [Mineral] or [Rock] to place on bottom of digivolution cards.");
  87. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  88. bool CanEndSelectCondition(List<CardSource> cardSources)
  89. {
  90. if (CardEffectCommons.HasNoElement(cardSources))
  91. {
  92. return false;
  93. }
  94. return true;
  95. }
  96. IEnumerator SelectCardCoroutine(CardSource cardSource)
  97. {
  98. selectedCards.Add(cardSource);
  99. yield return null;
  100. }
  101. if (selectedCards.Count >= 1)
  102. {
  103. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  104. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  105. }
  106. }
  107. }
  108. #endregion
  109. #region When Attacking - Add Sources OPT
  110. if (timing == EffectTiming.OnAllyAttack)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect("Place 3 cards from trash as bottom sources", CanUseCondition, card);
  114. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  115. activateClass.SetHashString("WDWA_EX10_036");
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[When Attacking] [Once Per Turn] By placing 3 [Mineral] or [Rock] trait cards from your trash as this Digimon's bottom digivolution cards, it unsuspends.";
  120. }
  121. bool HasProperTrait(CardSource source)
  122. {
  123. return source.EqualsTraits("Mineral") || source.EqualsTraits("Rock");
  124. }
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  128. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  133. CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, HasProperTrait) >= 3;
  134. }
  135. IEnumerator ActivateCoroutine(Hashtable hashtable)
  136. {
  137. List<CardSource> selectedCards = new List<CardSource>();
  138. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  139. selectCardEffect.SetUp(
  140. canTargetCondition: HasProperTrait,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: CanEndSelectCondition,
  143. canNoSelect: () => false,
  144. selectCardCoroutine: SelectCardCoroutine,
  145. afterSelectCardCoroutine: null,
  146. message: "Select [Mineral] or [Rock] to place on bottom of digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  147. maxCount: 3,
  148. canEndNotMax: false,
  149. isShowOpponent: true,
  150. mode: SelectCardEffect.Mode.Custom,
  151. root: SelectCardEffect.Root.Trash,
  152. customRootCardList: null,
  153. canLookReverseCard: true,
  154. selectPlayer: card.Owner,
  155. cardEffect: activateClass);
  156. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  157. selectCardEffect.SetUpCustomMessage("Select [Mineral] or [Rock] to place on bottom of digivolution cards.", "The opponent is selecting [Mineral] or [Rock] to place on bottom of digivolution cards.");
  158. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  159. bool CanEndSelectCondition(List<CardSource> cardSources)
  160. {
  161. if (CardEffectCommons.HasNoElement(cardSources))
  162. {
  163. return false;
  164. }
  165. return true;
  166. }
  167. IEnumerator SelectCardCoroutine(CardSource cardSource)
  168. {
  169. selectedCards.Add(cardSource);
  170. yield return null;
  171. }
  172. if (selectedCards.Count >= 1)
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  175. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  176. }
  177. }
  178. }
  179. #endregion
  180. #region When Digivolving - Delete/Trash
  181. if (timing == EffectTiming.OnEnterFieldAnyone)
  182. {
  183. ActivateClass activateClass = new ActivateClass();
  184. activateClass.SetUpICardEffect("By trashing 3 sources, Delete 1 digimon and trash top security", CanUseCondition, card);
  185. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  186. cardEffects.Add(activateClass);
  187. string EffectDiscription()
  188. {
  189. return "[When Digivolving] By trashing 3 [Mineral] or [Rock] trait cards from any of your Digimon's digivolution cards, delete 1 of your opponent's Digimon and trash their top security card.";
  190. }
  191. bool HasProperTrait(CardSource source)
  192. {
  193. return !source.CanNotTrashFromDigivolutionCards(activateClass) &&
  194. (source.EqualsTraits("Mineral") || source.EqualsTraits("Rock"));
  195. }
  196. bool HasProperAmountOfSources()
  197. {
  198. int totalSourceCount = 0;
  199. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  200. {
  201. totalSourceCount += permanent.DigivolutionCards.Count(HasProperTrait);
  202. }
  203. return totalSourceCount >= 3;
  204. }
  205. bool CanSelectPermanentCondition(Permanent permanent)
  206. {
  207. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  208. return permanent.DigivolutionCards.Count(HasProperTrait) >= 1;
  209. return false;
  210. }
  211. bool CanUseCondition(Hashtable hashtable)
  212. {
  213. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  214. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  215. }
  216. bool CanActivateCondition(Hashtable hashtable)
  217. {
  218. if (CardEffectCommons.IsExistOnBattleArea(card))
  219. return HasProperAmountOfSources();
  220. return false;
  221. }
  222. bool CanSelectOpponentsDigimon(Permanent permanent)
  223. {
  224. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  225. }
  226. IEnumerator ActivateCoroutine(Hashtable hashtable)
  227. {
  228. int trashedCount = 0;
  229. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  230. permanentCondition: CanSelectPermanentCondition,
  231. cardCondition: HasProperTrait,
  232. maxCount: 3,
  233. canNoTrash: false,
  234. isFromOnly1Permanent: false,
  235. activateClass: activateClass,
  236. afterSelectionCoroutine: AfterTrashedCards
  237. ));
  238. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  239. {
  240. trashedCount = cards.Count;
  241. yield return null;
  242. }
  243. if (trashedCount == 3)
  244. {
  245. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentsDigimon))
  246. {
  247. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  248. selectPermanentEffect.SetUp(
  249. selectPlayer: card.Owner,
  250. canTargetCondition: CanSelectOpponentsDigimon,
  251. canTargetCondition_ByPreSelecetedList: null,
  252. canEndSelectCondition: null,
  253. maxCount: 1,
  254. canNoSelect: false,
  255. canEndNotMax: false,
  256. selectPermanentCoroutine: null,
  257. afterSelectPermanentCoroutine: null,
  258. mode: SelectPermanentEffect.Mode.Destroy,
  259. cardEffect: activateClass);
  260. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  261. }
  262. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  263. player: card.Owner.Enemy,
  264. destroySecurityCount: 1,
  265. cardEffect: activateClass,
  266. fromTop: true).DestroySecurity());
  267. }
  268. }
  269. }
  270. #endregion
  271. #region When Attacking - Delete/Trash
  272. if (timing == EffectTiming.OnAllyAttack)
  273. {
  274. ActivateClass activateClass = new ActivateClass();
  275. activateClass.SetUpICardEffect("By trashing 3 sources, Delete 1 digimon and trash top security", CanUseCondition, card);
  276. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  277. cardEffects.Add(activateClass);
  278. string EffectDiscription()
  279. {
  280. return "[When Attacking] By trashing 3 [Mineral] or [Rock] trait cards from any of your Digimon's digivolution cards, delete 1 of your opponent's Digimon and trash their top security card.";
  281. }
  282. bool HasProperTrait(CardSource source)
  283. {
  284. return !source.CanNotTrashFromDigivolutionCards(activateClass) &&
  285. (source.EqualsTraits("Mineral") || source.EqualsTraits("Rock"));
  286. }
  287. bool HasProperAmountOfSources()
  288. {
  289. int totalSourceCount = 0;
  290. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  291. {
  292. totalSourceCount += permanent.DigivolutionCards.Count(HasProperTrait);
  293. }
  294. return totalSourceCount >= 3;
  295. }
  296. bool CanSelectPermanentCondition(Permanent permanent)
  297. {
  298. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  299. return permanent.DigivolutionCards.Count(HasProperTrait) >= 1;
  300. return false;
  301. }
  302. bool CanUseCondition(Hashtable hashtable)
  303. {
  304. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  305. }
  306. bool CanActivateCondition(Hashtable hashtable)
  307. {
  308. if (CardEffectCommons.IsExistOnBattleArea(card))
  309. return HasProperAmountOfSources();
  310. return false;
  311. }
  312. bool CanSelectOpponentsDigimon(Permanent permanent)
  313. {
  314. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  315. }
  316. IEnumerator ActivateCoroutine(Hashtable hashtable)
  317. {
  318. int trashedCount = 0;
  319. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  320. permanentCondition: CanSelectPermanentCondition,
  321. cardCondition: HasProperTrait,
  322. maxCount: 3,
  323. canNoTrash: false,
  324. isFromOnly1Permanent: false,
  325. activateClass: activateClass,
  326. afterSelectionCoroutine: AfterTrashedCards
  327. ));
  328. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  329. {
  330. trashedCount = cards.Count;
  331. yield return null;
  332. }
  333. if (trashedCount == 3)
  334. {
  335. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentsDigimon))
  336. {
  337. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  338. selectPermanentEffect.SetUp(
  339. selectPlayer: card.Owner,
  340. canTargetCondition: CanSelectOpponentsDigimon,
  341. canTargetCondition_ByPreSelecetedList: null,
  342. canEndSelectCondition: null,
  343. maxCount: 1,
  344. canNoSelect: false,
  345. canEndNotMax: false,
  346. selectPermanentCoroutine: null,
  347. afterSelectPermanentCoroutine: null,
  348. mode: SelectPermanentEffect.Mode.Destroy,
  349. cardEffect: activateClass);
  350. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  351. }
  352. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  353. player: card.Owner.Enemy,
  354. destroySecurityCount: 1,
  355. cardEffect: activateClass,
  356. fromTop: true).DestroySecurity());
  357. }
  358. }
  359. }
  360. #endregion
  361. return cardEffects;
  362. }
  363. }
  364. }