ST24_15.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // DNA Charge
  5. namespace DCGO.CardEffects.ST24
  6. {
  7. public class ST24_15 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. cardEffects.Add(CardEffectFactory.UseRequirements(card, PermanentCondition));
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return CardEffectCommons.IsOwnerPermanent(permanent, card)
  19. && permanent.TopCard.EqualsTraits("DATA SQUAD")
  20. && (permanent.IsDigimon || permanent.IsTamer);
  21. }
  22. }
  23. #endregion
  24. #region Main
  25. if (timing == EffectTiming.OptionSkill)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Play 1 [DATA SQUAD] card with a play cost of 4 or less from hand or trash for free, place this card in battle area", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  30. cardEffects.Add(activateClass);
  31. string EffectDescription()
  32. {
  33. return "[Main] You may play 1 [DATA SQUAD] trait card with a play cost of 4 or less from your hand or trash without paying the cost. Then, place this card in the battle area.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  38. }
  39. IEnumerator ActivateCoroutine(Hashtable hashtable)
  40. {
  41. bool CanSelectPlayCondition(CardSource cardSource)
  42. {
  43. return (cardSource.IsDigimon
  44. || cardSource.IsTamer)
  45. && cardSource.HasPlayCost
  46. && cardSource.EqualsTraits("DATA SQUAD")
  47. && cardSource.GetCostItself <= 4
  48. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  49. }
  50. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectPlayCondition);
  51. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectPlayCondition);
  52. if (canSelectHand || canSelectTrash)
  53. {
  54. #region Setup Location Selection
  55. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  56. if (canSelectHand)
  57. {
  58. selectionElements.Add(new(message: $"From hand", value: 1, spriteIndex: 0));
  59. }
  60. if (canSelectTrash)
  61. {
  62. selectionElements.Add(new(message: $"From trash", value: 2, spriteIndex: 0));
  63. }
  64. selectionElements.Add(new(message: $"Do not play", value: 3, spriteIndex: 1));
  65. string selectPlayerMessage = "From which area do you select a card?";
  66. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  67. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  68. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  69. #endregion
  70. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  71. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  72. if (doPlay)
  73. {
  74. #region Hand/Trash Card Selection & Play
  75. if (fromHand)
  76. {
  77. SelectHandEffect selectHandEffect2 = GManager.instance.GetComponent<SelectHandEffect>();
  78. selectHandEffect2.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectPlayCondition,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: 1,
  84. canNoSelect: true,
  85. canEndNotMax: false,
  86. isShowOpponent: true,
  87. selectCardCoroutine: null,
  88. afterSelectCardCoroutine: null,
  89. mode: SelectHandEffect.Mode.PlayForFree,
  90. cardEffect: activateClass);
  91. yield return StartCoroutine(selectHandEffect2.Activate());
  92. }
  93. else
  94. {
  95. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  96. selectCardEffect.SetUp(
  97. canTargetCondition: CanSelectPlayCondition,
  98. canTargetCondition_ByPreSelecetedList: null,
  99. canEndSelectCondition: null,
  100. canNoSelect: () => true,
  101. selectCardCoroutine: null,
  102. afterSelectCardCoroutine: null,
  103. message: "Select 1 card to play.",
  104. maxCount: 1,
  105. canEndNotMax: false,
  106. isShowOpponent: true,
  107. mode: SelectCardEffect.Mode.PlayForFree,
  108. root: SelectCardEffect.Root.Trash,
  109. customRootCardList: null,
  110. canLookReverseCard: true,
  111. selectPlayer: card.Owner,
  112. cardEffect: activateClass);
  113. yield return StartCoroutine(selectCardEffect.Activate());
  114. }
  115. #endregion
  116. }
  117. }
  118. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  119. }
  120. }
  121. #endregion
  122. #region Security
  123. if (timing == EffectTiming.SecuritySkill)
  124. {
  125. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  126. card: card,
  127. cardEffects: ref cardEffects,
  128. effectName: "[Security] You may play 1 [DATA SQUAD] trait card with a play cost of 4 or less from your hand or trash without paying the cost. Then, place this card in the battle area.");
  129. }
  130. #endregion
  131. #region Start of Your Main Phase
  132. if (timing == EffectTiming.OnStartMainPhase)
  133. {
  134. ActivateClass activateClass = new ActivateClass();
  135. activateClass.SetUpICardEffect("Place this card under 1 [DATA SQUAD] tamer face down to <Draw 1> and gain 1 memory", CanUseCondition, card);
  136. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  137. cardEffects.Add(activateClass);
  138. string EffectDescription()
  139. {
  140. return "[Start of Your Main Phase] By placing this card from the battle area face down under any of your [DATA SQUAD] trait Tamers, <Draw 1> and gain 1 memory.";
  141. }
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleArea(card)
  145. && CardEffectCommons.IsOwnerTurn(card);
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleArea(card)
  150. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentCondition);
  151. }
  152. bool CanSelectPermamentCondition(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  155. && permanent.TopCard.EqualsTraits("DATA SQUAD");
  156. }
  157. IEnumerator ActivateCoroutine(Hashtable hashtable)
  158. {
  159. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentCondition))
  160. {
  161. Permanent selectedPermanent = null;
  162. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermamentCondition));
  163. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  164. selectPermanentEffect.SetUp(
  165. selectPlayer: card.Owner,
  166. canTargetCondition: CanSelectPermamentCondition,
  167. canTargetCondition_ByPreSelecetedList: null,
  168. canEndSelectCondition: null,
  169. maxCount: maxCount,
  170. canNoSelect: true,
  171. canEndNotMax: false,
  172. selectPermanentCoroutine: SelectPermanentCoroutine,
  173. afterSelectPermanentCoroutine: null,
  174. mode: SelectPermanentEffect.Mode.Custom,
  175. cardEffect: activateClass);
  176. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer that will get a digivolution card.", "The opponent is selecting 1 Tamer that will get a digivolution card.");
  177. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  178. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  179. {
  180. selectedPermanent = permanent;
  181. yield return null;
  182. }
  183. if (selectedPermanent != null && !selectedPermanent.IsToken)
  184. {
  185. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  186. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  187. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  188. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  189. }
  190. }
  191. }
  192. }
  193. #endregion
  194. return cardEffects;
  195. }
  196. }
  197. }