BT21_095.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. public class BT21_095 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Ignore Color Requirement
  12. if (timing == EffectTiming.None)
  13. {
  14. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  15. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  16. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  17. cardEffects.Add(ignoreColorConditionClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. return card.Owner.SecurityCards.Count(cardSource => !cardSource.IsFlipped) == 0;
  21. }
  22. bool CardCondition(CardSource cardSource)
  23. {
  24. return cardSource == card;
  25. }
  26. }
  27. #endregion
  28. #region All Turns - Security
  29. if (timing == EffectTiming.None)
  30. {
  31. bool PermanentCondition(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  34. permanent.TopCard.EqualsTraits("WG");
  35. }
  36. AddSkillClass addSkillClass = new AddSkillClass();
  37. addSkillClass.SetUpICardEffect("Your Digimon gain <Vortex>", CanUseCondition, card);
  38. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  39. cardEffects.Add(addSkillClass);
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistInSecurity(card, false) &&
  43. CardEffectCommons.HasMatchConditionPermanent(PermanentCondition);
  44. }
  45. bool CardSourceCondition(CardSource cardSource)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource) &&
  48. cardSource.Owner == card.Owner &&
  49. cardSource == cardSource.PermanentOfThisCard().TopCard &&
  50. PermanentCondition(cardSource.PermanentOfThisCard());
  51. }
  52. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> effects, EffectTiming effectTiming)
  53. {
  54. if (effectTiming == EffectTiming.OnEndTurn)
  55. {
  56. bool Condition()
  57. {
  58. return CardSourceCondition(cardSource);
  59. }
  60. effects.Add(CardEffectFactory.VortexSelfEffect(false, cardSource, Condition));
  61. }
  62. return effects;
  63. }
  64. }
  65. #endregion
  66. #region Main Effect
  67. if (timing == EffectTiming.OptionSkill)
  68. {
  69. ActivateClass activateClass = new ActivateClass();
  70. activateClass.SetUpICardEffect("Replace your bottom security card with this face-up card", CanUseCondition, card);
  71. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  72. cardEffects.Add(activateClass);
  73. string EffectDescription()
  74. {
  75. return "[Main] Add your bottom security card to the hand. Then, place this card face up as the bottom security card.";
  76. }
  77. bool CanUseCondition(Hashtable hashtable)
  78. {
  79. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  80. }
  81. IEnumerator ActivateCoroutine(Hashtable hashtable)
  82. {
  83. if (card.Owner.SecurityCards.Count >= 1)
  84. {
  85. // Add your bottom security card to the hand
  86. CardSource bottomCard = card.Owner.SecurityCards[^1];
  87. yield return ContinuousController.instance.StartCoroutine(
  88. CardObjectController.AddHandCards(new List<CardSource>() { bottomCard }, false, activateClass));
  89. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  90. player: card.Owner,
  91. refSkillInfos: ref ContinuousController.instance.nullSkillInfos).ReduceSecurity());
  92. }
  93. // Place this card face up as the bottom security card
  94. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(
  95. card, toTop: false, faceUp: true));
  96. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  97. .CreateRecoveryEffect(card.Owner));
  98. yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(card.Owner).AddSecurity());
  99. }
  100. }
  101. #endregion
  102. #region Security Effect
  103. if (timing == EffectTiming.SecuritySkill)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect($"Play 1 [WG] Digimon card from hand", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  108. activateClass.SetIsSecurityEffect(true);
  109. cardEffects.Add(activateClass);
  110. string EffectDescription()
  111. {
  112. return
  113. "[Security] You may play 1 level 5 or lower Digimon with the [WG] trait from your hand without paying the cost.";
  114. }
  115. bool CanUseCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  118. }
  119. bool CanSelectCardCondition(CardSource cardSource)
  120. {
  121. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 5 &&
  122. cardSource.EqualsTraits("WG") &&
  123. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  124. }
  125. IEnumerator ActivateCoroutine(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  128. {
  129. List<CardSource> selectedCards = new List<CardSource>();
  130. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  131. selectHandEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: CanSelectCardCondition,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: 1,
  137. canNoSelect: true,
  138. canEndNotMax: false,
  139. isShowOpponent: true,
  140. selectCardCoroutine: SelectCardCoroutine,
  141. afterSelectCardCoroutine: null,
  142. mode: SelectHandEffect.Mode.Custom,
  143. cardEffect: activateClass);
  144. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  145. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  146. yield return StartCoroutine(selectHandEffect.Activate());
  147. IEnumerator SelectCardCoroutine(CardSource cardSource)
  148. {
  149. selectedCards.Add(cardSource);
  150. yield return null;
  151. }
  152. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  153. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  154. root: SelectCardEffect.Root.Hand, activateETB: true));
  155. }
  156. }
  157. }
  158. #endregion
  159. return cardEffects;
  160. }
  161. }
  162. }