BT18_055.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_055 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region DigiXros
  12. if (timing == EffectTiming.None)
  13. {
  14. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  15. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  16. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  17. addDigiXrosConditionClass.SetNotShowUI(true);
  18. cardEffects.Add(addDigiXrosConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return true;
  22. }
  23. DigiXrosCondition GetDigiXros(CardSource cardSource)
  24. {
  25. if (cardSource == card)
  26. {
  27. DigiXrosConditionElement elementArbormon =
  28. new DigiXrosConditionElement(CanSelectCardCondition, "Arbormon");
  29. bool CanSelectCardCondition(CardSource conditionCardSource)
  30. {
  31. if (conditionCardSource != null)
  32. {
  33. if (conditionCardSource.Owner == card.Owner)
  34. {
  35. if (conditionCardSource.IsDigimon)
  36. {
  37. if (conditionCardSource.CardNames_DigiXros.Contains("Arbormon"))
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. }
  44. return false;
  45. }
  46. DigiXrosConditionElement elementPetaldramon =
  47. new DigiXrosConditionElement(CanSelectCardCondition1, "Petaldramon");
  48. bool CanSelectCardCondition1(CardSource conditionCardSource)
  49. {
  50. if (conditionCardSource != null)
  51. {
  52. if (conditionCardSource.Owner == card.Owner)
  53. {
  54. if (conditionCardSource.IsDigimon)
  55. {
  56. if (conditionCardSource.CardNames_DigiXros.Contains("Petaldramon"))
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. }
  63. return false;
  64. }
  65. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  66. { elementArbormon, elementPetaldramon };
  67. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  68. return digiXrosCondition;
  69. }
  70. return null;
  71. }
  72. }
  73. #endregion
  74. #region All turns Once Per Turn
  75. if (timing == EffectTiming.OnTappedAnyone)
  76. {
  77. ActivateClass activateClass = new ActivateClass();
  78. activateClass.SetUpICardEffect("Trash opponents top security", CanUseCondition, card);
  79. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  80. activateClass.SetHashString("TrashSecurity_BT18_055");
  81. cardEffects.Add(activateClass);
  82. string EffectDiscription()
  83. {
  84. return "[All Turns] [Once Per Turn] When an opponent's Digimon becomes suspended, trash their top security card.";
  85. }
  86. bool PermanentCondition(Permanent permanent)
  87. {
  88. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  89. }
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  93. {
  94. if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, PermanentCondition))
  95. {
  96. return true;
  97. }
  98. }
  99. return false;
  100. }
  101. bool CanActivateCondition(Hashtable hashtable)
  102. {
  103. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  104. {
  105. if (card.Owner.Enemy.SecurityCards.Count >= 0)
  106. {
  107. return true;
  108. }
  109. }
  110. return false;
  111. }
  112. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  113. {
  114. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  115. player: card.Owner.Enemy,
  116. destroySecurityCount: 1,
  117. cardEffect: activateClass,
  118. fromTop: true).DestroySecurity());
  119. }
  120. }
  121. #endregion
  122. #region All Turns
  123. if (timing == EffectTiming.WhenRemoveField)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("Return a Digimon or play a Digimon from this Digimon digivolution sources to hand.", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  128. cardEffects.Add(activateClass);
  129. string EffectDiscription()
  130. {
  131. return "[All Turns] When this Digimon would leave the battle area, you may return to the hand or play 1 level 4 or lower green Digimon card from this Digimon's digivolution cards without paying the cost.";
  132. }
  133. bool CanSelectCardCondition(CardSource cardSource)
  134. {
  135. if (cardSource != null)
  136. {
  137. if (cardSource.Owner == card.Owner)
  138. {
  139. if (cardSource.IsDigimon)
  140. {
  141. if (cardSource.Level <= 4)
  142. {
  143. if (cardSource.HasCardColor(CardColor.Green))
  144. {
  145. if (cardSource.HasLevel)
  146. {
  147. return true;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. return false;
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  159. {
  160. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  161. {
  162. return true;
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  170. {
  171. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  172. {
  173. return true;
  174. }
  175. }
  176. return false;
  177. }
  178. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  179. {
  180. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  181. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  182. if (canSelectDigivolutionCards)
  183. {
  184. if (canSelectDigivolutionCards)
  185. {
  186. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  187. {
  188. new SelectionElement<bool>(message: $"Return to hand", value : true, spriteIndex: 0),
  189. new SelectionElement<bool>(message: $"Play a Digimon", value : false, spriteIndex: 1),
  190. };
  191. string selectPlayerMessage = "Do you want to return to hand or play 1 level 4 or lower Digimon from its digivolution sources";
  192. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  193. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  194. }
  195. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  196. bool toHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  197. List<CardSource> selectedCards = new List<CardSource>();
  198. IEnumerator SelectCardCoroutine(CardSource cardSource)
  199. {
  200. selectedCards.Add(cardSource);
  201. yield return null;
  202. }
  203. if (toHand)
  204. {
  205. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  206. selectCardEffect.SetUp(
  207. canTargetCondition: CanSelectCardCondition,
  208. canTargetCondition_ByPreSelecetedList: null,
  209. canEndSelectCondition: null,
  210. canNoSelect: () => true,
  211. selectCardCoroutine: SelectCardCoroutine,
  212. afterSelectCardCoroutine: null,
  213. message: "Select 1 card to return to hand.",
  214. maxCount: 1,
  215. canEndNotMax: false,
  216. isShowOpponent: true,
  217. mode: SelectCardEffect.Mode.AddHand,
  218. root: SelectCardEffect.Root.Custom,
  219. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  220. canLookReverseCard: true,
  221. selectPlayer: card.Owner,
  222. cardEffect: activateClass);
  223. yield return StartCoroutine(selectCardEffect.Activate());
  224. }
  225. else
  226. {
  227. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  228. selectCardEffect.SetUp(
  229. canTargetCondition: CanSelectCardCondition,
  230. canTargetCondition_ByPreSelecetedList: null,
  231. canEndSelectCondition: null,
  232. canNoSelect: () => true,
  233. selectCardCoroutine: SelectCardCoroutine,
  234. afterSelectCardCoroutine: null,
  235. message: "Select 1 card to play.",
  236. maxCount: 1,
  237. canEndNotMax: false,
  238. isShowOpponent: true,
  239. mode: SelectCardEffect.Mode.Custom,
  240. root: SelectCardEffect.Root.Custom,
  241. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  242. canLookReverseCard: true,
  243. selectPlayer: card.Owner,
  244. cardEffect: activateClass);
  245. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  246. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  247. yield return StartCoroutine(selectCardEffect.Activate());
  248. }
  249. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  250. if (!toHand)
  251. {
  252. root = SelectCardEffect.Root.DigivolutionCards;
  253. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: selectedCards[0], payCost: false, cardEffect: activateClass))
  254. {
  255. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  256. cardSources: selectedCards,
  257. activateClass: activateClass,
  258. payCost: false,
  259. isTapped: false,
  260. root: root,
  261. activateETB: true));
  262. }
  263. }
  264. }
  265. }
  266. }
  267. #endregion
  268. return cardEffects;
  269. }
  270. }
  271. }