EX4_066.cs 19 KB

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