BT14_033.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_033 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("This Digimon digivolves into Digimon card in security", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Start of Your Main Phase] Search your security stack. This Digimon may digivolve into a yellow Digimon card with the [Vaccine] trait among them without paying the cost. Then, shuffle your security stack. If digivolved by this effect, you may place 1 yellow card with the [Vaccine] trait from your hand at the bottom of your security stack.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource.CardTraits.Contains("Vaccine"))
  25. {
  26. if (cardSource.HasCardColor(CardColor.Yellow))
  27. {
  28. if (cardSource.IsDigimon)
  29. {
  30. if (CardEffectCommons.IsExistOnBattleArea(card))
  31. {
  32. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. bool CanSelectCardCondition1(CardSource cardSource)
  43. {
  44. if (cardSource.CardTraits.Contains("Vaccine"))
  45. {
  46. if (cardSource.HasCardColor(CardColor.Yellow))
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. if (CardEffectCommons.IsOwnerTurn(card))
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (card.Owner.SecurityCards.Count >= 1)
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. if (card.Owner.SecurityCards.Count >= 1)
  78. {
  79. int maxCount = Math.Min(1, card.Owner.SecurityCards.Count);
  80. CardSource selectedCard = null;
  81. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  82. selectCardEffect.SetUp(
  83. canTargetCondition: CanSelectCardCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. canNoSelect: () => true,
  87. selectCardCoroutine: SelectCardCoroutine,
  88. afterSelectCardCoroutine: null,
  89. message: "Select 1 card to digivolve.",
  90. maxCount: maxCount,
  91. canEndNotMax: false,
  92. isShowOpponent: true,
  93. mode: SelectCardEffect.Mode.Custom,
  94. root: SelectCardEffect.Root.Security,
  95. customRootCardList: null,
  96. canLookReverseCard: true,
  97. selectPlayer: card.Owner,
  98. cardEffect: activateClass);
  99. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  100. IEnumerator SelectCardCoroutine(CardSource cardSource)
  101. {
  102. selectedCard = cardSource;
  103. yield return null;
  104. }
  105. ContinuousController.instance.PlaySE(GManager.instance.ShuffleSE);
  106. card.Owner.SecurityCards = RandomUtility.ShuffledDeckCards(card.Owner.SecurityCards);
  107. if (selectedCard != null)
  108. {
  109. if (CardEffectCommons.IsExistOnBattleArea(card))
  110. {
  111. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = true;
  112. if (selectedCard.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, PayCost: false, activateClass, root: SelectCardEffect.Root.Security))
  113. {
  114. PlayCardClass playCardClass = new PlayCardClass(
  115. cardSources: new List<CardSource>() { selectedCard },
  116. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  117. payCost: false,
  118. targetPermanent: card.PermanentOfThisCard(),
  119. isTapped: false,
  120. root: SelectCardEffect.Root.Security,
  121. activateETB: true);
  122. yield return ContinuousController.instance.StartCoroutine(playCardClass.PlayCard());
  123. }
  124. GManager.instance.turnStateMachine.gameContext.IsSecurityLooking = false;
  125. if (CardEffectCommons.IsDigivolvedByTheEffect(card.PermanentOfThisCard(), selectedCard, activateClass))
  126. {
  127. if (card.Owner.CanAddSecurity(activateClass))
  128. {
  129. if (card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1)
  130. {
  131. List<CardSource> selectedCards = new List<CardSource>();
  132. maxCount = 1;
  133. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  134. selectHandEffect.SetUp(
  135. selectPlayer: card.Owner,
  136. canTargetCondition: CanSelectCardCondition1,
  137. canTargetCondition_ByPreSelecetedList: null,
  138. canEndSelectCondition: null,
  139. maxCount: maxCount,
  140. canNoSelect: true,
  141. canEndNotMax: false,
  142. isShowOpponent: true,
  143. selectCardCoroutine: SelectCardCoroutine1,
  144. afterSelectCardCoroutine: null,
  145. mode: SelectHandEffect.Mode.Custom,
  146. cardEffect: activateClass);
  147. selectHandEffect.SetUpCustomMessage(
  148. "Select 1 card to place at the bottom of security.",
  149. "The opponent is selecting 1 card to place at the bottom of security.");
  150. selectHandEffect.SetUpCustomMessage_ShowCard("Security Bottom Card");
  151. yield return StartCoroutine(selectHandEffect.Activate());
  152. IEnumerator SelectCardCoroutine1(CardSource cardSource)
  153. {
  154. selectedCards.Add(cardSource);
  155. yield return null;
  156. }
  157. foreach (CardSource cardSource in selectedCards)
  158. {
  159. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource, toTop: false));
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. }
  169. if (timing == EffectTiming.OnAddSecurity)
  170. {
  171. ActivateClass activateClass = new ActivateClass();
  172. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  173. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  174. activateClass.SetIsInheritedEffect(true);
  175. activateClass.SetHashString("Memory+1_BT14_033");
  176. cardEffects.Add(activateClass);
  177. string EffectDiscription()
  178. {
  179. return "[Your Turn][Once Per Turn] When a card is added to your security stack, gain 1 memory.";
  180. }
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. if (CardEffectCommons.IsExistOnBattleArea(card))
  184. {
  185. if (CardEffectCommons.IsOwnerTurn(card))
  186. {
  187. if (CardEffectCommons.CanTriggerWhenAddSecurity(hashtable, player => player == card.Owner))
  188. {
  189. return true;
  190. }
  191. }
  192. }
  193. return false;
  194. }
  195. bool CanActivateCondition(Hashtable hashtable)
  196. {
  197. if (CardEffectCommons.IsExistOnBattleArea(card))
  198. {
  199. return true;
  200. }
  201. return false;
  202. }
  203. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  204. {
  205. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  206. }
  207. }
  208. return cardEffects;
  209. }
  210. }
  211. }