ST24_15.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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, CardCondition));
  16. bool CardCondition(CardSource cardSource)
  17. {
  18. return cardSource.EqualsTraits("DATA SQUAD");
  19. }
  20. }
  21. #endregion
  22. #region Main
  23. if (timing == EffectTiming.OptionSkill)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. 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);
  27. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  28. cardEffects.Add(activateClass);
  29. string EffectDescription()
  30. {
  31. 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.";
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable hashtable)
  38. {
  39. bool CanSelectPlayCondition(CardSource cardSource)
  40. {
  41. return (cardSource.IsDigimon
  42. || cardSource.IsTamer)
  43. && cardSource.HasPlayCost
  44. && cardSource.EqualsTraits("DATA SQUAD")
  45. && cardSource.GetCostItself <= 4
  46. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  47. }
  48. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectPlayCondition);
  49. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectPlayCondition);
  50. if (canSelectHand || canSelectTrash)
  51. {
  52. #region Setup Location Selection
  53. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  54. if (canSelectHand)
  55. {
  56. selectionElements.Add(new(message: $"From hand", value: 1, spriteIndex: 0));
  57. }
  58. if (canSelectTrash)
  59. {
  60. selectionElements.Add(new(message: $"From trash", value: 2, spriteIndex: 0));
  61. }
  62. selectionElements.Add(new(message: $"Do not play", value: 3, spriteIndex: 1));
  63. string selectPlayerMessage = "From which area do you select a card?";
  64. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  65. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  66. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  67. #endregion
  68. SelectCardEffect.Root root = GManager.instance.userSelectionManager.SelectedIntValue == 1 ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  69. bool doSelect = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  70. if (doSelect)
  71. {
  72. #region Hand/Trash Card Selection & Play
  73. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  74. canTargetCondition: CanSelectPlayCondition,
  75. root,
  76. activateClass,
  77. payCost: false
  78. ));
  79. #endregion
  80. }
  81. }
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  83. }
  84. }
  85. #endregion
  86. #region Security
  87. if (timing == EffectTiming.SecuritySkill)
  88. {
  89. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  90. card: card,
  91. cardEffects: ref cardEffects,
  92. 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.");
  93. }
  94. #endregion
  95. #region Start of Your Main Phase
  96. if (timing == EffectTiming.OnStartMainPhase)
  97. {
  98. ActivateClass activateClass = new ActivateClass();
  99. activateClass.SetUpICardEffect("Place this card under 1 [DATA SQUAD] tamer face down to <Draw 1> and gain 1 memory", CanUseCondition, card);
  100. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  101. cardEffects.Add(activateClass);
  102. string EffectDescription()
  103. {
  104. 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.";
  105. }
  106. bool CanUseCondition(Hashtable hashtable)
  107. {
  108. return CardEffectCommons.IsExistOnBattleArea(card)
  109. && CardEffectCommons.IsOwnerTurn(card);
  110. }
  111. bool CanActivateCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.IsExistOnBattleArea(card)
  114. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentCondition);
  115. }
  116. bool CanSelectPermamentCondition(Permanent permanent)
  117. {
  118. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  119. && permanent.TopCard.EqualsTraits("DATA SQUAD");
  120. }
  121. IEnumerator ActivateCoroutine(Hashtable hashtable)
  122. {
  123. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentCondition))
  124. {
  125. Permanent selectedPermanent = null;
  126. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermamentCondition));
  127. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  128. selectPermanentEffect.SetUp(
  129. selectPlayer: card.Owner,
  130. canTargetCondition: CanSelectPermamentCondition,
  131. canTargetCondition_ByPreSelecetedList: null,
  132. canEndSelectCondition: null,
  133. maxCount: maxCount,
  134. canNoSelect: true,
  135. canEndNotMax: false,
  136. selectPermanentCoroutine: SelectPermanentCoroutine,
  137. afterSelectPermanentCoroutine: null,
  138. mode: SelectPermanentEffect.Mode.Custom,
  139. cardEffect: activateClass);
  140. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer that will get a digivolution card.", "The opponent is selecting 1 Tamer that will get a digivolution card.");
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  143. {
  144. selectedPermanent = permanent;
  145. yield return null;
  146. }
  147. if (selectedPermanent != null && !selectedPermanent.IsToken)
  148. {
  149. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  150. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass, false, true));
  151. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  152. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  153. }
  154. }
  155. }
  156. }
  157. #endregion
  158. return cardEffects;
  159. }
  160. }
  161. }