EX8_068.cs 8.3 KB

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