BT16_074.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_074 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolve Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasText("Pulsemon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region When Digivolving
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Draw 2 and trash 1 card and/or play a Digimon", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[When Digivolving] If you have 3 or more security cards, <Draw 2>. Then trash 1 card in your hand. If you have 3 or fewer security cards, you may play 1 Digimon with 6000 DP or less and [Pulsemon] in its text from your trash without paying the cost. At the next time your opponent's turn ends, delete that Digimon.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  35. }
  36. bool CanSelectCardCondition(CardSource card)
  37. {
  38. if (card.HasText("Pulsemon") && card.IsDigimon && card.CardDP <= 6000)
  39. {
  40. return true;
  41. }
  42. return false;
  43. }
  44. bool PermanentCondition(Permanent permanent)
  45. {
  46. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  47. {
  48. return true;
  49. }
  50. return false;
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. if (card.Owner.SecurityCards.Count <= 3)
  57. {
  58. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentCondition))
  59. {
  60. return true;
  61. }
  62. }
  63. if (card.Owner.SecurityCards.Count >= 3)
  64. {
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable hashtable)
  71. {
  72. if (card.Owner.SecurityCards.Count >= 3)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  75. if (card.Owner.HandCards.Count >= 1)
  76. {
  77. int discardCount = Math.Min(1, card.Owner.HandCards.Count);
  78. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  79. selectHandEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: (cardSource) => true,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: discardCount,
  85. canNoSelect: false,
  86. canEndNotMax: false,
  87. isShowOpponent: true,
  88. selectCardCoroutine: null,
  89. afterSelectCardCoroutine: null,
  90. mode: SelectHandEffect.Mode.Discard,
  91. cardEffect: activateClass);
  92. yield return StartCoroutine(selectHandEffect.Activate());
  93. }
  94. }
  95. if (card.Owner.SecurityCards.Count <= 3)
  96. {
  97. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  98. {
  99. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  100. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  101. };
  102. string selectPlayerMessage = "Will you play a Digimon with [Pulsemon] in it's text?";
  103. string notSelectPlayerMessage = "The opponent is choosing whether or not to play a Digimon.";
  104. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  105. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  106. bool willPlay = GManager.instance.userSelectionManager.SelectedBoolValue;
  107. if (willPlay)
  108. {
  109. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  110. {
  111. int maxCount = 1;
  112. List<CardSource> selectedCards = new List<CardSource>();
  113. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  114. selectCardEffect.SetUp(
  115. canTargetCondition: CanSelectCardCondition,
  116. canTargetCondition_ByPreSelecetedList: null,
  117. canEndSelectCondition: null,
  118. canNoSelect: () => true,
  119. selectCardCoroutine: SelectCardCoroutine,
  120. afterSelectCardCoroutine: null,
  121. message: "Select 1 card to play.",
  122. maxCount: maxCount,
  123. canEndNotMax: false,
  124. isShowOpponent: true,
  125. mode: SelectCardEffect.Mode.Custom,
  126. root: SelectCardEffect.Root.Trash,
  127. customRootCardList: null,
  128. canLookReverseCard: true,
  129. selectPlayer: card.Owner,
  130. cardEffect: activateClass);
  131. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  132. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  133. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  134. IEnumerator SelectCardCoroutine(CardSource cardSource)
  135. {
  136. selectedCards.Add(cardSource);
  137. yield return null;
  138. }
  139. SelectCardEffect.Root root = SelectCardEffect.Root.Trash;
  140. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  141. cardSources: selectedCards,
  142. activateClass: activateClass,
  143. payCost: false,
  144. isTapped: false,
  145. root: root,
  146. activateETB: true));
  147. foreach (CardSource selectedCard in selectedCards)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleArea(selectedCard))
  150. {
  151. Permanent selectedPermanent = selectedCard.PermanentOfThisCard();
  152. if (selectedPermanent != null)
  153. {
  154. ActivateClass activateClass1 = new ActivateClass();
  155. activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition1, selectedCard);
  156. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, "");
  157. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  158. card.Owner.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  159. if (!selectedCard.CanNotBeAffected(activateClass))
  160. {
  161. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  162. }
  163. bool CanUseCondition1(Hashtable hashtable1)
  164. {
  165. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  166. {
  167. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer != selectedPermanent.TopCard.Owner)
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. bool CanActivateCondition1(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  177. {
  178. if (selectedPermanent.CanBeDestroyedBySkill(activateClass1))
  179. {
  180. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass1))
  181. {
  182. return selectedPermanent.IsDigimon;
  183. }
  184. }
  185. }
  186. return false;
  187. }
  188. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  189. {
  190. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { selectedPermanent }, CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  191. }
  192. ICardEffect GetCardEffect(EffectTiming _timing)
  193. {
  194. if (_timing == EffectTiming.OnEndTurn)
  195. {
  196. return activateClass1;
  197. }
  198. return null;
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. else
  206. {
  207. yield return null;
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. #region Inherit
  214. if (timing == EffectTiming.OnEndAttack)
  215. {
  216. ActivateClass activateClass = new ActivateClass();
  217. activateClass.SetUpICardEffect("Unsuspend this Digimon.", CanUseCondition, card);
  218. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  219. activateClass.SetIsInheritedEffect(true);
  220. activateClass.SetHashString("Unsuspend_BT16_074");
  221. cardEffects.Add(activateClass);
  222. string EffectDiscription()
  223. {
  224. return "[End of Attack][Once per turn] If this Digimon has [Pulsemon] in its text, by trashing the top card of your security stack, unsuspend this Digimon.";
  225. }
  226. bool CanUseCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  229. }
  230. bool CanActivateCondition(Hashtable hashtable)
  231. {
  232. if (CardEffectCommons.IsExistOnBattleArea(card))
  233. {
  234. if (card.PermanentOfThisCard().TopCard.HasText("Pulsemon"))
  235. {
  236. if (card.Owner.SecurityCards.Count >= 1)
  237. {
  238. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  239. {
  240. return true;
  241. }
  242. }
  243. }
  244. }
  245. return false;
  246. }
  247. bool PermanentCondition(Permanent permanent)
  248. {
  249. if (permanent == card.PermanentOfThisCard())
  250. {
  251. if (card.PermanentOfThisCard().TopCard.HasText("Pulsemon"))
  252. {
  253. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  254. {
  255. return true;
  256. }
  257. }
  258. }
  259. return false;
  260. }
  261. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  262. {
  263. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  264. player: card.Owner,
  265. destroySecurityCount: 1,
  266. cardEffect: activateClass,
  267. fromTop: true).DestroySecurity());
  268. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  269. {
  270. Permanent selectedPermanent = card.PermanentOfThisCard();
  271. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  272. }
  273. }
  274. }
  275. #endregion
  276. return cardEffects;
  277. }
  278. }
  279. }