BT20_099.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT20
  6. {
  7. public class BT20_099 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirements
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool IgnoreColorConditions(Permanent permanent)
  20. {
  21. return permanent.TopCard.ContainsCardName("Chaosmon") || permanent.TopCard.EqualsTraits("ACCEL");
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, IgnoreColorConditions);
  26. }
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. return cardSource == card;
  30. }
  31. }
  32. #endregion
  33. #region Main
  34. if (timing == EffectTiming.OptionSkill)
  35. {
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  38. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  39. cardEffects.Add(activateClass);
  40. string EffectDiscription()
  41. {
  42. return "[Main] You may play 1 Digimon card with the [ACCEL] trait with the play cost reduced by 4. Then, place this card as any of your Digimon's bottom digivolution cards.";
  43. }
  44. bool CanSelectCardCondition(CardSource cardSource)
  45. {
  46. if (cardSource.IsDigimon)
  47. {
  48. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass))
  49. {
  50. return cardSource.EqualsTraits("ACCEL");
  51. }
  52. }
  53. return false;
  54. }
  55. bool CanSelectPermanentCondition(Permanent permanent)
  56. {
  57. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. #region Change Cost
  66. ChangeCostClass changeCostClass = new ChangeCostClass();
  67. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  68. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  69. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  70. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  71. ICardEffect GetCardEffect(EffectTiming _timing)
  72. {
  73. if (_timing == EffectTiming.None)
  74. {
  75. return changeCostClass;
  76. }
  77. return null;
  78. }
  79. bool CanUseCondition1(Hashtable hashtable)
  80. {
  81. return true;
  82. }
  83. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  84. {
  85. if (CardSourceCondition(cardSource))
  86. {
  87. if (RootCondition(root))
  88. {
  89. if (PermanentsCondition(targetPermanents))
  90. {
  91. Cost -= 4;
  92. }
  93. }
  94. }
  95. return Cost;
  96. }
  97. bool PermanentsCondition(List<Permanent> targetPermanents)
  98. {
  99. if (targetPermanents == null)
  100. {
  101. return true;
  102. }
  103. else
  104. {
  105. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  106. {
  107. return true;
  108. }
  109. }
  110. return false;
  111. }
  112. bool CardSourceCondition(CardSource cardSource)
  113. {
  114. if (cardSource != null)
  115. {
  116. if (cardSource.Owner == card.Owner)
  117. {
  118. if (cardSource.IsDigimon)
  119. {
  120. if (cardSource.EqualsTraits("ACCEL"))
  121. {
  122. return true;
  123. }
  124. }
  125. }
  126. }
  127. return false;
  128. }
  129. bool RootCondition(SelectCardEffect.Root root)
  130. {
  131. return true;
  132. }
  133. bool isUpDown()
  134. {
  135. return true;
  136. }
  137. #endregion
  138. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  139. {
  140. List<CardSource> selectedCards = new List<CardSource>();
  141. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  142. selectHandEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: CanSelectCardCondition,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: 1,
  148. canNoSelect: true,
  149. canEndNotMax: false,
  150. isShowOpponent: true,
  151. selectCardCoroutine: SelectCardCoroutine,
  152. afterSelectCardCoroutine: null,
  153. mode: SelectHandEffect.Mode.Custom,
  154. cardEffect: activateClass);
  155. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  156. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  157. yield return StartCoroutine(selectHandEffect.Activate());
  158. IEnumerator SelectCardCoroutine(CardSource cardSource)
  159. {
  160. selectedCards.Add(cardSource);
  161. yield return null;
  162. }
  163. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: true, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  164. }
  165. #region End Change Cost
  166. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  167. #endregion
  168. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  169. {
  170. Permanent selectedPermanent = null;
  171. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  172. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  173. selectPermanentEffect.SetUp(
  174. selectPlayer: card.Owner,
  175. canTargetCondition: CanSelectPermanentCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. maxCount: maxCount,
  179. canNoSelect: false,
  180. canEndNotMax: false,
  181. selectPermanentCoroutine: SelectPermanentCoroutine,
  182. afterSelectPermanentCoroutine: null,
  183. mode: SelectPermanentEffect.Mode.Custom,
  184. cardEffect: activateClass);
  185. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  186. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  187. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  188. {
  189. selectedPermanent = permanent;
  190. yield return null;
  191. }
  192. if (selectedPermanent != null && !selectedPermanent.IsToken)
  193. {
  194. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  195. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  196. }
  197. }
  198. }
  199. }
  200. #endregion
  201. #region Security Effect
  202. if (timing == EffectTiming.SecuritySkill)
  203. {
  204. ActivateClass activateClass = new ActivateClass();
  205. activateClass.SetUpICardEffect($"Memory +1 and add this card to hand", CanUseCondition, card);
  206. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  207. activateClass.SetIsSecurityEffect(true);
  208. cardEffects.Add(activateClass);
  209. string EffectDiscription()
  210. {
  211. return "[Security] Gain 1 memory and add this card to the hand.";
  212. }
  213. bool CanUseCondition(Hashtable hashtable)
  214. {
  215. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  216. }
  217. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  218. {
  219. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  221. }
  222. }
  223. #endregion
  224. #region End of Opponent's Turn
  225. if (timing == EffectTiming.OnEndTurn)
  226. {
  227. ActivateClass activateClass = new ActivateClass();
  228. activateClass.SetUpICardEffect("Trash opponent's top security, this Digimon get -30000 DP", CanUseCondition, card);
  229. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  230. activateClass.SetIsInheritedEffect(true);
  231. cardEffects.Add(activateClass);
  232. string EffectDiscription()
  233. {
  234. return "[End of Opponent's Turn] If this Digimon has [Chaosmon] in its name, trash your opponent's top security card and this Digimon gets -30000 DP for the turn.";
  235. }
  236. bool CanUseCondition(Hashtable hashtable)
  237. {
  238. return CardEffectCommons.IsOpponentTurn(card);
  239. }
  240. bool CanActivateCondition(Hashtable hashtable)
  241. {
  242. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  243. card.PermanentOfThisCard().TopCard.ContainsCardName("Chaosmon");
  244. }
  245. IEnumerator ActivateCoroutine(Hashtable hashtable)
  246. {
  247. if(card.Owner.Enemy.SecurityCards.Count > 0)
  248. {
  249. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  250. player: card.Owner.Enemy,
  251. destroySecurityCount: 1,
  252. cardEffect: activateClass,
  253. fromTop: true).DestroySecurity());
  254. }
  255. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: -30000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  256. }
  257. }
  258. #endregion
  259. return cardEffects;
  260. }
  261. }
  262. }