EX12_043.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Hakubamon
  5. namespace DCGO.CardEffects.EX12
  6. {
  7. public class EX12_043 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasText("Shambala");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 2,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null,
  25. level: 3)
  26. );
  27. }
  28. #endregion
  29. #region Main
  30. if (timing == EffectTiming.OnDeclaration)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("May play/use 1 card with [SW] trait from hand for 2 less", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDescription());
  35. activateClass.SetHashString("EX12_043_Main");
  36. cardEffects.Add(activateClass);
  37. string EffectDescription()
  38. => "[Main] [Once Per Turn] You may play or use 1 card with the [SW] trait from your hand with the cost reduced by 2.";
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleArea(card)
  42. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  43. }
  44. bool CanSelectCardCondition(CardSource cardSource)
  45. {
  46. return cardSource.EqualsTraits("SW")
  47. && ((cardSource.IsOption
  48. && !cardSource.CanNotPlayThisOption)
  49. || (cardSource.HasPlayCost
  50. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass, fixedCost: cardSource.GetCostItself - 2)));
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable hashtable)
  53. {
  54. bool isUsed = false;
  55. CardSource selectedCard = null;
  56. #region Selected card in hand to play/use
  57. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  58. selectHandEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: CanSelectCardCondition,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: 1,
  64. canNoSelect: true,
  65. canEndNotMax: false,
  66. isShowOpponent: true,
  67. selectCardCoroutine: SelectCardCoroutine,
  68. afterSelectCardCoroutine: null,
  69. mode: SelectHandEffect.Mode.Custom,
  70. cardEffect: activateClass);
  71. IEnumerator SelectCardCoroutine(CardSource cardSource)
  72. {
  73. selectedCard = cardSource;
  74. yield return null;
  75. }
  76. selectHandEffect.SetUpCustomMessage("Select 1 card to play/use.", "The opponent is selecting 1 card to play/use.");
  77. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  78. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  79. #endregion
  80. if (selectedCard != null)
  81. {
  82. isUsed = true;
  83. #region Reduce Cost
  84. IEnumerator ReduceCost(string type)
  85. {
  86. if (card.Owner.CanReduceCost(null, card))
  87. {
  88. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  89. }
  90. Hashtable hashtable = new Hashtable
  91. {
  92. { "CardEffect", activateClass }
  93. };
  94. ChangeCostClass changeCostClass = new ChangeCostClass();
  95. changeCostClass.SetUpICardEffect($"{type} cost: -2", CanUseCondition1, card);
  96. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  97. card.Owner.UntilCalculateFixedCostEffect.Add(_ => changeCostClass);
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  99. bool CanUseCondition1(Hashtable hashtable)
  100. {
  101. return true;
  102. }
  103. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  104. {
  105. if (CardSourceCondition(cardSource) &&
  106. RootCondition(root) &&
  107. PermanentsCondition(targetPermanents))
  108. {
  109. cost -= 2;
  110. }
  111. return cost;
  112. }
  113. bool PermanentsCondition(List<Permanent> targetPermanents)
  114. {
  115. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  116. }
  117. bool CardSourceCondition(CardSource cardSource)
  118. {
  119. return cardSource != null
  120. && cardSource.Owner == card.Owner;
  121. }
  122. bool RootCondition(SelectCardEffect.Root root)
  123. {
  124. return true;
  125. }
  126. bool isUpDown()
  127. {
  128. return true;
  129. }
  130. }
  131. #endregion
  132. if (selectedCard.IsOption)
  133. {
  134. yield return ContinuousController.instance.StartCoroutine(ReduceCost("Use"));
  135. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayOptionCards(
  136. cardSources: new List<CardSource>() { selectedCard },
  137. activateClass: activateClass,
  138. payCost: true,
  139. root: SelectCardEffect.Root.Hand));
  140. }
  141. else
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(ReduceCost("Play"));
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  145. cardSources: new List<CardSource>() { selectedCard },
  146. activateClass: activateClass,
  147. payCost: true,
  148. isTapped: false,
  149. root: SelectCardEffect.Root.Hand,
  150. activateETB: true));
  151. }
  152. }
  153. if (!isUsed) activateClass.RemoveUse();
  154. }
  155. }
  156. #endregion
  157. #region Inherited Barrier
  158. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  159. {
  160. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: true, card: card, condition: null));
  161. }
  162. #endregion
  163. return cardEffects;
  164. }
  165. }
  166. }