BT13_050.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_050 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnDeclaration)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Your Digimon digivolves", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Main] By suspending this Digimon, 1 of your Digimon may digivolve into a Digimon card with [Fairy] in one of its traits in the hand for the digivolution cost. When it would digivolve by this effect, reduce the digivolution cost by 2.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  25. {
  26. foreach (CardSource cardSource in card.Owner.HandCards)
  27. {
  28. if (CanSelectCardCondition(cardSource))
  29. {
  30. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanSelectCardCondition(CardSource cardSource)
  40. {
  41. return cardSource.IsDigimon && cardSource.HasFairyTraits;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. Permanent selectedPermanent = null;
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: true,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  77. {
  78. selectedPermanent = permanent;
  79. yield return null;
  80. }
  81. if (selectedPermanent != null)
  82. {
  83. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  84. targetPermanent: selectedPermanent,
  85. cardCondition: CanSelectCardCondition,
  86. payCost: true,
  87. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  88. fixedCostTuple: null,
  89. ignoreDigivolutionRequirementFixedCost: -1,
  90. isHand: true,
  91. activateClass: activateClass,
  92. successProcess: null));
  93. }
  94. }
  95. }
  96. }
  97. ActivateClass activateClass2 = new ActivateClass();
  98. activateClass2.SetUpICardEffect("Digivolution Cost -1", CanUseCondition2, card);
  99. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, false, EffectDiscription2());
  100. activateClass2.SetIsInheritedEffect(true);
  101. activateClass2.SetNotShowUI(true);
  102. activateClass2.SetIsBackgroundProcess(true);
  103. activateClass2.SetHashString("DigivolutionCost-1_BT13_050");
  104. string EffectDiscription2()
  105. {
  106. return "";
  107. }
  108. bool CanUseCondition2(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.IsExistOnBattleArea(card))
  111. {
  112. if (CardEffectCommons.IsOwnerTurn(card))
  113. {
  114. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  115. {
  116. List<CardSource> evoRootTops = CardEffectCommons.GetEvoRootTopsFromEnterFieldHashtable(
  117. hashtable,
  118. permanent => permanent.cardSources.Contains(card));
  119. if (evoRootTops != null)
  120. {
  121. if (!evoRootTops.Contains(card))
  122. {
  123. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) =>
  124. permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  125. {
  126. return true;
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. return false;
  134. }
  135. bool CanActivateCondition2(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleArea(card);
  138. }
  139. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  140. {
  141. yield return null;
  142. }
  143. if (timing == EffectTiming.OnEnterFieldAnyone)
  144. {
  145. cardEffects.Add(activateClass2);
  146. }
  147. if (timing == EffectTiming.None)
  148. {
  149. ChangeCostClass changeCostClass = new ChangeCostClass();
  150. changeCostClass.SetUpICardEffect($"Digivolution Cost -1", CanUseCondition, card);
  151. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  152. changeCostClass.SetIsInheritedEffect(true);
  153. cardEffects.Add(changeCostClass);
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. if (CardEffectCommons.IsExistOnBattleArea(card))
  157. {
  158. if (CardEffectCommons.IsOwnerTurn(card))
  159. {
  160. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  161. {
  162. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) =>
  163. permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  164. {
  165. return true;
  166. }
  167. }
  168. }
  169. }
  170. return false;
  171. }
  172. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  173. {
  174. if (CardSourceCondition(cardSource))
  175. {
  176. if (RootCondition(root))
  177. {
  178. if (PermanentsCondition(targetPermanents))
  179. {
  180. Cost -= 1;
  181. }
  182. }
  183. }
  184. return Cost;
  185. }
  186. bool PermanentsCondition(List<Permanent> targetPermanents)
  187. {
  188. if (targetPermanents != null)
  189. {
  190. if (targetPermanents.Count(PermanentCondition) >= 1)
  191. {
  192. return true;
  193. }
  194. }
  195. return false;
  196. }
  197. bool PermanentCondition(Permanent targetPermanent)
  198. {
  199. return targetPermanent == card.PermanentOfThisCard();
  200. }
  201. bool CardSourceCondition(CardSource cardSource)
  202. {
  203. return cardSource.Owner == card.Owner;
  204. }
  205. bool RootCondition(SelectCardEffect.Root root)
  206. {
  207. return true;
  208. }
  209. bool isUpDown()
  210. {
  211. return true;
  212. }
  213. }
  214. return cardEffects;
  215. }
  216. }
  217. }