EX8_063.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX8
  6. {
  7. public class EX8_063 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Barbamon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 1,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null));
  25. }
  26. #endregion
  27. #region When Digivolving/When Attacking Shared
  28. bool CanSelectCardOpponentsCardCondition(CardSource cardSource)
  29. {
  30. return cardSource.Owner == card.Owner.Enemy;
  31. }
  32. #endregion
  33. #region When Digivolving
  34. if (timing == EffectTiming.OnEnterFieldAnyone)
  35. {
  36. ActivateClass activateClass = new ActivateClass();
  37. activateClass.SetUpICardEffect("Opponent trashes 1 card, or you play a fallen angel", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectSharedDiscription());
  39. activateClass.SetHashString("TrashOrPlay_EX8_063");
  40. cardEffects.Add(activateClass);
  41. string EffectSharedDiscription()
  42. {
  43. return "[When Digivolving] [Once Per Turn] Your opponent may trash 1 card in their hand. If this effect didn't trash, you may play 1 [Fallen Angel] trait Digimon card with a play cost of 7 or less from your trash without paying the cost.";
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.IsExistOnBattleArea(card);
  52. }
  53. bool CanSelectCardInTrash(CardSource cardSource)
  54. {
  55. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  56. {
  57. if (cardSource.IsDigimon)
  58. {
  59. if (cardSource.GetCostItself <= 7)
  60. {
  61. if (cardSource.EqualsTraits("Fallen Angel"))
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. }
  68. return false;
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  71. {
  72. bool discarded = false;
  73. if (card.Owner.Enemy.HandCards.Count >= 1)
  74. {
  75. int discardCount = 1;
  76. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  77. selectHandEffect.SetUp(
  78. selectPlayer: card.Owner.Enemy,
  79. canTargetCondition: CanSelectCardOpponentsCardCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: discardCount,
  83. canNoSelect: true,
  84. canEndNotMax: false,
  85. isShowOpponent: true,
  86. selectCardCoroutine: null,
  87. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  88. mode: SelectHandEffect.Mode.Discard,
  89. cardEffect: activateClass);
  90. yield return StartCoroutine(selectHandEffect.Activate());
  91. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  92. {
  93. if (cardSources.Count >= 1)
  94. {
  95. discarded = true;
  96. yield return null;
  97. }
  98. }
  99. }
  100. if (!discarded)
  101. {
  102. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  103. {
  104. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  105. List<CardSource> selectedCards = new List<CardSource>();
  106. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  107. selectCardEffect.SetUp(
  108. canTargetCondition: CanSelectCardInTrash,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. canNoSelect: () => true,
  112. selectCardCoroutine: SelectCardCoroutine,
  113. afterSelectCardCoroutine: null,
  114. message: "Select 1 card to play.",
  115. maxCount: maxCount,
  116. canEndNotMax: false,
  117. isShowOpponent: true,
  118. mode: SelectCardEffect.Mode.Custom,
  119. root: SelectCardEffect.Root.Trash,
  120. customRootCardList: null,
  121. canLookReverseCard: true,
  122. selectPlayer: card.Owner,
  123. cardEffect: activateClass);
  124. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  125. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  126. yield return StartCoroutine(selectCardEffect.Activate());
  127. IEnumerator SelectCardCoroutine(CardSource cardSource)
  128. {
  129. selectedCards.Add(cardSource);
  130. yield return null;
  131. }
  132. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  133. cardSources: selectedCards,
  134. activateClass: activateClass,
  135. payCost: false,
  136. isTapped: false,
  137. root: SelectCardEffect.Root.Trash,
  138. activateETB: true));
  139. }
  140. }
  141. }
  142. }
  143. #endregion
  144. #region When Attacking
  145. if (timing == EffectTiming.OnAllyAttack)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("Opponent trashes 1 card, or you play a fallen angel", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectSharedDiscription());
  150. activateClass.SetHashString("TrashOrPlay_EX8_063");
  151. cardEffects.Add(activateClass);
  152. string EffectSharedDiscription()
  153. {
  154. return "[When Attacking] [Once Per Turn] Your opponent may trash 1 card in their hand. If this effect didn't trash, you may play 1 [Fallen Angel] trait Digimon card with a play cost of 7 or less from your trash without paying the cost.";
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  159. {
  160. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  161. {
  162. return true;
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. return CardEffectCommons.IsExistOnBattleArea(card);
  170. }
  171. bool CanSelectCardInTrash(CardSource cardSource)
  172. {
  173. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  174. {
  175. if (cardSource.IsDigimon)
  176. {
  177. if (cardSource.GetCostItself <= 7)
  178. {
  179. if (cardSource.EqualsTraits("Fallen Angel"))
  180. {
  181. return true;
  182. }
  183. }
  184. }
  185. }
  186. return false;
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  189. {
  190. bool discarded = false;
  191. if (card.Owner.Enemy.HandCards.Count >= 1)
  192. {
  193. int discardCount = 1;
  194. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  195. selectHandEffect.SetUp(
  196. selectPlayer: card.Owner.Enemy,
  197. canTargetCondition: CanSelectCardOpponentsCardCondition,
  198. canTargetCondition_ByPreSelecetedList: null,
  199. canEndSelectCondition: null,
  200. maxCount: discardCount,
  201. canNoSelect: true,
  202. canEndNotMax: false,
  203. isShowOpponent: true,
  204. selectCardCoroutine: null,
  205. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  206. mode: SelectHandEffect.Mode.Discard,
  207. cardEffect: activateClass);
  208. yield return StartCoroutine(selectHandEffect.Activate());
  209. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  210. {
  211. if (cardSources.Count >= 1)
  212. {
  213. discarded = true;
  214. yield return null;
  215. }
  216. }
  217. }
  218. if (!discarded)
  219. {
  220. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardInTrash))
  221. {
  222. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardInTrash));
  223. List<CardSource> selectedCards = new List<CardSource>();
  224. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  225. selectCardEffect.SetUp(
  226. canTargetCondition: CanSelectCardInTrash,
  227. canTargetCondition_ByPreSelecetedList: null,
  228. canEndSelectCondition: null,
  229. canNoSelect: () => true,
  230. selectCardCoroutine: SelectCardCoroutine,
  231. afterSelectCardCoroutine: null,
  232. message: "Select 1 card to play.",
  233. maxCount: maxCount,
  234. canEndNotMax: false,
  235. isShowOpponent: true,
  236. mode: SelectCardEffect.Mode.Custom,
  237. root: SelectCardEffect.Root.Trash,
  238. customRootCardList: null,
  239. canLookReverseCard: true,
  240. selectPlayer: card.Owner,
  241. cardEffect: activateClass);
  242. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  243. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  244. yield return StartCoroutine(selectCardEffect.Activate());
  245. IEnumerator SelectCardCoroutine(CardSource cardSource)
  246. {
  247. selectedCards.Add(cardSource);
  248. yield return null;
  249. }
  250. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  251. cardSources: selectedCards,
  252. activateClass: activateClass,
  253. payCost: false,
  254. isTapped: false,
  255. root: SelectCardEffect.Root.Trash,
  256. activateETB: true));
  257. }
  258. }
  259. }
  260. }
  261. #endregion
  262. #region All Turns
  263. if (timing == EffectTiming.OnDiscardHand)
  264. {
  265. ActivateClass activateClass = new ActivateClass();
  266. activateClass.SetUpICardEffect("Trash opponent's security", CanUseCondition, card);
  267. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  268. activateClass.SetHashString("TrashSecurity_EX8_063");
  269. cardEffects.Add(activateClass);
  270. string EffectDescription()
  271. {
  272. return "[All Turns] [Once Per Turn] When your opponent's hand is trashed from, if [Barbamon] or [X Antibody] is in this Digimon's digivolution cards, trash their top security card.";
  273. }
  274. bool CanUseCondition(Hashtable hashtable)
  275. {
  276. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  277. {
  278. if (CardEffectCommons.CanTriggerOnTrashHand(hashtable, cardEffect => true, cardSource => cardSource.Owner == card.Owner.Enemy))
  279. {
  280. return true;
  281. }
  282. }
  283. return false;
  284. }
  285. bool CanActivateCondition(Hashtable hashtable)
  286. {
  287. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  288. {
  289. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.EqualsCardName("Barbamon") || cardSource.EqualsCardName("X Antibody")) >= 1)
  290. {
  291. return true;
  292. }
  293. }
  294. return false;
  295. }
  296. IEnumerator ActivateCoroutine(Hashtable hashtable)
  297. {
  298. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  299. player: card.Owner.Enemy,
  300. destroySecurityCount: 1,
  301. cardEffect: activateClass,
  302. fromTop: true).DestroySecurity());
  303. }
  304. }
  305. #endregion
  306. return cardEffects;
  307. }
  308. }
  309. }