EX6_042.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_042 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4)
  18. {
  19. return targetPermanent.TopCard.ContainsTraits("Legend-Arms");
  20. }
  21. return false;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  24. permanentCondition: PermanentCondition,
  25. digivolutionCost: 3,
  26. ignoreDigivolutionRequirement: false,
  27. card: card,
  28. condition: null));
  29. }
  30. #endregion
  31. #region Hand - Main
  32. if (timing == EffectTiming.OnDeclaration)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("One of your opponents Digimon must attack", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDiscription());
  37. activateClass.SetIsDigimonEffect(true);
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "[Hand] [Main] By paying 2 cost and placing this card as the bottom digivolution card of 1 of your Digimon that's level 5 or has the [Legend-Arms] trait, until the end of your opponent's turn, 1 of their Digimon gains \"[Start of Your Main Phase] This Digimon attacks.\"";
  42. }
  43. bool IsLevel5OrHasLegendArmsTrait(Permanent targetPermanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(targetPermanent, card))
  46. {
  47. if (targetPermanent.TopCard.HasLevel && targetPermanent.Level == 5)
  48. return true;
  49. if (targetPermanent.TopCard.ContainsTraits("Legend-Arms"))
  50. return true;
  51. }
  52. return false;
  53. }
  54. bool IsEnemyPermanent(Permanent permanent)
  55. {
  56. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnHand(card))
  61. {
  62. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsLevel5OrHasLegendArmsTrait))
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable hashtable)
  70. {
  71. Permanent selectedPermanent = null;
  72. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-2, activateClass));
  73. if (CardEffectCommons.HasMatchConditionPermanent(IsLevel5OrHasLegendArmsTrait))
  74. {
  75. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsLevel5OrHasLegendArmsTrait));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: IsLevel5OrHasLegendArmsTrait,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: SelectPermanentCoroutine,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to add bottom digivolution source.", "The opponent is selecting 1 Digimon to add bottom digivolution source.");
  90. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  91. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  92. {
  93. selectedPermanent = permanent;
  94. yield return null;
  95. }
  96. }
  97. if (selectedPermanent != null)
  98. {
  99. Permanent selectedPermanent1 = null;
  100. if (CardEffectCommons.HasMatchConditionPermanent(IsEnemyPermanent))
  101. {
  102. int enemyCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsEnemyPermanent));
  103. SelectPermanentEffect selectEnemyEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  104. selectEnemyEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: IsEnemyPermanent,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: enemyCount,
  110. canNoSelect: false,
  111. canEndNotMax: false,
  112. selectPermanentCoroutine: SelectPermanentCoroutine,
  113. afterSelectPermanentCoroutine: null,
  114. mode: SelectPermanentEffect.Mode.Custom,
  115. cardEffect: activateClass);
  116. selectEnemyEffect.SetUpCustomMessage("Select 1 Digimon to gain effect.", "The opponent is selecting 1 Digimon gain effect.");
  117. yield return ContinuousController.instance.StartCoroutine(selectEnemyEffect.Activate());
  118. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  119. {
  120. selectedPermanent1 = permanent;
  121. yield return null;
  122. }
  123. if (selectedPermanent1 != null)
  124. {
  125. ActivateClass activateClass1 = new ActivateClass();
  126. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent1.TopCard);
  127. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  128. activateClass1.SetEffectSourcePermanent(selectedPermanent1);
  129. selectedPermanent1.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  130. if (!selectedPermanent1.TopCard.CanNotBeAffected(activateClass))
  131. {
  132. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent1));
  133. }
  134. string EffectDiscription1()
  135. {
  136. return "[Start of Your Main Phase] Attack with this Digimon.";
  137. }
  138. bool CanUseCondition1(Hashtable hashtable1)
  139. {
  140. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent1))
  141. {
  142. if (selectedPermanent1.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent1))
  143. {
  144. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent1.TopCard.Owner)
  145. {
  146. return true;
  147. }
  148. }
  149. }
  150. return false;
  151. }
  152. bool CanActivateCondition1(Hashtable hashtable1)
  153. {
  154. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent1))
  155. {
  156. if (!selectedPermanent1.TopCard.CanNotBeAffected(activateClass))
  157. {
  158. if (selectedPermanent1.CanAttack(activateClass1))
  159. {
  160. return true;
  161. }
  162. }
  163. }
  164. return false;
  165. }
  166. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  167. {
  168. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent1))
  169. {
  170. if (selectedPermanent1.CanAttack(activateClass1))
  171. {
  172. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  173. selectAttackEffect.SetUp(
  174. attacker: selectedPermanent1,
  175. canAttackPlayerCondition: () => true,
  176. defenderCondition: (permanent) => true,
  177. cardEffect: activateClass1);
  178. selectAttackEffect.SetCanNotSelectNotAttack();
  179. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  180. }
  181. }
  182. }
  183. ICardEffect GetCardEffect(EffectTiming _timing)
  184. {
  185. if (_timing == EffectTiming.OnStartMainPhase)
  186. {
  187. return activateClass1;
  188. }
  189. return null;
  190. }
  191. }
  192. }
  193. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(
  194. new List<CardSource>() { card },
  195. activateClass));
  196. }
  197. }
  198. }
  199. #endregion
  200. #region Your Turn - Place Digivolution
  201. if (timing == EffectTiming.OnAddDigivolutionCards)
  202. {
  203. ActivateClass activateClass = new ActivateClass();
  204. activateClass.SetUpICardEffect("Gain <Blocker> and <Reboot>", CanUseCondition, card);
  205. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  206. activateClass.SetHashString("GainEffects_EX6_042");
  207. cardEffects.Add(activateClass);
  208. string EffectDiscription()
  209. {
  210. return "[Your Turn] [Once Per Turn] When an effect places a digivolution card under this Digimon, it gains <Blocker> and <Reboot> until the end of your opponent's turn.";
  211. }
  212. bool CanUseCondition(Hashtable hashtable)
  213. {
  214. if (CardEffectCommons.IsExistOnBattleArea(card))
  215. {
  216. if (CardEffectCommons.IsOwnerTurn(card))
  217. {
  218. if (CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  219. hashtable: hashtable,
  220. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  221. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  222. cardCondition: null))
  223. {
  224. return true;
  225. }
  226. }
  227. }
  228. return false;
  229. }
  230. bool CanActivateCondition(Hashtable hashtable)
  231. {
  232. return CardEffectCommons.IsExistOnBattleArea(card);
  233. }
  234. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  235. {
  236. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  237. targetPermanent: card.PermanentOfThisCard(),
  238. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  239. activateClass: activateClass));
  240. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainReboot(
  241. targetPermanent: card.PermanentOfThisCard(),
  242. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  243. activateClass: activateClass));
  244. }
  245. }
  246. #endregion
  247. #region All Turns - ESS
  248. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  249. {
  250. ActivateClass activateClass = new ActivateClass();
  251. activateClass.SetUpICardEffect("Prevent Deletion", CanUseCondition, card);
  252. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  253. activateClass.SetHashString("Protection_EX6_042");
  254. activateClass.SetIsInheritedEffect(true);
  255. cardEffects.Add(activateClass);
  256. string EffectDiscription()
  257. {
  258. return "[All Turns] [Once Per Turn] When this Digimon would be deleted other than by one of your effects, by trashing 1 card with the [Legend-Arms] trait in this Digimon's digivolution cards, prevent that deletion.";
  259. }
  260. bool HasLegendArmsTrait(CardSource cardSource)
  261. {
  262. if (!cardSource.CanNotTrashFromDigivolutionCards(activateClass))
  263. {
  264. return cardSource.ContainsTraits("Legend-Arms");
  265. }
  266. return false;
  267. }
  268. bool CanUseCondition(Hashtable hashtable)
  269. {
  270. if (CardEffectCommons.IsExistOnBattleArea(card))
  271. {
  272. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  273. {
  274. if (!CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  275. {
  276. return true;
  277. }
  278. }
  279. }
  280. return false;
  281. }
  282. bool CanActivateCondition(Hashtable hashtable)
  283. {
  284. if (CardEffectCommons.IsExistOnBattleArea(card))
  285. {
  286. if (card.PermanentOfThisCard().DigivolutionCards.Count(HasLegendArmsTrait) >= 1)
  287. {
  288. return true;
  289. }
  290. }
  291. return false;
  292. }
  293. IEnumerator ActivateCoroutine(Hashtable hashtable)
  294. {
  295. Permanent selectedPermanent = card.PermanentOfThisCard();
  296. if (selectedPermanent.DigivolutionCards.Count(HasLegendArmsTrait) >= 1)
  297. {
  298. List<CardSource> selectedCards = new List<CardSource>();
  299. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(HasLegendArmsTrait));
  300. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  301. selectCardEffect.SetUp(
  302. canTargetCondition: HasLegendArmsTrait,
  303. canTargetCondition_ByPreSelecetedList: null,
  304. canEndSelectCondition: null,
  305. canNoSelect: () => false,
  306. selectCardCoroutine: SelectCardCoroutine,
  307. afterSelectCardCoroutine: null,
  308. message: "Select cards to discard.",
  309. maxCount: maxCount,
  310. canEndNotMax: false,
  311. isShowOpponent: true,
  312. mode: SelectCardEffect.Mode.Custom,
  313. root: SelectCardEffect.Root.DigivolutionCards,
  314. customRootCardList: selectedPermanent.DigivolutionCards,
  315. canLookReverseCard: true,
  316. selectPlayer: card.Owner,
  317. cardEffect: activateClass);
  318. selectCardEffect.SetNotShowCard();
  319. yield return StartCoroutine(selectCardEffect.Activate());
  320. IEnumerator SelectCardCoroutine(CardSource cardSource)
  321. {
  322. selectedCards.Add(cardSource);
  323. yield return null;
  324. }
  325. if (selectedCards.Count >= 1)
  326. {
  327. selectedPermanent.willBeRemoveField = false;
  328. selectedPermanent.HideDeleteEffect();
  329. selectedPermanent.HideHandBounceEffect();
  330. selectedPermanent.HideDeckBounceEffect();
  331. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(selectedPermanent, selectedCards, activateClass).TrashDigivolutionCards());
  332. }
  333. }
  334. }
  335. }
  336. #endregion
  337. return cardEffects;
  338. }
  339. }
  340. }