EX4_020.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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_020 : 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("This Digimon gains Rush and trash digivolution cards", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] This Digimon gains <Rush> for the turn. (This Digimon may attack the turn it was played.) If DigiXrosing, trash up to 2 digivolution cards of 1 of your opponent's Digimon.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  25. {
  26. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. return true;
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(
  52. targetPermanent: card.PermanentOfThisCard(),
  53. effectDuration: EffectDuration.UntilEachTurnEnd,
  54. activateClass: activateClass));
  55. if (CardEffectCommons.IsDijiXros(_hashtable, card, (digixrosCount) => digixrosCount >= 1))
  56. {
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: CanSelectPermanentCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: maxCount,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  76. {
  77. Permanent selectedPermanent = permanent;
  78. if (selectedPermanent != null)
  79. {
  80. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1 && !selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  81. {
  82. maxCount = Math.Min(2, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  83. List<CardSource> selectedCards = new List<CardSource>();
  84. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  85. selectCardEffect.SetUp(
  86. canTargetCondition: CanSelectCardCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: CanEndSelectCondition,
  89. canNoSelect: () => false,
  90. selectCardCoroutine: SelectCardCoroutine,
  91. afterSelectCardCoroutine: null,
  92. message: "Select digivolution cards to trash.",
  93. maxCount: maxCount,
  94. canEndNotMax: true,
  95. isShowOpponent: true,
  96. mode: SelectCardEffect.Mode.Custom,
  97. root: SelectCardEffect.Root.Custom,
  98. customRootCardList: selectedPermanent.DigivolutionCards,
  99. canLookReverseCard: true,
  100. selectPlayer: card.Owner,
  101. cardEffect: activateClass);
  102. selectCardEffect.SetUpCustomMessage("Select digivolution cards to trash.", "The opponent is selecting digivolution cards to trash.");
  103. yield return StartCoroutine(selectCardEffect.Activate());
  104. bool CanEndSelectCondition(List<CardSource> cardSources)
  105. {
  106. if (CardEffectCommons.HasNoElement(cardSources))
  107. {
  108. return false;
  109. }
  110. return true;
  111. }
  112. IEnumerator SelectCardCoroutine(CardSource cardSource)
  113. {
  114. selectedCards.Add(cardSource);
  115. yield return null;
  116. }
  117. if (selectedCards.Count >= 1)
  118. {
  119. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(
  120. selectedPermanent,
  121. selectedCards,
  122. activateClass).TrashDigivolutionCards());
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  132. {
  133. cardEffects.Add(CardEffectFactory.MaterialSaveEffect(card: card, materialSaveCount: 2));
  134. }
  135. if (timing == EffectTiming.None)
  136. {
  137. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  138. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  139. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  140. addDigiXrosConditionClass.SetNotShowUI(true);
  141. cardEffects.Add(addDigiXrosConditionClass);
  142. bool CanUseCondition(Hashtable hashtable)
  143. {
  144. return true;
  145. }
  146. DigiXrosCondition GetDigiXros(CardSource cardSource)
  147. {
  148. if (cardSource == card)
  149. {
  150. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Blue Greymon");
  151. bool CanSelectCardCondition(CardSource cardSource)
  152. {
  153. if (cardSource != null)
  154. {
  155. if (cardSource.Owner == card.Owner)
  156. {
  157. if (cardSource.IsDigimon)
  158. {
  159. if (cardSource.CardNames_DigiXros.Contains("Greymon"))
  160. {
  161. if (cardSource.HasCardColor(CardColor.Blue))
  162. {
  163. return true;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. return false;
  170. }
  171. DigiXrosConditionElement element1 = new DigiXrosConditionElement(CanSelectCardCondition1, "MailBirdramon");
  172. bool CanSelectCardCondition1(CardSource cardSource)
  173. {
  174. if (cardSource != null)
  175. {
  176. if (cardSource.Owner == card.Owner)
  177. {
  178. if (cardSource.IsDigimon)
  179. {
  180. if (cardSource.CardNames_DigiXros.Contains("MailBirdramon"))
  181. {
  182. return true;
  183. }
  184. }
  185. }
  186. }
  187. return false;
  188. }
  189. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element, element1 };
  190. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  191. return digiXrosCondition;
  192. }
  193. return null;
  194. }
  195. }
  196. if (timing == EffectTiming.OnAllyAttack)
  197. {
  198. ActivateClass activateClass = new ActivateClass();
  199. activateClass.SetUpICardEffect("Opponent's 1 Digimon can't attack", CanUseCondition, card);
  200. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  201. activateClass.SetIsInheritedEffect(true);
  202. cardEffects.Add(activateClass);
  203. string EffectDiscription()
  204. {
  205. return "[When Attacking] If this Digimon is [GreyKnightsmon], 1 of your opponent's Digimon with 3 or fewer digivolution cards can't attack until the end of your opponent's turn.";
  206. }
  207. bool CanSelectPermanentCondition(Permanent permanent)
  208. {
  209. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  210. {
  211. if (permanent.DigivolutionCards.Count <= 3)
  212. {
  213. return true;
  214. }
  215. }
  216. return false;
  217. }
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  221. }
  222. bool CanActivateCondition(Hashtable hashtable)
  223. {
  224. if (CardEffectCommons.IsExistOnBattleArea(card))
  225. {
  226. if (card.PermanentOfThisCard().TopCard.CardNames.Contains("GreyKnightsmon"))
  227. {
  228. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  229. {
  230. return true;
  231. }
  232. }
  233. }
  234. return false;
  235. }
  236. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  237. {
  238. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  239. {
  240. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  241. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  242. selectPermanentEffect.SetUp(
  243. selectPlayer: card.Owner,
  244. canTargetCondition: CanSelectPermanentCondition,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canEndSelectCondition: null,
  247. maxCount: maxCount,
  248. canNoSelect: false,
  249. canEndNotMax: false,
  250. selectPermanentCoroutine: SelectPermanentCoroutine,
  251. afterSelectPermanentCoroutine: null,
  252. mode: SelectPermanentEffect.Mode.Custom,
  253. cardEffect: activateClass);
  254. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  255. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  256. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  257. {
  258. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  259. targetPermanent: permanent,
  260. defenderCondition: null,
  261. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  262. activateClass: activateClass,
  263. effectName: "Can't Attack"));
  264. }
  265. }
  266. }
  267. }
  268. return cardEffects;
  269. }
  270. }
  271. }