BT23_098.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. //
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_098 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Ghostmon]/[Violet Inboots] from hand or trash, then place in battle area", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] You may play 1 [Ghostmon] or [Violet Inboots] from your hand or trash without paying the cost. Then, place this card in the battle area.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  26. }
  27. bool CanSelectCardCondition(CardSource cardSource)
  28. {
  29. return cardSource.EqualsCardName("Ghostmon") || cardSource.EqualsCardName("Violet Inboots")
  30. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  31. }
  32. IEnumerator ActivateCoroutine(Hashtable hashtable)
  33. {
  34. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  35. {
  36. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  37. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  38. if (canSelectHand || canSelectTrash)
  39. {
  40. #region Setup Location Selection
  41. if (canSelectHand && canSelectTrash)
  42. {
  43. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  44. {
  45. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  46. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  47. };
  48. string selectPlayerMessage = "From which area do you select a card?";
  49. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  50. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  51. }
  52. else
  53. {
  54. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  55. }
  56. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  57. #endregion
  58. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  59. CardSource selectedCard = null;
  60. IEnumerator SelectCardCoroutine(CardSource cardSource)
  61. {
  62. selectedCard = cardSource;
  63. yield return null;
  64. }
  65. #region Hand/Trash Card Selection & Play
  66. if (fromHand)
  67. {
  68. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  69. selectHandEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectCardCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: 1,
  75. canNoSelect: true,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. selectCardCoroutine: SelectCardCoroutine,
  79. afterSelectCardCoroutine: null,
  80. mode: SelectHandEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectHandEffect.SetUpCustomMessage("Select 1 [Ghostmon]/[Violet Inboots] to play.", "The opponent is selecting 1 [Ghostmon]/[Violet Inboots] to play.");
  83. yield return StartCoroutine(selectHandEffect.Activate());
  84. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  85. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Hand, true));
  86. }
  87. else
  88. {
  89. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  90. selectCardEffect.SetUp(
  91. canTargetCondition: CanSelectCardCondition,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. canNoSelect: () => true,
  95. selectCardCoroutine: SelectCardCoroutine,
  96. afterSelectCardCoroutine: null,
  97. message: "Select 1 [Ghostmon]/[Violet Inboots] to play.",
  98. maxCount: 1,
  99. canEndNotMax: false,
  100. isShowOpponent: true,
  101. mode: SelectCardEffect.Mode.Custom,
  102. root: SelectCardEffect.Root.Trash,
  103. customRootCardList: null,
  104. canLookReverseCard: true,
  105. selectPlayer: card.Owner,
  106. cardEffect: activateClass);
  107. selectCardEffect.SetUpCustomMessage("Select 1 [Ghostmon]/[Violet Inboots] to play.", "The opponent is selecting 1 [Ghostmon]/[Violet Inboots] to play.");
  108. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  109. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  110. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Trash, true));
  111. }
  112. #endregion
  113. }
  114. }
  115. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  116. }
  117. }
  118. #endregion
  119. #region Your turn - Delay
  120. if (timing == EffectTiming.OnTappedAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("1 of your [Ghost] trait Digimon may digivolve", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  125. cardEffects.Add(activateClass);
  126. string EffectDiscription()
  127. {
  128. return "[Your Turn] When any of your [Violet Inboots] suspend, <Delay> (By trashing this card after the placing turn, activate the effect below.)\r\n・1 of your [Ghost] trait Digimon may digivolve into a [Ghost] and [LIBERATOR] trait Digimon card in the hand with the digivolution cost reduced by 3.";
  129. }
  130. bool CanUseCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnBattleArea(card)
  133. && CardEffectCommons.CanDeclareOptionDelayEffect(card) &&
  134. CardEffectCommons.IsOwnerTurn(card) &&
  135. CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, IsVioletInboots);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.IsExistOnBattleArea(card);
  140. }
  141. bool IsVioletInboots(Permanent permanent)
  142. {
  143. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  144. && permanent.IsTamer
  145. && permanent.TopCard.EqualsCardName("Violet Inboots");
  146. }
  147. bool PermanentCondition(Permanent permanent)
  148. {
  149. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  150. && permanent.TopCard.HasGhostTraits;
  151. }
  152. bool CardCondition(CardSource cardSource)
  153. {
  154. return cardSource.IsDigimon
  155. && cardSource.HasGhostTraits
  156. && cardSource.HasLiberatorTraits;
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable hashtable)
  159. {
  160. bool delaySuccessful = false;
  161. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  162. IEnumerator SuccessProcess()
  163. {
  164. delaySuccessful = true;
  165. yield return null;
  166. }
  167. if (delaySuccessful)
  168. {
  169. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  170. {
  171. Permanent selectedDigimon = null;
  172. #region Select Permanent
  173. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, PermanentCondition));
  174. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  175. selectPermanentEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: PermanentCondition,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: maxCount,
  181. canNoSelect: true,
  182. canEndNotMax: false,
  183. selectPermanentCoroutine: SelectPermanentCoroutine,
  184. afterSelectPermanentCoroutine: null,
  185. mode: SelectPermanentEffect.Mode.Custom,
  186. cardEffect: activateClass);
  187. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  188. {
  189. selectedDigimon = permanent;
  190. yield return null;
  191. }
  192. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve", "The opponent is selecting 1 Digimon to digivolve");
  193. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  194. #endregion
  195. if (selectedDigimon != null) yield return ContinuousController.instance.StartCoroutine(
  196. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  197. targetPermanent: selectedDigimon,
  198. cardCondition: CardCondition,
  199. payCost: true,
  200. reduceCostTuple: (reduceCost: 3, reduceCostCardCondition: null),
  201. fixedCostTuple: null,
  202. ignoreDigivolutionRequirementFixedCost: -1,
  203. isHand: true,
  204. activateClass: activateClass,
  205. successProcess: null
  206. )
  207. );
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. #region Security Effect
  214. if (timing == EffectTiming.SecuritySkill)
  215. {
  216. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  217. card: card,
  218. cardEffects: ref cardEffects,
  219. effectName: "Play 1 [Ghostmon]/[Violet Inboots] from hand or trash, then place in battle area");
  220. }
  221. #endregion
  222. return cardEffects;
  223. }
  224. }
  225. }