BT21_090.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //The Strongest of Brothers
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_090 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region ignoring colors
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. => CardEffectCommons.HasMatchConditionPermanent((permanent) => permanent.TopCard.Owner == card.Owner && (permanent.IsTamer || permanent.IsDigimon) && permanent.TopCard.HasText("Gammamon"), true);
  21. bool CardCondition(CardSource cardSource)
  22. => cardSource == card;
  23. }
  24. #endregion
  25. #region Main
  26. if (timing == EffectTiming.OptionSkill)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Reveal top 3, add 1 [Gammamon] then place in battle area", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "[Main] Reveal the top 3 cards of your deck. Add 1 card with [Gammamon] in its text among them to the hand. Return the rest to the bottom of the deck. Then, place this card in the battle area.";
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. return cardSource.HasText("Gammamon");
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  45. {
  46. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  47. revealCount: 3,
  48. simplifiedSelectCardConditions:
  49. new SimplifiedSelectCardConditionClass[]
  50. {
  51. new SimplifiedSelectCardConditionClass(
  52. canTargetCondition:CanSelectCardCondition,
  53. message: "Select 1 card with [Gammamon] in its text",
  54. mode: SelectCardEffect.Mode.AddHand,
  55. maxCount: 1,
  56. selectCardCoroutine: null),
  57. },
  58. remainingCardsPlace: RemainingCardsPlace.DeckBottom,
  59. activateClass: activateClass
  60. ));
  61. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  62. }
  63. }
  64. #endregion
  65. #region All Turns - Delay
  66. if (timing == EffectTiming.OnAddDigivolutionCards)
  67. {
  68. ActivateClass activateClass = new ActivateClass();
  69. activateClass.SetUpICardEffect("Your 1 Digimon digivolves", CanUseCondition, card);
  70. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  71. cardEffects.Add(activateClass);
  72. string EffectDiscription()
  73. {
  74. return "[All Turns] When effects place digivolution cards under your Digimon, <Delay> (After this card is placed, by trashing it the next turn or later, activate the effect below).\r\n・1 of your Digimon may digivolve into a Digimon card with [Gammamon] in its text in the hand without paying the cost.";
  75. }
  76. bool CanUseCondition(Hashtable hashtable)
  77. {
  78. if (CardEffectCommons.CanTriggerOnAddDigivolutionCard(hashtable, PermamentConndition, cardEffect => EffectCondition(hashtable, cardEffect), null))
  79. {
  80. if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
  81. {
  82. return true;
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
  90. {
  91. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  92. {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. bool PermamentConndition(Permanent permanent)
  99. {
  100. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  101. }
  102. bool EffectCondition(Hashtable hashtable, ICardEffect effect)
  103. {
  104. return CardEffectCommons.IsByEffect(hashtable, null);
  105. }
  106. bool CanSelectCardCondition(CardSource cardSource)
  107. {
  108. if (cardSource.IsDigimon)
  109. {
  110. if (cardSource.HasText("Gammamon"))
  111. {
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanSelectPermanentCondition(Permanent permanent)
  118. {
  119. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  120. {
  121. foreach (CardSource cardSource in card.Owner.HandCards)
  122. {
  123. if (CanSelectCardCondition(cardSource))
  124. {
  125. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. }
  132. return false;
  133. }
  134. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  135. {
  136. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  137. IEnumerator SuccessProcess()
  138. {
  139. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  140. {
  141. Permanent selectedPermanent = null;
  142. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  143. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. selectPermanentEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: CanSelectPermanentCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: maxCount,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. selectPermanentCoroutine: SelectPermanentCoroutine,
  153. afterSelectPermanentCoroutine: null,
  154. mode: SelectPermanentEffect.Mode.Custom,
  155. cardEffect: activateClass);
  156. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  159. {
  160. selectedPermanent = permanent;
  161. yield return null;
  162. }
  163. if (selectedPermanent != null)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  166. targetPermanent: selectedPermanent,
  167. cardCondition: CanSelectCardCondition,
  168. payCost: false,
  169. reduceCostTuple: null,
  170. fixedCostTuple: null,
  171. ignoreDigivolutionRequirementFixedCost: -1,
  172. isHand: true,
  173. activateClass: activateClass,
  174. successProcess: null));
  175. }
  176. }
  177. }
  178. }
  179. }
  180. #endregion
  181. #region Security
  182. if (timing == EffectTiming.SecuritySkill)
  183. {
  184. ActivateClass activateClass = new ActivateClass();
  185. activateClass.SetUpICardEffect("Play a 4 play cost or less card with [Gammamon] in text", CanUseCondition, card);
  186. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  187. activateClass.SetIsSecurityEffect(true);
  188. cardEffects.Add(activateClass);
  189. string EffectDiscription()
  190. {
  191. return "[Security] You may play 1 card with [Gammamon] in its text and a play cost of 4 or less from your hand or trash without paying the cost. Then, place this card in the battle area.";
  192. }
  193. bool CanUseCondition(Hashtable hashtable)
  194. {
  195. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  196. }
  197. bool CanActivateCondition(Hashtable hashtable)
  198. {
  199. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  200. }
  201. bool CanSelectCardCondition(CardSource cardSource)
  202. {
  203. if (cardSource.HasPlayCost)
  204. {
  205. if (cardSource.BasePlayCostFromEntity <= 4)
  206. {
  207. if (cardSource.HasText("Gammamon"))
  208. {
  209. if (!cardSource.IsDigiEgg)
  210. {
  211. return true;
  212. }
  213. }
  214. }
  215. }
  216. return false;
  217. }
  218. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  219. {
  220. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  221. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  222. if(canSelectHand || canSelectTrash)
  223. {
  224. if (canSelectHand && canSelectTrash)
  225. {
  226. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  227. {
  228. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  229. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  230. };
  231. string selectPlayerMessage = "From which area do you select a card?";
  232. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  233. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  234. }
  235. else
  236. {
  237. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  238. }
  239. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  240. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  241. CardSource selectedCard = null;
  242. if (fromHand)
  243. {
  244. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  245. selectHandEffect.SetUp(
  246. selectPlayer: card.Owner,
  247. canTargetCondition: CanSelectCardCondition,
  248. canTargetCondition_ByPreSelecetedList: null,
  249. canEndSelectCondition: null,
  250. maxCount: 1,
  251. canNoSelect: true,
  252. canEndNotMax: false,
  253. isShowOpponent: true,
  254. selectCardCoroutine: SelectCardCoroutine,
  255. afterSelectCardCoroutine: null,
  256. mode: SelectHandEffect.Mode.Custom,
  257. cardEffect: activateClass);
  258. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  259. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  260. yield return StartCoroutine(selectHandEffect.Activate());
  261. }
  262. else
  263. {
  264. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  265. selectCardEffect.SetUp(
  266. canTargetCondition: CanSelectCardCondition,
  267. canTargetCondition_ByPreSelecetedList: null,
  268. canEndSelectCondition: null,
  269. canNoSelect: () => true,
  270. selectCardCoroutine: SelectCardCoroutine,
  271. afterSelectCardCoroutine: null,
  272. message: "Select 1 card to play.",
  273. maxCount: 1,
  274. canEndNotMax: false,
  275. isShowOpponent: true,
  276. mode: SelectCardEffect.Mode.Custom,
  277. root: SelectCardEffect.Root.Trash,
  278. customRootCardList: null,
  279. canLookReverseCard: true,
  280. selectPlayer: card.Owner,
  281. cardEffect: activateClass);
  282. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  283. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  284. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  285. }
  286. IEnumerator SelectCardCoroutine(CardSource cardSource)
  287. {
  288. selectedCard = cardSource;
  289. yield return null;
  290. }
  291. if (selectedCard != null)
  292. {
  293. var selectedRoot = fromHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  294. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: selectedRoot, activateETB: true));
  295. }
  296. }
  297. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  298. }
  299. }
  300. #endregion
  301. return cardEffects;
  302. }
  303. }
  304. }