BT17_096.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_096 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main Effect
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect($"Play 1 [Guilmon] or [Takato Matsuki] from your hand or trash",
  17. CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. activateClass.SetIsSecurityEffect(true);
  20. cardEffects.Add(activateClass);
  21. string EffectDescription()
  22. {
  23. return
  24. "[Main] You may play 1 [Guilmon]/[Takato Matsuki] from your hand or trash without paying the cost. Then, place this card in the battle area.";
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  29. }
  30. bool CanSelectCardCondition(CardSource cardSource)
  31. {
  32. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  33. {
  34. if (cardSource.IsDigimon)
  35. {
  36. return cardSource.EqualsCardName("Guilmon");
  37. }
  38. if (cardSource.IsTamer)
  39. {
  40. return cardSource.EqualsCardName("Takato Matsuki");
  41. }
  42. }
  43. return false;
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable hashtable)
  46. {
  47. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  48. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  49. if (canSelectHand || canSelectTrash)
  50. {
  51. if (canSelectHand && canSelectTrash)
  52. {
  53. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  54. {
  55. new(message: "From hand", value: true, spriteIndex: 0),
  56. new(message: "From trash", value: false, spriteIndex: 1),
  57. };
  58. string selectPlayerMessage = "From which area do you play a card?";
  59. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  60. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  61. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  62. notSelectPlayerMessage: notSelectPlayerMessage);
  63. }
  64. else
  65. {
  66. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  67. }
  68. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  69. .WaitForEndSelect());
  70. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  71. List<CardSource> selectedCards = new List<CardSource>();
  72. IEnumerator SelectCardCoroutine(CardSource cardSource)
  73. {
  74. selectedCards.Add(cardSource);
  75. yield return null;
  76. }
  77. if (fromHand)
  78. {
  79. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  80. selectHandEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: CanSelectCardCondition,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: 1,
  86. canNoSelect: true,
  87. canEndNotMax: false,
  88. isShowOpponent: true,
  89. selectCardCoroutine: SelectCardCoroutine,
  90. afterSelectCardCoroutine: null,
  91. mode: SelectHandEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  94. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  95. yield return StartCoroutine(selectHandEffect.Activate());
  96. }
  97. else
  98. {
  99. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  100. selectCardEffect.SetUp(
  101. canTargetCondition: CanSelectCardCondition,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. canNoSelect: () => true,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. message: "Select 1 card to play.",
  108. maxCount: 1,
  109. canEndNotMax: false,
  110. isShowOpponent: true,
  111. mode: SelectCardEffect.Mode.Custom,
  112. root: SelectCardEffect.Root.Trash,
  113. customRootCardList: null,
  114. canLookReverseCard: true,
  115. selectPlayer: card.Owner,
  116. cardEffect: activateClass);
  117. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  118. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  119. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  120. }
  121. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  122. if (!fromHand)
  123. {
  124. root = SelectCardEffect.Root.Trash;
  125. }
  126. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  127. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root,
  128. activateETB: true));
  129. }
  130. yield return ContinuousController.instance.StartCoroutine(
  131. CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  132. }
  133. }
  134. #endregion
  135. #region Delay Effect
  136. if (timing == EffectTiming.OnEnterFieldAnyone)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect(
  140. "Digivolve into a Digimon card with [Gallantmon] in its name",
  141. CanUseCondition, card);
  142. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  143. activateClass.SetHashString("DigivolveGallantmon_BT17_096");
  144. cardEffects.Add(activateClass);
  145. string EffectDescription()
  146. {
  147. return
  148. "[All Turns] When an opponent's level 5 or higher Digimon is played, [Delay]. ・1 of your Digimon may digivolve into a Digimon card with [Gallantmon] in its name in the hand without paying the cost.";
  149. }
  150. bool CanUseCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
  153. {
  154. return CardEffectCommons.CanTriggerOnPermanentPlay(hashtable,
  155. permanent =>
  156. CardEffectCommons.IsOpponentPermanent(permanent, card) &&
  157. permanent.IsDigimon &&
  158. permanent.TopCard.HasLevel && permanent.Level >= 5);
  159. }
  160. return false;
  161. }
  162. bool IsGallantmonCardCondition(CardSource cardSource)
  163. {
  164. return cardSource.ContainsCardName("Gallantmon");
  165. }
  166. bool OwnDigimonCondition(Permanent permanent)
  167. {
  168. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  169. {
  170. foreach (CardSource cardSource in card.Owner.HandCards)
  171. {
  172. if (IsGallantmonCardCondition(cardSource))
  173. {
  174. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  175. {
  176. return true;
  177. }
  178. }
  179. }
  180. }
  181. return false;
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable hashtable)
  184. {
  185. yield return ContinuousController.instance.StartCoroutine(
  186. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  187. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  188. activateClass: activateClass, successProcess: _ => SuccessProcess(),
  189. failureProcess: null));
  190. }
  191. IEnumerator SuccessProcess()
  192. {
  193. if (CardEffectCommons.HasMatchConditionPermanent(OwnDigimonCondition))
  194. {
  195. Permanent selectedPermanent = null;
  196. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(OwnDigimonCondition));
  197. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  198. selectPermanentEffect.SetUp(
  199. selectPlayer: card.Owner,
  200. canTargetCondition: OwnDigimonCondition,
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. maxCount: maxCount,
  204. canNoSelect: true,
  205. canEndNotMax: false,
  206. selectPermanentCoroutine: SelectPermanentCoroutine,
  207. afterSelectPermanentCoroutine: null,
  208. mode: SelectPermanentEffect.Mode.Custom,
  209. cardEffect: activateClass);
  210. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  211. "The opponent is selecting 1 Digimon that will digivolve.");
  212. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  213. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  214. {
  215. selectedPermanent = permanent;
  216. yield return null;
  217. }
  218. if (selectedPermanent != null)
  219. {
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  221. targetPermanent: selectedPermanent,
  222. cardCondition: IsGallantmonCardCondition,
  223. payCost: false,
  224. reduceCostTuple: null,
  225. fixedCostTuple: null,
  226. ignoreDigivolutionRequirementFixedCost: -1,
  227. isHand: true,
  228. activateClass: activateClass,
  229. successProcess: null));
  230. }
  231. }
  232. }
  233. }
  234. #endregion
  235. #region Security Effect
  236. if (timing == EffectTiming.SecuritySkill)
  237. {
  238. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects,
  239. effectName: "Play 1 [Guilmon] or [Takato Matsuki] from your hand or trash");
  240. }
  241. #endregion
  242. return cardEffects;
  243. }
  244. }
  245. }