EX10_033.cs 20 KB

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