EX5_026.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_026 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.None)
  11. {
  12. bool PermanentCondition(Permanent targetPermanent)
  13. {
  14. return targetPermanent.TopCard.CardNames.Contains("MetalGarurumon");
  15. }
  16. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  17. }
  18. if (timing == EffectTiming.None)
  19. {
  20. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  21. }
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Opponent's Digimon gain effects", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[When Digivolving] If [MetalGarurumon] or [X Antibody] is in this Digimon's digivolution cards, until the end of your opponent's turn, all of their Digimon gain \"[When Attacking] Lose 4 memory\".";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleArea(card))
  39. {
  40. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("MetalGarurumon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  48. {
  49. bool PermanentCondition(Permanent permanent)
  50. {
  51. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  52. {
  53. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  54. {
  55. return true;
  56. }
  57. }
  58. return false;
  59. }
  60. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaPermanents())
  61. {
  62. if (PermanentCondition(permanent))
  63. {
  64. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  65. }
  66. }
  67. AddSkillClass addSkillClass = new AddSkillClass();
  68. addSkillClass.SetUpICardEffect("Memory -4", CanUseCondition1, card);
  69. addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects);
  70. card.Owner.UntilOpponentTurnEndEffects.Add((_timing) => addSkillClass);
  71. bool CanUseCondition1(Hashtable hashtable)
  72. {
  73. return true;
  74. }
  75. bool CardSourceCondition(CardSource cardSource)
  76. {
  77. if (PermanentCondition(cardSource.PermanentOfThisCard()))
  78. {
  79. if (cardSource == cardSource.PermanentOfThisCard().TopCard)
  80. {
  81. return true;
  82. }
  83. }
  84. return false;
  85. }
  86. List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
  87. {
  88. if (_timing == EffectTiming.OnAllyAttack)
  89. {
  90. ActivateClass activateClass1 = new ActivateClass();
  91. activateClass1.SetUpICardEffect("Memory -4", CanUseCondition2, cardSource);
  92. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  93. cardEffects.Add(activateClass1);
  94. if (cardSource.PermanentOfThisCard() != null)
  95. {
  96. activateClass1.SetEffectSourcePermanent(cardSource.PermanentOfThisCard());
  97. }
  98. string EffectDiscription1()
  99. {
  100. return "[When Attacking] Lose 4 memory.";
  101. }
  102. bool CanUseCondition2(Hashtable hashtable)
  103. {
  104. if (CardSourceCondition(cardSource))
  105. {
  106. if (CardEffectCommons.CanTriggerOnAttack(hashtable, cardSource))
  107. {
  108. return true;
  109. }
  110. }
  111. return false;
  112. }
  113. bool CanActivateCondition1(Hashtable hashtable)
  114. {
  115. if (CardEffectCommons.IsExistOnBattleArea(cardSource))
  116. {
  117. return true;
  118. }
  119. return false;
  120. }
  121. IEnumerator ActivateCoroutine1(Hashtable _hashtable)
  122. {
  123. yield return ContinuousController.instance.StartCoroutine(cardSource.Owner.AddMemory(-4, activateClass1));
  124. }
  125. }
  126. return cardEffects;
  127. }
  128. }
  129. }
  130. if (timing == EffectTiming.OnAllyAttack)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Return 1 card from trash to the bottom of deck to delete 1 Digimon", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  135. cardEffects.Add(activateClass);
  136. string EffectDiscription()
  137. {
  138. return "[When Attacking] By returning 1 Digimon card from your trash to the bottom of the deck, delete 1 of your opponent's Digimon with the same level as that card.";
  139. }
  140. bool CanSelectCardCondition(CardSource cardSource)
  141. {
  142. return cardSource.IsDigimon;
  143. }
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  147. }
  148. bool CanActivateCondition(Hashtable hashtable)
  149. {
  150. if (CardEffectCommons.IsExistOnBattleArea(card))
  151. {
  152. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  153. {
  154. return true;
  155. }
  156. }
  157. return false;
  158. }
  159. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  160. {
  161. CardSource deckBottomCard = null;
  162. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  163. {
  164. int maxCount = 1;
  165. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  166. selectCardEffect.SetUp(
  167. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  168. canTargetCondition_ByPreSelecetedList: null,
  169. canEndSelectCondition: null,
  170. canNoSelect: () => true,
  171. selectCardCoroutine: null,
  172. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  173. message: "Select cards to place at the bottom of the deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  174. maxCount: maxCount,
  175. canEndNotMax: false,
  176. isShowOpponent: false,
  177. mode: SelectCardEffect.Mode.Custom,
  178. root: SelectCardEffect.Root.Trash,
  179. customRootCardList: null,
  180. canLookReverseCard: true,
  181. selectPlayer: card.Owner,
  182. cardEffect: activateClass);
  183. selectCardEffect.SetNotShowCard();
  184. selectCardEffect.SetNotAddLog();
  185. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  186. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  187. {
  188. if (cardSources.Count == 1)
  189. {
  190. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  191. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Card", true, true));
  192. deckBottomCard = cardSources[0];
  193. }
  194. }
  195. }
  196. if (deckBottomCard != null)
  197. {
  198. bool CanSelectPermanentCondition(Permanent permanent)
  199. {
  200. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  201. {
  202. if (permanent.Level == deckBottomCard.Level)
  203. {
  204. if (permanent.TopCard.HasLevel)
  205. {
  206. if (deckBottomCard.HasLevel)
  207. {
  208. return true;
  209. }
  210. }
  211. }
  212. }
  213. return false;
  214. }
  215. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  216. {
  217. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  218. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  219. selectPermanentEffect.SetUp(
  220. selectPlayer: card.Owner,
  221. canTargetCondition: CanSelectPermanentCondition,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. maxCount: maxCount,
  225. canNoSelect: false,
  226. canEndNotMax: false,
  227. selectPermanentCoroutine: null,
  228. afterSelectPermanentCoroutine: null,
  229. mode: SelectPermanentEffect.Mode.Destroy,
  230. cardEffect: activateClass);
  231. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  232. }
  233. }
  234. }
  235. }
  236. return cardEffects;
  237. }
  238. }