BT21_020.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //Aldamon
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. public class BT21_020 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Static Effects
  12. #region Reduced Digivolution Cost
  13. if (timing == EffectTiming.BeforePayCost)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Reduce the digivolution cost by 1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. => "When any of your Digimon with [Agunimon]/[BurningGreymon] in their digivolution cards would digivolve into this card in the hand, reduce the digivolution cost by 1.";
  21. bool PermanentEvoCondition(Permanent permanent)
  22. {
  23. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  24. {
  25. if (permanent.DigivolutionCards.Find(source =>
  26. (source.EqualsCardName("Agunimon") || source.EqualsCardName("BurningGreymon"))))
  27. {
  28. return card.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass);
  29. }
  30. }
  31. return false;
  32. }
  33. bool CardCondition(CardSource source)
  34. {
  35. if (source == card) return true;
  36. return false;
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. if (CardEffectCommons.IsExistOnHand(card))
  41. {
  42. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentEvoCondition))
  43. {
  44. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentEvoCondition, CardCondition))
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.IsExistOnHand(card);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. Hashtable hashtable = new Hashtable();
  59. hashtable.Add("CardEffect", activateClass);
  60. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  61. ChangeCostClass changeCostClass = new ChangeCostClass();
  62. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  63. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  64. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  65. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  66. bool CanUseCondition1(Hashtable hashtable)
  67. {
  68. return true;
  69. }
  70. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  71. {
  72. if (CardSourceCondition(cardSource))
  73. {
  74. if (RootCondition(root))
  75. {
  76. if (PermanentsCondition(targetPermanents))
  77. {
  78. Cost -= 1;
  79. }
  80. }
  81. }
  82. return Cost;
  83. }
  84. bool PermanentsCondition(List<Permanent> targetPermanents)
  85. {
  86. if (targetPermanents != null)
  87. {
  88. if (targetPermanents.Exists(PermanentCondition))
  89. {
  90. return true;
  91. }
  92. }
  93. return false;
  94. }
  95. bool PermanentCondition(Permanent targetPermanent)
  96. {
  97. if (targetPermanent.TopCard != null)
  98. {
  99. return PermanentEvoCondition(targetPermanent);
  100. }
  101. return false;
  102. }
  103. bool CardSourceCondition(CardSource cardSource)
  104. {
  105. if (cardSource != null)
  106. {
  107. return CardCondition(cardSource);
  108. }
  109. return false;
  110. }
  111. bool RootCondition(SelectCardEffect.Root root)
  112. {
  113. return true;
  114. }
  115. bool isUpDown()
  116. {
  117. return true;
  118. }
  119. }
  120. }
  121. #endregion
  122. #region Sec +1
  123. if (timing == EffectTiming.None)
  124. {
  125. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  126. changeValue: 1,
  127. isInheritedEffect: false,
  128. card: card,
  129. condition: null));
  130. }
  131. #endregion
  132. #endregion
  133. #region On Deletion / ESS Shared
  134. string OnDeletionEffectDiscription()
  135. {
  136. return "[On Deletion] You may play 1 red Tamer card with inherited effects from your hand or trash without paying the cost.";
  137. }
  138. bool CanUseOnDeletionCondition(Hashtable hashtable, ActivateClass activateClass)
  139. {
  140. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  141. }
  142. bool CanActivateOnDeletionCondition(Hashtable hashtable, ActivateClass activateClass)
  143. {
  144. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  145. {
  146. if (CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanSelectCard(cardSource, activateClass))
  147. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => CanSelectCard(cardSource, activateClass)))
  148. {
  149. return true;
  150. }
  151. }
  152. return false;
  153. }
  154. bool CanSelectCard(CardSource source, ActivateClass activateClass)
  155. {
  156. if (source.IsTamer)
  157. {
  158. if (source.HasCardColor(CardColor.Red))
  159. {
  160. if (source.HasInheritedEffect)
  161. {
  162. if (CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Hand) || CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Trash))
  163. {
  164. return true;
  165. }
  166. }
  167. }
  168. }
  169. return false;
  170. }
  171. IEnumerator OnDeletionActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  172. {
  173. CardSource selectedCard = null;
  174. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanSelectCard(cardSource, activateClass));
  175. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => CanSelectCard(cardSource, activateClass));
  176. if (canSelectHand || canSelectTrash)
  177. {
  178. if (canSelectHand && canSelectTrash)
  179. {
  180. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  181. {
  182. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  183. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  184. };
  185. string selectPlayerMessage = "From which area do you select a card?";
  186. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  187. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  188. }
  189. else
  190. {
  191. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  192. }
  193. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  194. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  195. if (fromHand)
  196. {
  197. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  198. selectHandEffect.SetUp(
  199. selectPlayer: card.Owner,
  200. canTargetCondition: cardSource => CanSelectCard(cardSource, activateClass),
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. maxCount: 1,
  204. canNoSelect: true,
  205. canEndNotMax: false,
  206. isShowOpponent: true,
  207. selectCardCoroutine: SelectCardCoroutine,
  208. afterSelectCardCoroutine: null,
  209. mode: SelectHandEffect.Mode.Custom,
  210. cardEffect: activateClass);
  211. selectHandEffect.SetUpCustomMessage("Select 1 tamer.", "The opponent is selecting 1 tamer.");
  212. yield return StartCoroutine(selectHandEffect.Activate());
  213. }
  214. else
  215. {
  216. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  217. selectCardEffect.SetUp(
  218. canTargetCondition: cardSource => CanSelectCard(cardSource, activateClass),
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. canNoSelect: () => true,
  222. selectCardCoroutine: SelectCardCoroutine,
  223. afterSelectCardCoroutine: null,
  224. message: "Select 1 tamer.",
  225. maxCount: 1,
  226. canEndNotMax: false,
  227. isShowOpponent: true,
  228. mode: SelectCardEffect.Mode.Custom,
  229. root: SelectCardEffect.Root.Trash,
  230. customRootCardList: null,
  231. canLookReverseCard: true,
  232. selectPlayer: card.Owner,
  233. cardEffect: activateClass);
  234. selectCardEffect.SetUpCustomMessage("Select 1 tamer.", "The opponent is selecting 1 tamer.");
  235. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  236. }
  237. IEnumerator SelectCardCoroutine(CardSource cardSource)
  238. {
  239. selectedCard = cardSource;
  240. yield return null;
  241. }
  242. if (selectedCard != null)
  243. {
  244. if (fromHand)
  245. {
  246. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  247. cardSources: new List<CardSource>() { selectedCard },
  248. activateClass: activateClass,
  249. payCost: false,
  250. isTapped: false,
  251. root: SelectCardEffect.Root.Hand,
  252. activateETB: true));
  253. }
  254. else
  255. {
  256. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  257. cardSources: new List<CardSource>() { selectedCard },
  258. activateClass: activateClass,
  259. payCost: false,
  260. isTapped: false,
  261. root: SelectCardEffect.Root.Trash,
  262. activateETB: true));
  263. }
  264. }
  265. }
  266. }
  267. #endregion
  268. #region On Deletion
  269. if (timing == EffectTiming.OnDestroyedAnyone)
  270. {
  271. ActivateClass activateClass = new ActivateClass();
  272. activateClass.SetUpICardEffect("Play a Red tamer from hand or trash", hash => CanUseOnDeletionCondition(hash, activateClass), card);
  273. activateClass.SetUpActivateClass(hash => CanActivateOnDeletionCondition(hash, activateClass), hash => OnDeletionActivateCoroutine(hash, activateClass), -1, true, OnDeletionEffectDiscription());
  274. cardEffects.Add(activateClass);
  275. }
  276. #endregion
  277. #region On Deletion - ESS
  278. if (timing == EffectTiming.OnDestroyedAnyone)
  279. {
  280. ActivateClass activateClass = new ActivateClass();
  281. activateClass.SetUpICardEffect("Play a Red tamer from hand or trash", hash => CanUseOnDeletionCondition(hash, activateClass), card);
  282. activateClass.SetUpActivateClass(hash => CanActivateOnDeletionCondition(hash, activateClass), hash => OnDeletionActivateCoroutine(hash, activateClass), -1, true, OnDeletionEffectDiscription());
  283. activateClass.SetIsInheritedEffect(true);
  284. cardEffects.Add(activateClass);
  285. }
  286. #endregion
  287. return cardEffects;
  288. }
  289. }
  290. }