BT20_013.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using DG.Tweening.Core.Easing;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine.TextCore.Text;
  7. namespace DCGO.CardEffects.BT20
  8. {
  9. public class BT20_013 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Main Once Per Turn
  15. if (timing == EffectTiming.OnDeclaration)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("Play a Digimon with the cost reduced by 2", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  20. activateClass.SetHashString("PlayCost_BT20_013");
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription ()
  23. {
  24. return "[Main] [Once Per Turn] You may play 1 Digimon card with [Sistermon] or [Gankoomon] in its name from you hand with the play cost reduced by 2.";
  25. }
  26. bool CanUseCondition (Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  29. {
  30. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanSelectCardCondition (CardSource cardSource)
  38. {
  39. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  40. {
  41. if (cardSource.ContainsCardName("Sistermon") || cardSource.ContainsCardName("Gankoomon"))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. IEnumerator ActivateCoroutine (Hashtable _hashtable)
  49. {
  50. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  51. {
  52. new SelectionElement<bool>(message: $"Play Card", value : true, spriteIndex: 0),
  53. new SelectionElement<bool>(message: $"Not Play Card", value : false, spriteIndex: 1),
  54. };
  55. string selectPlayerMessage = "Will you play a card from your hand?";
  56. string notSelectPlayerMessage = "The opponent is deciding to play a card from their hand.";
  57. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  58. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  59. bool isPlaying = GManager.instance.userSelectionManager.SelectedBoolValue;
  60. if (isPlaying)
  61. {
  62. #region reduce play cost
  63. ChangeCostClass changeCostClass = new ChangeCostClass();
  64. changeCostClass.SetUpICardEffect($"Play Cost -2", CanUseCondition1, card);
  65. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  66. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  67. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  68. ICardEffect GetCardEffect(EffectTiming _timing)
  69. {
  70. if (_timing == EffectTiming.None)
  71. {
  72. return changeCostClass;
  73. }
  74. return null;
  75. }
  76. bool CanUseCondition1(Hashtable hashtable)
  77. {
  78. return true;
  79. }
  80. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  81. {
  82. if (CardSourceCondition(cardSource))
  83. {
  84. if (RootCondition(root))
  85. {
  86. if (PermanentsCondition(targetPermanents))
  87. {
  88. Cost -= 2;
  89. }
  90. }
  91. }
  92. return Cost;
  93. }
  94. bool PermanentsCondition(List<Permanent> targetPermanents)
  95. {
  96. if (targetPermanents == null)
  97. {
  98. return true;
  99. }
  100. else
  101. {
  102. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  103. {
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. bool CardSourceCondition(CardSource cardSource)
  110. {
  111. if (CanSelectCardCondition(cardSource))
  112. {
  113. return true;
  114. }
  115. return false;
  116. }
  117. bool RootCondition(SelectCardEffect.Root root)
  118. {
  119. return true;
  120. }
  121. bool isUpDown()
  122. {
  123. return true;
  124. }
  125. #endregion
  126. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  127. {
  128. List<CardSource> selectedCards = new List<CardSource>();
  129. int maxCount = 1;
  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: maxCount,
  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 ContinuousController.instance.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,
  154. activateClass: activateClass,
  155. payCost: true,
  156. isTapped: false,
  157. root: SelectCardEffect.Root.Hand,
  158. activateETB: true));
  159. }
  160. #region Remove Cost effect after use
  161. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  162. #endregion
  163. }
  164. }
  165. }
  166. #endregion
  167. #region ESS
  168. if (timing == EffectTiming.None)
  169. {
  170. bool Condition()
  171. {
  172. if (CardEffectCommons.IsExistOnBattleArea(card))
  173. {
  174. if (CardEffectCommons.IsOwnerTurn(card))
  175. {
  176. return true;
  177. }
  178. }
  179. return false;
  180. }
  181. bool PermanentCondition(Permanent permanent)
  182. {
  183. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  184. {
  185. return true;
  186. }
  187. return false;
  188. }
  189. cardEffects.Add(CardEffectFactory.ChangeDPStaticEffect(
  190. permanentCondition: PermanentCondition,
  191. changeValue: 1000,
  192. isInheritedEffect: true,
  193. card: card,
  194. condition: Condition,
  195. effectName: () => "Your Digimon gain DP +1000"));
  196. }
  197. #endregion
  198. return cardEffects;
  199. }
  200. }
  201. }