EX4_066.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX4
  6. {
  7. public class EX4_066 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OptionSkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Main] Activate 1 of the effects below. -If you have [CresGarurumon] in play, 1 of your [Agumon] or [Greymon] may digivolve into [BlitzGreymon] in your hand, ignoring digivolution requirements and without paying the cost. -If you have [BlitzGreymon] in play, 1 of your [Gabumon] or [Garurumon] may digivolve into [CresGarurumon] in your hand, ignoring digivolution requirements and without paying the cost.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  25. }
  26. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  27. {
  28. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>()
  29. {
  30. new SelectionElement<int>(message: $"Digivolve into [BlitzGreymon]", value : 0, spriteIndex: 0),
  31. new SelectionElement<int>(message: $"Digivolve into [CresGarurumon]", value : 1, spriteIndex: 1),
  32. };
  33. string selectPlayerMessage = "Which effect will you activate?";
  34. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  35. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  36. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  37. int actionID = GManager.instance.userSelectionManager.SelectedIntValue;
  38. switch (actionID)
  39. {
  40. case 0:
  41. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardNames.Contains("CresGarurumon")))
  42. {
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  46. {
  47. if (permanent.TopCard.CardNames.Contains("Agumon") || permanent.TopCard.CardNames.Contains("Greymon"))
  48. {
  49. foreach (CardSource cardSource in card.Owner.HandCards)
  50. {
  51. if (CanSelectCardCondition(cardSource))
  52. {
  53. if (!cardSource.CanNotEvolve(permanent))
  54. {
  55. return true;
  56. }
  57. }
  58. }
  59. }
  60. }
  61. return false;
  62. }
  63. bool CanSelectCardCondition(CardSource cardSource)
  64. {
  65. return cardSource.ContainsCardName("BlitzGreymon");
  66. }
  67. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  68. {
  69. Permanent selectedPermanent = null;
  70. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  71. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  72. selectPermanentEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectPermanentCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: maxCount,
  78. canNoSelect: true,
  79. canEndNotMax: false,
  80. selectPermanentCoroutine: SelectPermanentCoroutine,
  81. afterSelectPermanentCoroutine: null,
  82. mode: SelectPermanentEffect.Mode.Custom,
  83. cardEffect: activateClass);
  84. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  85. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  86. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  87. {
  88. selectedPermanent = permanent;
  89. yield return null;
  90. }
  91. if (selectedPermanent != null)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  94. targetPermanent: selectedPermanent,
  95. cardCondition: CanSelectCardCondition,
  96. payCost: false,
  97. reduceCostTuple: null,
  98. fixedCostTuple: null,
  99. ignoreDigivolutionRequirementFixedCost: 0,
  100. isHand: true,
  101. activateClass: activateClass,
  102. successProcess: null));
  103. }
  104. }
  105. }
  106. break;
  107. case 1:
  108. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardNames.Contains("BlitzGreymon")))
  109. {
  110. bool CanSelectPermanentCondition(Permanent permanent)
  111. {
  112. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  113. {
  114. if (permanent.TopCard.CardNames.Contains("Gabumon") || permanent.TopCard.CardNames.Contains("Garurumon"))
  115. {
  116. foreach (CardSource cardSource in card.Owner.HandCards)
  117. {
  118. if (CanSelectCardCondition(cardSource))
  119. {
  120. if (!cardSource.CanNotEvolve(permanent))
  121. {
  122. return true;
  123. }
  124. }
  125. }
  126. }
  127. }
  128. return false;
  129. }
  130. bool CanSelectCardCondition(CardSource cardSource)
  131. {
  132. return cardSource.ContainsCardName("CresGarurumon");
  133. }
  134. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  135. {
  136. Permanent selectedPermanent = null;
  137. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectPermanentCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: true,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: SelectPermanentCoroutine,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Custom,
  150. cardEffect: activateClass);
  151. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  152. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  153. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  154. {
  155. selectedPermanent = permanent;
  156. yield return null;
  157. }
  158. if (selectedPermanent != null)
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  161. targetPermanent: selectedPermanent,
  162. cardCondition: CanSelectCardCondition,
  163. payCost: false,
  164. reduceCostTuple: null,
  165. fixedCostTuple: null,
  166. ignoreDigivolutionRequirementFixedCost: 0,
  167. isHand: true,
  168. activateClass: activateClass,
  169. successProcess: null));
  170. }
  171. }
  172. }
  173. break;
  174. }
  175. }
  176. }
  177. if (timing == EffectTiming.SecuritySkill)
  178. {
  179. ActivateClass activateClass = new ActivateClass();
  180. activateClass.SetUpICardEffect($"Play 1 [Gabumon] or [Agumon] from hand or trash and add this card to hand", CanUseCondition, card);
  181. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  182. activateClass.SetIsSecurityEffect(true);
  183. cardEffects.Add(activateClass);
  184. string EffectDiscription()
  185. {
  186. return "[Security] You may play 1 [Gabumon] or [Agumon] from your hand or trash without paying the cost. Then, add this card to your hand.";
  187. }
  188. bool CanSelectCardCondition(CardSource cardSource)
  189. {
  190. if (cardSource != null)
  191. {
  192. if (cardSource.Owner == card.Owner)
  193. {
  194. if (cardSource.CardNames.Contains("Gabumon") || cardSource.CardNames.Contains("Agumon"))
  195. {
  196. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  197. {
  198. return true;
  199. }
  200. }
  201. }
  202. }
  203. return false;
  204. }
  205. bool CanUseCondition(Hashtable hashtable)
  206. {
  207. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  208. }
  209. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  210. {
  211. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  212. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  213. if (canSelectHand || canSelectTrash)
  214. {
  215. if (canSelectHand && canSelectTrash)
  216. {
  217. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  218. {
  219. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  220. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  221. };
  222. string selectPlayerMessage = "From which area do you play a card?";
  223. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  224. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  225. }
  226. else
  227. {
  228. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  229. }
  230. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  231. List<CardSource> selectedCards = new List<CardSource>();
  232. IEnumerator SelectCardCoroutine(CardSource cardSource)
  233. {
  234. selectedCards.Add(cardSource);
  235. yield return null;
  236. }
  237. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  238. if (fromHand)
  239. {
  240. int maxCount = 1;
  241. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  242. selectHandEffect.SetUp(
  243. selectPlayer: card.Owner,
  244. canTargetCondition: CanSelectCardCondition,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. maxCount: maxCount,
  248. canNoSelect: true,
  249. canEndNotMax: false,
  250. isShowOpponent: true,
  251. selectCardCoroutine: SelectCardCoroutine,
  252. afterSelectCardCoroutine: null,
  253. mode: SelectHandEffect.Mode.Custom,
  254. cardEffect: activateClass);
  255. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  256. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  257. yield return StartCoroutine(selectHandEffect.Activate());
  258. }
  259. else
  260. {
  261. int maxCount = 1;
  262. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  263. selectCardEffect.SetUp(
  264. canTargetCondition: CanSelectCardCondition,
  265. canTargetCondition_ByPreSelecetedList: null,
  266. canEndSelectCondition: null,
  267. canNoSelect: () => true,
  268. selectCardCoroutine: SelectCardCoroutine,
  269. afterSelectCardCoroutine: null,
  270. message: "Select 1 card to play.",
  271. maxCount: maxCount,
  272. canEndNotMax: false,
  273. isShowOpponent: true,
  274. mode: SelectCardEffect.Mode.Custom,
  275. root: SelectCardEffect.Root.Trash,
  276. customRootCardList: null,
  277. canLookReverseCard: true,
  278. selectPlayer: card.Owner,
  279. cardEffect: activateClass);
  280. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  281. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  282. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  283. }
  284. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  285. if (!fromHand)
  286. {
  287. root = SelectCardEffect.Root.Trash;
  288. }
  289. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  290. }
  291. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  292. }
  293. }
  294. return cardEffects;
  295. }
  296. }
  297. }