BT16_056.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_056 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Place top card of one of your opponent's Digimon to the top/bottom of their security stack.", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] You may place the top card of 1 of your opponent's Digimon with the [Vaccine] trait at the top of your opponent's security stack.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent.TopCard.CardTraits.Contains("Vaccine"))
  27. return true;
  28. }
  29. return false;
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. if (CardEffectCommons.IsExistOnBattleArea(card))
  38. {
  39. if (CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition) >= 1)
  40. return true;
  41. }
  42. return false;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  47. {
  48. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  49. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  50. selectPermanentEffect.SetUp(
  51. selectPlayer: card.Owner,
  52. canTargetCondition: CanSelectPermanentCondition,
  53. canTargetCondition_ByPreSelecetedList: null,
  54. canEndSelectCondition: null,
  55. maxCount: maxCount,
  56. canNoSelect: true,
  57. canEndNotMax: false,
  58. selectPermanentCoroutine: SelectPermanentCoroutine,
  59. afterSelectPermanentCoroutine: null,
  60. mode: SelectPermanentEffect.Mode.Custom,
  61. cardEffect: activateClass);
  62. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place to security.", "The opponent is selecting 1 Digimon to place to security.");
  63. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  64. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  65. {
  66. Permanent selectedPermanent = permanent;
  67. if (selectedPermanent != null)
  68. {
  69. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  70. {
  71. Permanent securityPermanent = selectedPermanent;
  72. CardSource securityCard = securityPermanent.TopCard;
  73. if (securityPermanent.DigivolutionCards.Count >= 1)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(securityCard));
  76. permanent.ShowingPermanentCard.ShowPermanentData(true);
  77. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(securityCard, permanent));
  78. if (!securityCard.IsToken)
  79. {
  80. Player owner = securityCard.Owner;
  81. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(securityCard, true));
  82. permanent.willBeRemoveField = false;
  83. if (permanent.ShowingPermanentCard != null)
  84. {
  85. if (permanent.ShowingPermanentCard.WillBeDeletedObject != null)
  86. {
  87. permanent.ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. }
  97. }
  98. #endregion
  99. #region When Digivolving
  100. if (timing == EffectTiming.OnEnterFieldAnyone)
  101. {
  102. ActivateClass activateClass = new ActivateClass();
  103. activateClass.SetUpICardEffect("Place top card of one of your opponent's Digimon to the top/bottom of their security stack.", CanUseCondition, card);
  104. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  105. cardEffects.Add(activateClass);
  106. string EffectDiscription()
  107. {
  108. return "[When Digivolving] You may place the top card of 1 of your opponent's Digimon with the [Vaccine] trait at the top of your opponent's security stack.";
  109. }
  110. bool CanSelectPermanentCondition(Permanent permanent)
  111. {
  112. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  113. {
  114. if (permanent.TopCard.CardTraits.Contains("Vaccine"))
  115. return true;
  116. }
  117. return false;
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  126. {
  127. if (CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition) >= 1)
  128. return true;
  129. }
  130. return false;
  131. }
  132. IEnumerator ActivateCoroutine(Hashtable hashtable)
  133. {
  134. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  135. {
  136. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  137. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  138. selectPermanentEffect.SetUp(
  139. selectPlayer: card.Owner,
  140. canTargetCondition: CanSelectPermanentCondition,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: null,
  143. maxCount: maxCount,
  144. canNoSelect: true,
  145. canEndNotMax: false,
  146. selectPermanentCoroutine: SelectPermanentCoroutine,
  147. afterSelectPermanentCoroutine: null,
  148. mode: SelectPermanentEffect.Mode.Custom,
  149. cardEffect: activateClass);
  150. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place to security.", "The opponent is selecting 1 Digimon to place to security.");
  151. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  152. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  153. {
  154. Permanent selectedPermanent = permanent;
  155. if (selectedPermanent != null)
  156. {
  157. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  158. {
  159. Permanent securityPermanent = selectedPermanent;
  160. CardSource securityCard = securityPermanent.TopCard;
  161. if (securityPermanent.DigivolutionCards.Count >= 1)
  162. {
  163. yield return ContinuousController.instance.StartCoroutine(CardObjectController.RemoveFromAllArea(securityCard));
  164. permanent.ShowingPermanentCard.ShowPermanentData(true);
  165. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(securityCard, permanent));
  166. if (!securityCard.IsToken)
  167. {
  168. Player owner = securityCard.Owner;
  169. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(securityCard, true));
  170. permanent.willBeRemoveField = false;
  171. if (permanent.ShowingPermanentCard != null)
  172. {
  173. if (permanent.ShowingPermanentCard.WillBeDeletedObject != null)
  174. {
  175. permanent.ShowingPermanentCard.WillBeDeletedObject.SetActive(false);
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. #endregion
  187. #region All Turns
  188. if (timing == EffectTiming.OnAddSecurity)
  189. {
  190. ActivateClass activateClass = new ActivateClass();
  191. activateClass.SetUpICardEffect("Trash top or bottom of opponents security", CanUseCondition, card);
  192. activateClass.SetUpActivateClass(CanActivateAllTurnsCondition, ActivateCoroutine, 1, false, EffectAllTurnsDiscription());
  193. activateClass.SetHashString("Publimon_BT16_056_AllTurns");
  194. cardEffects.Add(activateClass);
  195. string EffectAllTurnsDiscription()
  196. {
  197. return "[All Turns] [Once Per Turn] When a card is added to your opponent's security stack, if they have 3 or more security cards, trash the top or bottom card of their security stack.";
  198. }
  199. bool CanUseCondition(Hashtable hashtable)
  200. {
  201. if (CardEffectCommons.CanTriggerWhenAddSecurity(hashtable, player => player == card.Owner.Enemy))
  202. {
  203. if (card.Owner.Enemy.SecurityCards.Count >= 3)
  204. return true;
  205. }
  206. return false;
  207. }
  208. bool CanActivateAllTurnsCondition(Hashtable hashtable)
  209. {
  210. return CardEffectCommons.IsExistOnBattleArea(card);
  211. }
  212. IEnumerator ActivateCoroutine(Hashtable hashtable)
  213. {
  214. if (card.Owner.Enemy.SecurityCards.Count < 3)
  215. yield break;
  216. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  217. {
  218. new SelectionElement<bool>(message: $"Security Top", value : true, spriteIndex: 0),
  219. new SelectionElement<bool>(message: $"Security Bottom", value : false, spriteIndex: 1),
  220. };
  221. string selectPlayerMessage = "Will you trash the card on the top or bottom of the security?";
  222. string notSelectPlayerMessage = "The opponent is selecting whether to trash the card on the top or bottom of security.";
  223. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  224. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  225. bool toTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  226. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  227. player: card.Owner.Enemy,
  228. destroySecurityCount: 1,
  229. cardEffect: activateClass,
  230. fromTop: toTop).DestroySecurity());
  231. }
  232. }
  233. #endregion
  234. return cardEffects;
  235. }
  236. }
  237. }