EX11_065.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Close
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_065 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Shared Conditions
  13. bool HasMineralOrRock(CardSource source)
  14. {
  15. return source.EqualsTraits("Mineral")
  16. || source.EqualsTraits("Rock");
  17. }
  18. #endregion
  19. #region Start of Your Main Phase
  20. if (timing == EffectTiming.OnStartMainPhase)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Trash 1 to gain 1 memory", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[Start of Your Main Phase] By trashing 1 [Mineral] or [Rock] trait card from your hand or your Digimon's digivolution cards, gain 1 memory.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.IsExistOnBattleArea(card) &&
  33. CardEffectCommons.IsOwnerTurn(card);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnBattleArea(card)
  38. && (CardEffectCommons.HasMatchConditionOwnersHand(card, HasMineralOrRock)
  39. || CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectTrashTargetCondition));
  40. }
  41. bool CanSelectTrashTargetCondition(Permanent permanent)
  42. {
  43. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  44. && permanent.DigivolutionCards.Count(HasMineralOrRock) >= 1;
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable hashtable)
  47. {
  48. #region Setup Location Selection
  49. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, HasMineralOrRock);
  50. bool canSelectDigivolutionSource = CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectTrashTargetCondition);
  51. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  52. if (canSelectHand)
  53. {
  54. selectionElements.Add(new(message: "From hand", value: 0, spriteIndex: 0));
  55. }
  56. if (canSelectDigivolutionSource)
  57. {
  58. selectionElements.Add(new(message: "From digivolution cards", value: 1, spriteIndex: 0));
  59. }
  60. selectionElements.Add(new(message: "Do not trash", value: 2, spriteIndex: 1));
  61. string selectPlayerMessage = "From which area will you trash a card?";
  62. string notSelectPlayerMessage = "The opponent is choosing if they will activate their effect.";
  63. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  64. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  65. notSelectPlayerMessage: notSelectPlayerMessage);
  66. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  67. .WaitForEndSelect());
  68. int selection = GManager.instance.userSelectionManager.SelectedIntValue;
  69. #endregion
  70. if (selection != 2)
  71. {
  72. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  73. bool discarded = false;
  74. if (selection == 0)
  75. {
  76. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  77. selectHandEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: HasMineralOrRock,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: 1,
  83. canNoSelect: true,
  84. canEndNotMax: false,
  85. isShowOpponent: true,
  86. selectCardCoroutine: null,
  87. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  88. mode: SelectHandEffect.Mode.Discard,
  89. cardEffect: activateClass);
  90. yield return StartCoroutine(selectHandEffect.Activate());
  91. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  92. {
  93. if (cardSources.Count >= 1)
  94. {
  95. discarded = true;
  96. yield return null;
  97. }
  98. }
  99. }
  100. else
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  103. permanentCondition: CanSelectTrashTargetCondition,
  104. cardCondition: HasMineralOrRock,
  105. maxCount: 1,
  106. canNoTrash: true,
  107. isFromOnly1Permanent: false,
  108. activateClass: activateClass,
  109. afterSelectionCoroutine: AfterTrashedCards
  110. ));
  111. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  112. {
  113. if (cards.Count >= 1)
  114. {
  115. discarded = true;
  116. yield return null;
  117. }
  118. }
  119. }
  120. if (discarded)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  123. }
  124. }
  125. }
  126. }
  127. #endregion
  128. #region All Turns
  129. if (timing == EffectTiming.OnEnterFieldAnyone)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect("Place 1 [Mineral]/[Rock] trait card from hand or trash under played/digivolved digimon", CanUseCondition, card);
  133. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  134. cardEffects.Add(activateClass);
  135. string EffectDescription() => "[All Turns] When your Digimon are played or digivolved, if any of them have the [Mineral] or [Rock] trait, by suspending this Tamer, you may place 1 [Mineral] or [Rock] trait card from your hand or trash as any of those Digimon's bottom digivolution card.";
  136. bool CanUseCondition(Hashtable hashtable)
  137. {
  138. return CardEffectCommons.IsExistOnBattleArea(card)
  139. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)
  140. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition));
  141. }
  142. bool CanActivateCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleArea(card)
  145. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  146. }
  147. bool PermanentCondition(Permanent permanent)
  148. {
  149. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  150. && (permanent.TopCard.EqualsTraits("Mineral")
  151. || permanent.TopCard.EqualsTraits("Rock"));
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable hashtable)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent> { card.PermanentOfThisCard() }, hashtable).Tap());
  156. #region Select Played/Digivolved Permanent
  157. List<Permanent> playedPermanents = new List<Permanent>();
  158. foreach (Hashtable hash in CardEffectCommons.GetHashtablesFromHashtable(hashtable))
  159. {
  160. playedPermanents.Add(CardEffectCommons.GetPermanentFromHashtable(hash));
  161. }
  162. List<Permanent> targetPermanents = playedPermanents.Filter(PermanentCondition);
  163. Permanent selectedPermament = null;
  164. if (targetPermanents.Count > 1)
  165. {
  166. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  167. selectPermanentEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: permanent => targetPermanents.Contains(permanent),
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: 1,
  173. canNoSelect: false,
  174. canEndNotMax: false,
  175. selectPermanentCoroutine: SelectPermanentCoroutine,
  176. afterSelectPermanentCoroutine: null,
  177. mode: SelectPermanentEffect.Mode.Custom,
  178. cardEffect: activateClass);
  179. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  180. {
  181. selectedPermament = permanent;
  182. yield return null;
  183. }
  184. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get the digivolution cards.", "The opponent is selecting 1 Digimon that will get the digivolution cards.");
  185. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  186. }
  187. else selectedPermament = targetPermanents[0];
  188. #endregion
  189. if (selectedPermament != null)
  190. {
  191. #region Setup Location Selection
  192. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, HasMineralOrRock);
  193. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasMineralOrRock);
  194. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  195. if (canSelectHand)
  196. {
  197. selectionElements.Add(new(message: "From hand", value: 0, spriteIndex: 0));
  198. }
  199. if (canSelectTrash)
  200. {
  201. selectionElements.Add(new(message: "From trash", value: 1, spriteIndex: 0));
  202. }
  203. selectionElements.Add(new(message: "Do not add", value: 2, spriteIndex: 1));
  204. string selectPlayerMessage = "From which area will you select a card?";
  205. string notSelectPlayerMessage = "The opponent is choosing if they will activate their effect.";
  206. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements,
  207. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  208. notSelectPlayerMessage: notSelectPlayerMessage);
  209. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  210. .WaitForEndSelect());
  211. int selection = GManager.instance.userSelectionManager.SelectedIntValue;
  212. #endregion
  213. if (selection != 2)
  214. {
  215. if (selection == 0)
  216. {
  217. List<CardSource> selectedCards = new List<CardSource>();
  218. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  219. selectHandEffect.SetUp(
  220. selectPlayer: card.Owner,
  221. canTargetCondition: HasMineralOrRock,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. maxCount: 1,
  225. canNoSelect: true,
  226. canEndNotMax: false,
  227. isShowOpponent: true,
  228. selectCardCoroutine: SelectCardCoroutine,
  229. afterSelectCardCoroutine: null,
  230. mode: SelectHandEffect.Mode.Custom,
  231. cardEffect: activateClass);
  232. selectHandEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.",
  233. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  234. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  235. yield return StartCoroutine(selectHandEffect.Activate());
  236. IEnumerator SelectCardCoroutine(CardSource cardSource)
  237. {
  238. selectedCards.Add(cardSource);
  239. yield return null;
  240. }
  241. if (selectedCards.Count >= 1)
  242. {
  243. yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddDigivolutionCardsBottom(selectedCards, activateClass));
  244. }
  245. }
  246. else
  247. {
  248. List<CardSource> selectedCards = new List<CardSource>();
  249. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  250. selectCardEffect.SetUp(
  251. canTargetCondition: HasMineralOrRock,
  252. canTargetCondition_ByPreSelecetedList: null,
  253. canEndSelectCondition: null,
  254. canNoSelect: () => true,
  255. selectCardCoroutine: SelectCardCoroutine,
  256. afterSelectCardCoroutine: null,
  257. message: "Select 1 card to place on bottom of digivolution cards.",
  258. maxCount: 1,
  259. canEndNotMax: false,
  260. isShowOpponent: true,
  261. mode: SelectCardEffect.Mode.Custom,
  262. root: SelectCardEffect.Root.Trash,
  263. customRootCardList: null,
  264. canLookReverseCard: true,
  265. selectPlayer: card.Owner,
  266. cardEffect: activateClass);
  267. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  268. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  269. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  270. IEnumerator SelectCardCoroutine(CardSource cardSource)
  271. {
  272. selectedCards.Add(cardSource);
  273. yield return null;
  274. }
  275. if (selectedCards.Count >= 1)
  276. {
  277. yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddDigivolutionCardsBottom(selectedCards, activateClass));
  278. }
  279. }
  280. }
  281. }
  282. }
  283. }
  284. #endregion
  285. #region Security Effect
  286. if (timing == EffectTiming.SecuritySkill)
  287. {
  288. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  289. }
  290. #endregion
  291. return cardEffects;
  292. }
  293. }
  294. }