EX9_039.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // DarkTyrannomon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_039 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel3 &&
  19. targetPermanent.TopCard.EqualsTraits("DM");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 2,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. #endregion
  29. #region Training
  30. if (timing == EffectTiming.OnDeclaration)
  31. {
  32. cardEffects.Add(CardEffectFactory.TrainingEffect(card: card));
  33. }
  34. #endregion
  35. #region On Play
  36. if (timing == EffectTiming.OnEnterFieldAnyone)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect("Place 1 hand card as FD bottom source, suspend 1 digimon, then attack", CanUseCondition, card);
  40. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[On Play] You may place 1 card in your hand face down as this Digimon's bottom digivolution card. For each of this Digimon's face-down digivolution cards, suspend 1 of your opponent's Digimon. Then, 1 of your Digimon may attack your opponent's Digimon.";
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  53. }
  54. bool SelectCardCondition(CardSource source)
  55. {
  56. return true;
  57. }
  58. bool CanSelectPermanentCondition(Permanent permanent)
  59. {
  60. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  61. }
  62. bool CanSelectPermanentCondition1(Permanent permanent)
  63. {
  64. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  65. {
  66. if (permanent.CanAttack(activateClass))
  67. {
  68. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((enemyDigimon) => permanent.CanAttackTargetDigimon(enemyDigimon, activateClass)) >= 1)
  69. {
  70. return true;
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable hashtable)
  77. {
  78. if(card.Owner.HandCards.Count > 0)
  79. {
  80. CardSource selectedCard = null;
  81. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  82. selectHandEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: SelectCardCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: 1,
  88. canNoSelect: true,
  89. canEndNotMax: false,
  90. isShowOpponent: false,
  91. selectCardCoroutine: SelectCardCoroutine,
  92. afterSelectCardCoroutine: null,
  93. mode: SelectHandEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectHandEffect.SetUpCustomMessage("Select 1 card to add as FD Source", "The opponent is selecting 1 card to add as FD source");
  96. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  97. yield return StartCoroutine(selectHandEffect.Activate());
  98. IEnumerator SelectCardCoroutine(CardSource cardSource)
  99. {
  100. selectedCard = cardSource;
  101. yield return null;
  102. }
  103. if(selectedCard != null)
  104. {
  105. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  106. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  107. }
  108. }
  109. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  110. {
  111. int tapCount = card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count;
  112. int maxCount = Math.Min(tapCount, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectPermanentCondition,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: false,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: null,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.Tap,
  125. cardEffect: activateClass);
  126. selectPermanentEffect.SetUpCustomMessage($"Select {tapCount} Digimon to suspend", $"The opponent is selecting {tapCount} Digimon to suspend");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. }
  129. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  130. {
  131. List<Permanent> selectedPermanents = new List<Permanent>();
  132. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect1.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: CanSelectPermanentCondition1,
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: 1,
  139. canNoSelect: true,
  140. canEndNotMax: false,
  141. selectPermanentCoroutine: null,
  142. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  143. mode: SelectPermanentEffect.Mode.Custom,
  144. cardEffect: activateClass);
  145. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon that will attack.", "The opponent is selecting 1 Digimon that will attack.");
  146. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  147. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  148. {
  149. selectedPermanents = permanents;
  150. yield return null;
  151. }
  152. foreach (Permanent permanent in selectedPermanents)
  153. {
  154. Permanent selectedPermanent = permanent;
  155. if (selectedPermanent != null)
  156. {
  157. if (selectedPermanent.CanAttack(activateClass))
  158. {
  159. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  160. selectAttackEffect.SetUp(
  161. attacker: selectedPermanent,
  162. canAttackPlayerCondition: () => false,
  163. defenderCondition: (permanent) => true,
  164. cardEffect: activateClass);
  165. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. #endregion
  173. #region When Digivolving
  174. if (timing == EffectTiming.OnEnterFieldAnyone)
  175. {
  176. ActivateClass activateClass = new ActivateClass();
  177. activateClass.SetUpICardEffect("Place 1 hand card as FD bottom source, suspend 1 digimon, then attack", CanUseCondition, card);
  178. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  179. cardEffects.Add(activateClass);
  180. string EffectDiscription()
  181. {
  182. return "[When Digivolving] You may place 1 card in your hand face down as this Digimon's bottom digivolution card. For each of this Digimon's face-down digivolution cards, suspend 1 of your opponent's Digimon. Then, 1 of your Digimon may attack your opponent's Digimon.";
  183. }
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  187. }
  188. bool CanActivateCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  191. }
  192. bool SelectCardCondition(CardSource source)
  193. {
  194. return true;
  195. }
  196. bool CanSelectPermanentCondition(Permanent permanent)
  197. {
  198. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  199. }
  200. bool CanSelectPermanentCondition1(Permanent permanent)
  201. {
  202. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  203. {
  204. if (permanent.CanAttack(activateClass))
  205. {
  206. if (card.Owner.Enemy.GetBattleAreaDigimons().Count((enemyDigimon) => permanent.CanAttackTargetDigimon(enemyDigimon, activateClass)) >= 1)
  207. {
  208. return true;
  209. }
  210. }
  211. }
  212. return false;
  213. }
  214. IEnumerator ActivateCoroutine(Hashtable hashtable)
  215. {
  216. if (card.Owner.HandCards.Count > 0)
  217. {
  218. CardSource selectedCard = null;
  219. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  220. selectHandEffect.SetUp(
  221. selectPlayer: card.Owner,
  222. canTargetCondition: SelectCardCondition,
  223. canTargetCondition_ByPreSelecetedList: null,
  224. canEndSelectCondition: null,
  225. maxCount: 1,
  226. canNoSelect: true,
  227. canEndNotMax: false,
  228. isShowOpponent: false,
  229. selectCardCoroutine: SelectCardCoroutine,
  230. afterSelectCardCoroutine: null,
  231. mode: SelectHandEffect.Mode.Custom,
  232. cardEffect: activateClass);
  233. selectHandEffect.SetUpCustomMessage("Select 1 card to add as FD Source", "The opponent is selecting 1 card to add as FD source");
  234. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  235. yield return StartCoroutine(selectHandEffect.Activate());
  236. IEnumerator SelectCardCoroutine(CardSource cardSource)
  237. {
  238. selectedCard = cardSource;
  239. yield return null;
  240. }
  241. if (selectedCard != null)
  242. {
  243. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  244. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  245. }
  246. }
  247. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  248. {
  249. int tapCount = card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.IsFlipped).Count;
  250. int maxCount = Math.Min(tapCount, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  251. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  252. selectPermanentEffect.SetUp(
  253. selectPlayer: card.Owner,
  254. canTargetCondition: CanSelectPermanentCondition,
  255. canTargetCondition_ByPreSelecetedList: null,
  256. canEndSelectCondition: null,
  257. maxCount: maxCount,
  258. canNoSelect: false,
  259. canEndNotMax: false,
  260. selectPermanentCoroutine: null,
  261. afterSelectPermanentCoroutine: null,
  262. mode: SelectPermanentEffect.Mode.Tap,
  263. cardEffect: activateClass);
  264. selectPermanentEffect.SetUpCustomMessage($"Select {tapCount} Digimon to suspend", $"The opponent is selecting {tapCount} Digimon to suspend");
  265. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  266. }
  267. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  268. {
  269. List<Permanent> selectedPermanents = new List<Permanent>();
  270. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  271. selectPermanentEffect1.SetUp(
  272. selectPlayer: card.Owner,
  273. canTargetCondition: CanSelectPermanentCondition1,
  274. canTargetCondition_ByPreSelecetedList: null,
  275. canEndSelectCondition: null,
  276. maxCount: 1,
  277. canNoSelect: true,
  278. canEndNotMax: false,
  279. selectPermanentCoroutine: null,
  280. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  281. mode: SelectPermanentEffect.Mode.Custom,
  282. cardEffect: activateClass);
  283. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon that will attack.", "The opponent is selecting 1 Digimon that will attack.");
  284. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  285. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  286. {
  287. selectedPermanents = permanents;
  288. yield return null;
  289. }
  290. foreach (Permanent permanent in selectedPermanents)
  291. {
  292. Permanent selectedPermanent = permanent;
  293. if (selectedPermanent != null)
  294. {
  295. if (selectedPermanent.CanAttack(activateClass))
  296. {
  297. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  298. selectAttackEffect.SetUp(
  299. attacker: selectedPermanent,
  300. canAttackPlayerCondition: () => false,
  301. defenderCondition: (permanent) => true,
  302. cardEffect: activateClass);
  303. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  304. }
  305. }
  306. }
  307. }
  308. }
  309. }
  310. #endregion
  311. #region ESS
  312. if (timing == EffectTiming.OnDestroyedAnyone)
  313. {
  314. ActivateClass activateClass = new ActivateClass();
  315. activateClass.SetUpICardEffect("Suspend 1 digimon or tamer", CanUseCondition, card);
  316. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  317. activateClass.SetIsInheritedEffect(true);
  318. cardEffects.Add(activateClass);
  319. string EffectDiscription()
  320. {
  321. return "[On Deletion] Suspend 1 of your opponent's Digimon or Tamers.";
  322. }
  323. bool CanUseCondition(Hashtable hashtable)
  324. {
  325. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  326. }
  327. bool CanActivateCondition(Hashtable hashtable)
  328. {
  329. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  330. }
  331. bool CanSelectPermanentCondition(Permanent permanent)
  332. {
  333. return CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card) && permanent.IsDigimon || permanent.IsTamer;
  334. }
  335. IEnumerator ActivateCoroutine(Hashtable hashtable)
  336. {
  337. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  338. {
  339. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  340. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  341. selectPermanentEffect.SetUp(
  342. selectPlayer: card.Owner,
  343. canTargetCondition: CanSelectPermanentCondition,
  344. canTargetCondition_ByPreSelecetedList: null,
  345. canEndSelectCondition: null,
  346. maxCount: maxCount1,
  347. canNoSelect: false,
  348. canEndNotMax: false,
  349. selectPermanentCoroutine: null,
  350. afterSelectPermanentCoroutine: null,
  351. mode: SelectPermanentEffect.Mode.Tap,
  352. cardEffect: activateClass);
  353. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon or tamer to suspend", "The opponent is selecting 1 Digimon or tamer to suspend");
  354. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  355. }
  356. }
  357. }
  358. #endregion
  359. return cardEffects;
  360. }
  361. }
  362. }