EX4_021.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX4
  6. {
  7. public class EX4_021 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("De-Digivolve 1 on 1 Digimon and opponent's Digimon can't attack", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] <De-Digivolve 1> 1 of your opponent's Digimon. Then, all of your opponent's level 4 or lower Digimon can't attack until the end of your opponent's turn.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  29. }
  30. bool CanActivateCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.IsExistOnBattleArea(card))
  33. {
  34. return true;
  35. }
  36. return false;
  37. }
  38. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  39. {
  40. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  41. {
  42. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  43. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  44. selectPermanentEffect.SetUp(
  45. selectPlayer: card.Owner,
  46. canTargetCondition: CanSelectPermanentCondition,
  47. canTargetCondition_ByPreSelecetedList: null,
  48. canEndSelectCondition: null,
  49. maxCount: maxCount,
  50. canNoSelect: false,
  51. canEndNotMax: false,
  52. selectPermanentCoroutine: SelectPermanentCoroutine,
  53. afterSelectPermanentCoroutine: null,
  54. mode: SelectPermanentEffect.Mode.Custom,
  55. cardEffect: activateClass);
  56. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  57. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  58. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  59. {
  60. Permanent selectedPermanent = permanent;
  61. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  62. }
  63. }
  64. bool AttackerCondition(Permanent Attacker)
  65. {
  66. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(Attacker, card))
  67. {
  68. if (Attacker.TopCard.HasLevel && Attacker.Level <= 4)
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. bool DefenderCondition(Permanent defender)
  76. {
  77. return true;
  78. }
  79. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttackPlayerEffect(
  80. attackerCondition: AttackerCondition,
  81. defenderCondition: DefenderCondition,
  82. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  83. activateClass: activateClass,
  84. effectName: "Can't Attack"));
  85. }
  86. }
  87. if (timing == EffectTiming.WhenPermanentWouldBeDeleted || timing == EffectTiming.WhenReturntoHandAnyone || timing == EffectTiming.WhenReturntoLibraryAnyone)
  88. {
  89. ActivateClass activateClass = new ActivateClass();
  90. activateClass.SetUpICardEffect("Play [MetalGreymon] and [DarkKnightmon] from digivolution cards", CanUseCondition, card);
  91. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  92. activateClass.SetHashString("PlayDigivolutionCards_EX4_021");
  93. cardEffects.Add(activateClass);
  94. string EffectDiscription()
  95. {
  96. return "[All Turns] When this Digimon would be deleted or returned to your hand or deck, you may play 1 [MetalGreymon] and 1 [DarkKnightmon] from this Digimon's digivolution cards without paying the costs.";
  97. }
  98. bool CanSelectCardCondition(CardSource cardSource)
  99. {
  100. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  101. {
  102. if (cardSource.CardNames.Contains("MetalGreymon"))
  103. {
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. bool CanSelectCardCondition1(CardSource cardSource)
  110. {
  111. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  112. {
  113. if (cardSource.CardNames.Contains("DarkKnightmon"))
  114. {
  115. return true;
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. if (CardEffectCommons.IsExistOnBattleArea(card))
  123. {
  124. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  125. {
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanActivateCondition(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.IsExistOnBattleArea(card))
  134. {
  135. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource) || CanSelectCardCondition1(cardSource)) >= 1)
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  143. {
  144. if (CardEffectCommons.IsExistOnBattleArea(card))
  145. {
  146. List<CardSource> selectedCards = new List<CardSource>();
  147. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  148. {
  149. int maxCount = 1;
  150. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  151. selectCardEffect.SetUp(
  152. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. canNoSelect: () => false,
  156. selectCardCoroutine: SelectCardCoroutine,
  157. afterSelectCardCoroutine: null,
  158. message: "Select 1 [MetalGreymon] to play.",
  159. maxCount: maxCount,
  160. canEndNotMax: false,
  161. isShowOpponent: true,
  162. mode: SelectCardEffect.Mode.Custom,
  163. root: SelectCardEffect.Root.Custom,
  164. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  165. canLookReverseCard: true,
  166. selectPlayer: card.Owner,
  167. cardEffect: activateClass);
  168. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  169. IEnumerator SelectCardCoroutine(CardSource cardSource)
  170. {
  171. selectedCards.Add(cardSource);
  172. yield return null;
  173. }
  174. }
  175. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => CanSelectCardCondition1(cardSource)) >= 1)
  176. {
  177. int maxCount = 1;
  178. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  179. selectCardEffect.SetUp(
  180. canTargetCondition: (cardSource) => CanSelectCardCondition1(cardSource),
  181. canTargetCondition_ByPreSelecetedList: null,
  182. canEndSelectCondition: null,
  183. canNoSelect: () => false,
  184. selectCardCoroutine: SelectCardCoroutine,
  185. afterSelectCardCoroutine: null,
  186. message: "Select 1 [DarkKnightmon] to play.",
  187. maxCount: maxCount,
  188. canEndNotMax: false,
  189. isShowOpponent: true,
  190. mode: SelectCardEffect.Mode.Custom,
  191. root: SelectCardEffect.Root.Custom,
  192. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  193. canLookReverseCard: true,
  194. selectPlayer: card.Owner,
  195. cardEffect: activateClass);
  196. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  197. IEnumerator SelectCardCoroutine(CardSource cardSource)
  198. {
  199. selectedCards.Add(cardSource);
  200. yield return null;
  201. }
  202. }
  203. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  204. cardSources: selectedCards,
  205. activateClass: activateClass,
  206. payCost: false,
  207. isTapped: false,
  208. root: SelectCardEffect.Root.DigivolutionCards,
  209. activateETB: true));
  210. }
  211. }
  212. }
  213. if (timing == EffectTiming.None)
  214. {
  215. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  216. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  217. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  218. addDigiXrosConditionClass.SetNotShowUI(true);
  219. cardEffects.Add(addDigiXrosConditionClass);
  220. bool CanUseCondition(Hashtable hashtable)
  221. {
  222. return true;
  223. }
  224. DigiXrosCondition GetDigiXros(CardSource cardSource)
  225. {
  226. if (cardSource == card)
  227. {
  228. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Blue MetalGreymon");
  229. bool CanSelectCardCondition(CardSource cardSource)
  230. {
  231. if (cardSource != null)
  232. {
  233. if (cardSource.Owner == card.Owner)
  234. {
  235. if (cardSource.IsDigimon)
  236. {
  237. if (cardSource.CardNames_DigiXros.Contains("MetalGreymon"))
  238. {
  239. if (cardSource.HasCardColor(CardColor.Blue))
  240. {
  241. return true;
  242. }
  243. }
  244. }
  245. }
  246. }
  247. return false;
  248. }
  249. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "DarkKnightmon");
  250. bool CanSelectCardCondition1(CardSource cardSource)
  251. {
  252. if (cardSource != null)
  253. {
  254. if (cardSource.Owner == card.Owner)
  255. {
  256. if (cardSource.IsDigimon)
  257. {
  258. if (cardSource.CardNames_DigiXros.Contains("DarkKnightmon"))
  259. {
  260. return true;
  261. }
  262. }
  263. }
  264. }
  265. return false;
  266. }
  267. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  268. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  269. return digiXrosCondition;
  270. }
  271. return null;
  272. }
  273. }
  274. return cardEffects;
  275. }
  276. }
  277. }