ST17_02.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.ST17
  9. {
  10. public class ST17_02 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Alternate Digivolution Condition
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return targetPermanent.TopCard.CardNames.Contains("Gummymon");
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Main
  26. if (timing == EffectTiming.OnDeclaration)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Play 1 Digimon/Tamer from hand", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, true, EffectDiscription());
  31. activateClass.SetHashString("PlayReduce_ST17_02");
  32. cardEffects.Add(activateClass);
  33. string EffectDiscription()
  34. {
  35. return "[Main] [Once Per Turn] You may play 1 green Tamer card or 1 level 3 Digimon card with [Lopmon] in its name from your hand with the play cost reduced by 2.";
  36. }
  37. bool CanSelectCardCondition(CardSource cardSource)
  38. {
  39. if (cardSource.IsDigimon)
  40. {
  41. if (cardSource.Level == 3)
  42. {
  43. if (cardSource.ContainsCardName("Lopmon"))
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. if (cardSource.IsTamer)
  50. {
  51. if (cardSource.HasCardColor(CardColor.Green))
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. #region reduce play cost
  72. ChangeCostClass changeCostClass = new ChangeCostClass();
  73. changeCostClass.SetUpICardEffect($"Play Cost -2", CanUseCondition1, card);
  74. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CanSelectCardCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  75. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  76. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  77. ICardEffect GetCardEffect(EffectTiming _timing)
  78. {
  79. if (_timing == EffectTiming.None)
  80. {
  81. return changeCostClass;
  82. }
  83. return null;
  84. }
  85. bool CanUseCondition1(Hashtable hashtable)
  86. {
  87. return true;
  88. }
  89. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  90. {
  91. if (CanSelectCardCondition(cardSource))
  92. {
  93. if (RootCondition(root))
  94. {
  95. if (PermanentsCondition(targetPermanents))
  96. {
  97. Cost -= 2;
  98. }
  99. }
  100. }
  101. return Cost;
  102. }
  103. bool PermanentsCondition(List<Permanent> targetPermanents)
  104. {
  105. if (targetPermanents == null)
  106. {
  107. return true;
  108. }
  109. else
  110. {
  111. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. bool RootCondition(SelectCardEffect.Root root)
  119. {
  120. return true;
  121. }
  122. bool isUpDown()
  123. {
  124. return true;
  125. }
  126. #endregion
  127. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  128. {
  129. List<CardSource> selectedCards = new List<CardSource>();
  130. int maxCount = 1;
  131. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  132. selectHandEffect.SetUp(
  133. selectPlayer: card.Owner,
  134. canTargetCondition: CanSelectCardCondition,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. maxCount: maxCount,
  138. canNoSelect: true,
  139. canEndNotMax: false,
  140. isShowOpponent: true,
  141. selectCardCoroutine: SelectCardCoroutine,
  142. afterSelectCardCoroutine: null,
  143. mode: SelectHandEffect.Mode.Custom,
  144. cardEffect: activateClass);
  145. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  146. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  147. yield return StartCoroutine(selectHandEffect.Activate());
  148. IEnumerator SelectCardCoroutine(CardSource cardSource)
  149. {
  150. selectedCards.Add(cardSource);
  151. yield return null;
  152. }
  153. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  154. cardSources: selectedCards,
  155. activateClass: activateClass,
  156. payCost: true,
  157. isTapped: false,
  158. root: SelectCardEffect.Root.Hand,
  159. activateETB: true));
  160. }
  161. #region Remove Cost effect after use
  162. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  163. #endregion
  164. }
  165. }
  166. #endregion
  167. #region Inherit
  168. if (timing == EffectTiming.None)
  169. {
  170. bool Condition()
  171. {
  172. if (CardEffectCommons.IsExistOnBattleArea(card))
  173. {
  174. if (card.PermanentOfThisCard().IsSuspended)
  175. {
  176. return true;
  177. }
  178. }
  179. return false;
  180. }
  181. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 1000, isInheritedEffect: true, card: card, condition: Condition));
  182. }
  183. #endregion
  184. return cardEffects;
  185. }
  186. }
  187. }