BT14_044.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_044 : 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.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Opponent's 1 Digimon gains effect", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Start of Your Main Phase] 1 of your opponent's Digimon gains \"[All Turns] When this Digimon becomes suspended, lose 2 memory.\" until the end of their turn.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleArea(card))
  29. {
  30. if (CardEffectCommons.IsOwnerTurn(card))
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. if (CardEffectCommons.IsExistOnBattleArea(card))
  40. {
  41. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  49. {
  50. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  51. {
  52. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  53. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  54. selectPermanentEffect.SetUp(
  55. selectPlayer: card.Owner,
  56. canTargetCondition: CanSelectPermanentCondition,
  57. canTargetCondition_ByPreSelecetedList: null,
  58. canEndSelectCondition: null,
  59. maxCount: maxCount,
  60. canNoSelect: false,
  61. canEndNotMax: false,
  62. selectPermanentCoroutine: SelectPermanentCoroutine,
  63. afterSelectPermanentCoroutine: null,
  64. mode: SelectPermanentEffect.Mode.Custom,
  65. cardEffect: activateClass);
  66. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  67. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  68. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  69. {
  70. Permanent selectedPermanent = permanent;
  71. if (selectedPermanent != null)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  74. }
  75. if (selectedPermanent != null)
  76. {
  77. ActivateClass activateClass1 = new ActivateClass();
  78. activateClass1.SetUpICardEffect("Memory -2", CanUseCondition2, selectedPermanent.TopCard);
  79. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  80. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  81. CardEffectCommons.AddEffectToPermanent(
  82. targetPermanent: selectedPermanent,
  83. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  84. card: card,
  85. cardEffect: activateClass1,
  86. timing: EffectTiming.OnTappedAnyone);
  87. CardEffectCommons.AddEffectToPermanent(
  88. targetPermanent: selectedPermanent,
  89. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  90. card: card,
  91. cardEffect: PermanentEffectFactory.AddDetailClass(selectedPermanent, "[All Turns] When this Digimon becomes suspended, lose 2 memory.", true, activateClass),
  92. timing: EffectTiming.None);
  93. string EffectDiscription1()
  94. {
  95. return "[All Turns] When this Digimon becomes suspended, lose 2 memory.";
  96. }
  97. bool CanUseCondition2(Hashtable hashtable1)
  98. {
  99. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  100. {
  101. if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable1, (permanent) => permanent == selectedPermanent))
  102. {
  103. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  104. {
  105. return true;
  106. }
  107. }
  108. }
  109. return false;
  110. }
  111. bool CanActivateCondition1(Hashtable hashtable1)
  112. {
  113. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  114. {
  115. return true;
  116. }
  117. return false;
  118. }
  119. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  120. {
  121. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.TopCard.Owner.AddMemory(-2, activateClass));
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. ActivateClass activateClass2 = new ActivateClass();
  129. activateClass2.SetUpICardEffect("Digivolution Cost -1", CanUseCondition2, card);
  130. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, false, EffectDiscription2());
  131. activateClass2.SetIsInheritedEffect(true);
  132. activateClass2.SetNotShowUI(true);
  133. activateClass2.SetIsBackgroundProcess(true);
  134. activateClass2.SetHashString("DigivolutionCost-1_BT14_044");
  135. string EffectDiscription2()
  136. {
  137. return "";
  138. }
  139. bool CanUseCondition2(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.IsExistOnBattleArea(card))
  142. {
  143. if (CardEffectCommons.IsOwnerTurn(card))
  144. {
  145. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  146. {
  147. List<CardSource> evoRootTops = CardEffectCommons.GetEvoRootTopsFromEnterFieldHashtable(
  148. hashtable,
  149. permanent => permanent.cardSources.Contains(card));
  150. if (evoRootTops != null)
  151. {
  152. if (!evoRootTops.Contains(card))
  153. {
  154. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) =>
  155. permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  156. {
  157. return true;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. return false;
  165. }
  166. bool CanActivateCondition2(Hashtable hashtable)
  167. {
  168. return CardEffectCommons.IsExistOnBattleArea(card);
  169. }
  170. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  171. {
  172. yield return null;
  173. }
  174. if (timing == EffectTiming.OnEnterFieldAnyone)
  175. {
  176. cardEffects.Add(activateClass2);
  177. }
  178. if (timing == EffectTiming.None)
  179. {
  180. ChangeCostClass changeCostClass = new ChangeCostClass();
  181. changeCostClass.SetUpICardEffect($"Digivolution Cost -1", CanUseCondition, card);
  182. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  183. changeCostClass.SetIsInheritedEffect(true);
  184. cardEffects.Add(changeCostClass);
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. if (CardEffectCommons.IsExistOnBattleArea(card))
  188. {
  189. if (CardEffectCommons.IsOwnerTurn(card))
  190. {
  191. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  192. {
  193. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) =>
  194. permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  195. {
  196. return true;
  197. }
  198. }
  199. }
  200. }
  201. return false;
  202. }
  203. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  204. {
  205. if (CardSourceCondition(cardSource))
  206. {
  207. if (RootCondition(root))
  208. {
  209. if (PermanentsCondition(targetPermanents))
  210. {
  211. Cost -= 1;
  212. }
  213. }
  214. }
  215. return Cost;
  216. }
  217. bool PermanentsCondition(List<Permanent> targetPermanents)
  218. {
  219. if (targetPermanents != null)
  220. {
  221. if (targetPermanents.Count(PermanentCondition) >= 1)
  222. {
  223. return true;
  224. }
  225. }
  226. return false;
  227. }
  228. bool PermanentCondition(Permanent targetPermanent)
  229. {
  230. return targetPermanent == card.PermanentOfThisCard();
  231. }
  232. bool CardSourceCondition(CardSource cardSource)
  233. {
  234. return cardSource.Owner == card.Owner;
  235. }
  236. bool RootCondition(SelectCardEffect.Root root)
  237. {
  238. return true;
  239. }
  240. bool isUpDown()
  241. {
  242. return true;
  243. }
  244. }
  245. return cardEffects;
  246. }
  247. }
  248. }