EX8_071.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_071 : 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. AddSkillClass addSkillClass = new AddSkillClass();
  32. addSkillClass.SetUpICardEffect("Your NSo trait Digimon gain Scapegoat", CanUseCondition, card);
  33. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  34. cardEffects.Add(addSkillClass);
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsOwnerEffect(addSkillClass, card) &&
  38. CardEffectCommons.IsExistInSecurity(card, false) &&
  39. CardEffectCommons.HasMatchConditionPermanent(PermanentCondition);
  40. }
  41. bool PermanentCondition(Permanent permanent)
  42. {
  43. return card.Owner == permanent.TopCard.Owner &&
  44. CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  45. permanent.TopCard.HasLevel && permanent.TopCard.Level >= 4 &&
  46. permanent.TopCard.EqualsTraits("NSo");
  47. }
  48. bool CardSourceCondition(CardSource cardSource)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
  51. {
  52. if (cardSource.Owner == card.Owner)
  53. {
  54. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  55. {
  56. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. }
  63. return false;
  64. }
  65. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  66. {
  67. if (_timing == EffectTiming.WhenPermanentWouldBeDeleted)
  68. {
  69. bool Condition()
  70. {
  71. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(cardSource.PermanentOfThisCard(), card) &&
  72. cardSource.HasLevel && cardSource.Level >= 4 &&
  73. cardSource.EqualsTraits("NSo");
  74. }
  75. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: false, card: cardSource, condition: Condition, effectName: "<Scapegoat>", effectDiscription: null));
  76. }
  77. return cardEffects;
  78. }
  79. }
  80. #endregion
  81. #region Main Effect
  82. if (timing == EffectTiming.OptionSkill)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Replace your bottom security card with this face-up card", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  87. cardEffects.Add(activateClass);
  88. string EffectDescription()
  89. {
  90. return "[Main] Add your bottom security card to the hand. Then, place this card face up as the bottom security card.";
  91. }
  92. bool CanUseCondition(Hashtable hashtable)
  93. {
  94. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  95. }
  96. IEnumerator ActivateCoroutine(Hashtable hashtable)
  97. {
  98. if(card.Owner.SecurityCards.Count >= 1)
  99. {
  100. // Add your bottom security card to the hand
  101. CardSource bottomCard = card.Owner.SecurityCards[^1];
  102. yield return ContinuousController.instance.StartCoroutine(
  103. CardObjectController.AddHandCards(new List<CardSource>() { bottomCard }, false, activateClass));
  104. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  105. player: card.Owner,
  106. refSkillInfos: ref ContinuousController.instance.nullSkillInfos).ReduceSecurity());
  107. }
  108. // Place this card face up as the bottom security card
  109. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(
  110. card, toTop: false, faceUp: true));
  111. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  112. .CreateRecoveryEffect(card.Owner));
  113. yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(card.Owner).AddSecurity());
  114. }
  115. }
  116. #endregion
  117. #region Security Effect
  118. if (timing == EffectTiming.SecuritySkill)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect($"Play 1 [NSo] Digimon card from hand", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  123. activateClass.SetIsSecurityEffect(true);
  124. cardEffects.Add(activateClass);
  125. string EffectDescription()
  126. {
  127. return
  128. "[Security] You may play 1 level 5 or lower Digimon with the [NSo] trait from your hand without paying the cost.";
  129. }
  130. bool CanUseCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  133. }
  134. bool CanSelectCardCondition(CardSource cardSource)
  135. {
  136. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 5 &&
  137. cardSource.EqualsTraits("NSo") &&
  138. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  139. }
  140. IEnumerator ActivateCoroutine(Hashtable hashtable)
  141. {
  142. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  143. {
  144. List<CardSource> selectedCards = new List<CardSource>();
  145. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  146. selectHandEffect.SetUp(
  147. selectPlayer: card.Owner,
  148. canTargetCondition: CanSelectCardCondition,
  149. canTargetCondition_ByPreSelecetedList: null,
  150. canEndSelectCondition: null,
  151. maxCount: 1,
  152. canNoSelect: true,
  153. canEndNotMax: false,
  154. isShowOpponent: true,
  155. selectCardCoroutine: SelectCardCoroutine,
  156. afterSelectCardCoroutine: null,
  157. mode: SelectHandEffect.Mode.Custom,
  158. cardEffect: activateClass);
  159. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  160. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  161. yield return StartCoroutine(selectHandEffect.Activate());
  162. IEnumerator SelectCardCoroutine(CardSource cardSource)
  163. {
  164. selectedCards.Add(cardSource);
  165. yield return null;
  166. }
  167. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  168. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  169. root: SelectCardEffect.Root.Hand, activateETB: true));
  170. }
  171. }
  172. }
  173. #endregion
  174. return cardEffects;
  175. }
  176. }
  177. }