P_181.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Royal Base
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_181 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Your Turn Face Up Security
  12. if (timing == EffectTiming.BeforePayCost)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Reduce Digivolve Cost", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  17. activateClass.SetHashString("P-181-ReduceDigivovleCost");
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. => "[Security] [Your Turn] [Once Per Turn] When any of your Digimon would digivolve into a Digimon card with the [Royal Base] trait, reduce the digivolution cost by 1.";
  21. bool CanUseCondition(Hashtable hashtable)
  22. {
  23. return CardEffectCommons.IsExistInSecurity(card, false) &&
  24. CardEffectCommons.IsOwnerTurn(card) &&
  25. CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, DigivolveTargetCondition, DigivolveCondition);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistInSecurity(card, false);
  30. }
  31. bool DigivolveTargetCondition(Permanent permanent)
  32. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  33. bool DigivolveCondition(CardSource source)
  34. => source.IsDigimon
  35. && source.HasRoyalBaseTraits;
  36. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  37. {
  38. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  39. ChangeCostClass changeCostClass = new ChangeCostClass();
  40. changeCostClass.SetUpICardEffect("Digivolve Cost -1", hashtable => true, card);
  41. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: root => true, isUpDown: () => true, isCheckAvailability: () => false, isChangePayingCost: () => true);
  42. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  43. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  44. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  45. {
  46. if (CardSourceCondition(cardSource))
  47. {
  48. if (PermanentsCondition(targetPermanents))
  49. {
  50. Cost -= 1;
  51. }
  52. }
  53. return Cost;
  54. }
  55. bool PermanentsCondition(List<Permanent> targetPermanents)
  56. => targetPermanents != null;
  57. bool CardSourceCondition(CardSource cardSource)
  58. {
  59. if (cardSource != null)
  60. {
  61. return cardSource.Owner == card.Owner &&
  62. cardSource.HasRoyalBaseTraits;
  63. }
  64. return false;
  65. }
  66. }
  67. }
  68. #endregion
  69. #region Main Effect
  70. if (timing == EffectTiming.OptionSkill)
  71. {
  72. ActivateClass activateClass = new ActivateClass();
  73. activateClass.SetUpICardEffect("Add top sec to hand, send this to bottom sec", CanUseCondition, card);
  74. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  75. cardEffects.Add(activateClass);
  76. string EffectDescription()
  77. {
  78. return "[Main] Add your top security card to the hand. Then, place this card face up as the bottom security card.";
  79. }
  80. bool CanUseCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  83. }
  84. IEnumerator ActivateCoroutine(Hashtable hashtable)
  85. {
  86. if (card.Owner.SecurityCards.Count >= 1)
  87. {
  88. // Add your top security card to the hand
  89. CardSource topSecCard = card.Owner.SecurityCards[0];
  90. yield return ContinuousController.instance.StartCoroutine(
  91. CardObjectController.AddHandCards(new List<CardSource>() { topSecCard }, false, activateClass));
  92. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  93. player: card.Owner,
  94. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  95. activateClass).ReduceSecurity());
  96. }
  97. // Place this card face up as the bottom security card
  98. if (card.Owner.CanAddSecurity(activateClass))
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(
  101. card, toTop: false, faceUp: true));
  102. }
  103. }
  104. }
  105. #endregion
  106. #region Security Effect
  107. if (timing == EffectTiming.SecuritySkill)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect($"Play 1 [Royal Base] Digimon card from hand", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  112. activateClass.SetIsSecurityEffect(true);
  113. cardEffects.Add(activateClass);
  114. string EffectDescription()
  115. {
  116. return
  117. "[Security] You may play 1 level 5 or lower [Royal Base] trait Digimon card from your hand without paying the cost.";
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  122. }
  123. bool CanSelectCardCondition(CardSource cardSource)
  124. {
  125. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 5 &&
  126. cardSource.HasRoyalBaseTraits &&
  127. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  128. }
  129. IEnumerator ActivateCoroutine(Hashtable hashtable)
  130. {
  131. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  132. {
  133. List<CardSource> selectedCards = new List<CardSource>();
  134. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  135. selectHandEffect.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: CanSelectCardCondition,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. maxCount: 1,
  141. canNoSelect: true,
  142. canEndNotMax: false,
  143. isShowOpponent: true,
  144. selectCardCoroutine: SelectCardCoroutine,
  145. afterSelectCardCoroutine: null,
  146. mode: SelectHandEffect.Mode.Custom,
  147. cardEffect: activateClass);
  148. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  149. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  150. yield return StartCoroutine(selectHandEffect.Activate());
  151. IEnumerator SelectCardCoroutine(CardSource cardSource)
  152. {
  153. selectedCards.Add(cardSource);
  154. yield return null;
  155. }
  156. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  157. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  158. root: SelectCardEffect.Root.Hand, activateETB: true));
  159. }
  160. }
  161. }
  162. #endregion
  163. return cardEffects;
  164. }
  165. }
  166. }