EX5_074.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class EX5_074 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 6)
  18. {
  19. if (targetPermanent.TopCard.CardTraits.Contains("Four Sovereigns"))
  20. {
  21. return true;
  22. }
  23. if (targetPermanent.TopCard.CardTraits.Contains("FourSovereigns"))
  24. {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  31. }
  32. if (timing == EffectTiming.OnEnterFieldAnyone)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("Return cards from trash to the bottom of deck to reduce opponent's Digimon's DP", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  37. cardEffects.Add(activateClass);
  38. string EffectDiscription()
  39. {
  40. return "[On Play] By returning up to 4 cards with the [Deva]/[Four Sovereigns] trait from your trash to the bottom of the deck, for each one, all your opponent's Digimon get -4000 DP for the turn.";
  41. }
  42. bool CanSelectCardCondition(CardSource cardSource)
  43. {
  44. if (cardSource.CardTraits.Contains("Deva"))
  45. {
  46. return true;
  47. }
  48. if (cardSource.CardTraits.Contains("Four Sovereigns"))
  49. {
  50. return true;
  51. }
  52. if (cardSource.CardTraits.Contains("FourSovereigns"))
  53. {
  54. return true;
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  74. {
  75. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  76. {
  77. int maxCount = Math.Min(4, card.Owner.TrashCards.Count(CanSelectCardCondition));
  78. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  79. selectCardEffect.SetUp(
  80. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: CanEndSelectCondition,
  83. canNoSelect: () => true,
  84. selectCardCoroutine: null,
  85. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  86. 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).",
  87. maxCount: maxCount,
  88. canEndNotMax: true,
  89. isShowOpponent: false,
  90. mode: SelectCardEffect.Mode.Custom,
  91. root: SelectCardEffect.Root.Trash,
  92. customRootCardList: null,
  93. canLookReverseCard: true,
  94. selectPlayer: card.Owner,
  95. cardEffect: activateClass);
  96. selectCardEffect.SetNotShowCard();
  97. selectCardEffect.SetNotAddLog();
  98. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  99. bool CanEndSelectCondition(List<CardSource> cardSources)
  100. {
  101. if (CardEffectCommons.HasNoElement(cardSources))
  102. {
  103. return false;
  104. }
  105. return true;
  106. }
  107. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  108. {
  109. if (cardSources.Count >= 1)
  110. {
  111. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  112. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  113. int minusDP = 4000 * cardSources.Count;
  114. bool PermanentCondition(Permanent permanent)
  115. {
  116. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  117. }
  118. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDPPlayerEffect(
  119. permanentCondition: PermanentCondition,
  120. changeValue: -minusDP,
  121. effectDuration: EffectDuration.UntilEachTurnEnd,
  122. activateClass: activateClass));
  123. }
  124. }
  125. }
  126. }
  127. }
  128. if (timing == EffectTiming.OnAllyAttack)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect("Return cards from trash to the bottom of deck to reduce opponent's Digimon's DP", CanUseCondition, card);
  132. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  133. cardEffects.Add(activateClass);
  134. string EffectDiscription()
  135. {
  136. return "[When Attacking] By returning up to 4 cards with the [Deva]/[Four Sovereigns] trait from your trash to the bottom of the deck, for each one, all your opponent's Digimon get -4000 DP for the turn.";
  137. }
  138. bool CanSelectCardCondition(CardSource cardSource)
  139. {
  140. if (cardSource.CardTraits.Contains("Deva"))
  141. {
  142. return true;
  143. }
  144. if (cardSource.CardTraits.Contains("Four Sovereigns"))
  145. {
  146. return true;
  147. }
  148. if (cardSource.CardTraits.Contains("FourSovereigns"))
  149. {
  150. return true;
  151. }
  152. return false;
  153. }
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  157. }
  158. bool CanActivateCondition(Hashtable hashtable)
  159. {
  160. if (CardEffectCommons.IsExistOnBattleArea(card))
  161. {
  162. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  163. {
  164. return true;
  165. }
  166. }
  167. return false;
  168. }
  169. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  170. {
  171. if (card.Owner.TrashCards.Count(CanSelectCardCondition) >= 1)
  172. {
  173. int maxCount = Math.Min(4, card.Owner.TrashCards.Count(CanSelectCardCondition));
  174. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  175. selectCardEffect.SetUp(
  176. canTargetCondition: (cardSource) => CanSelectCardCondition(cardSource),
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: CanEndSelectCondition,
  179. canNoSelect: () => true,
  180. selectCardCoroutine: null,
  181. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  182. 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).",
  183. maxCount: maxCount,
  184. canEndNotMax: true,
  185. isShowOpponent: false,
  186. mode: SelectCardEffect.Mode.Custom,
  187. root: SelectCardEffect.Root.Trash,
  188. customRootCardList: null,
  189. canLookReverseCard: true,
  190. selectPlayer: card.Owner,
  191. cardEffect: activateClass);
  192. selectCardEffect.SetNotShowCard();
  193. selectCardEffect.SetNotAddLog();
  194. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  195. bool CanEndSelectCondition(List<CardSource> cardSources)
  196. {
  197. if (CardEffectCommons.HasNoElement(cardSources))
  198. {
  199. return false;
  200. }
  201. return true;
  202. }
  203. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  204. {
  205. if (cardSources.Count >= 1)
  206. {
  207. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  208. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(cardSources, "Deck Bottom Cards", true, true));
  209. int minusDP = 4000 * cardSources.Count;
  210. bool PermanentCondition(Permanent permanent)
  211. {
  212. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  213. }
  214. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDPPlayerEffect(
  215. permanentCondition: PermanentCondition,
  216. changeValue: -minusDP,
  217. effectDuration: EffectDuration.UntilEachTurnEnd,
  218. activateClass: activateClass));
  219. }
  220. }
  221. }
  222. }
  223. }
  224. if (timing == EffectTiming.OnAllyAttack)
  225. {
  226. ActivateClass activateClass = new ActivateClass();
  227. activateClass.SetUpICardEffect("Trash the top cards of opponent's security", CanUseCondition, card);
  228. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  229. cardEffects.Add(activateClass);
  230. string EffectDiscription()
  231. {
  232. return "[When Attacking] For each of your Digimon with the [Four Sovereigns] trait, trash the top card of your opponent's security stack.";
  233. }
  234. bool CanUseCondition(Hashtable hashtable)
  235. {
  236. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  237. }
  238. bool CanActivateCondition(Hashtable hashtable)
  239. {
  240. if (CardEffectCommons.IsExistOnBattleArea(card))
  241. {
  242. if (card.Owner.Enemy.SecurityCards.Count >= 1)
  243. {
  244. if (card.Owner.GetBattleAreaDigimons().Some(permanent =>
  245. permanent.TopCard.CardTraits.Contains("Four Sovereigns")
  246. || permanent.TopCard.CardTraits.Contains("FourSovereigns")))
  247. {
  248. return true;
  249. }
  250. }
  251. }
  252. return false;
  253. }
  254. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  255. {
  256. int trashCount = card.Owner.GetBattleAreaDigimons().Count(permanent =>
  257. permanent.TopCard.CardTraits.Contains("Four Sovereigns")
  258. || permanent.TopCard.CardTraits.Contains("FourSovereigns"));
  259. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  260. player: card.Owner.Enemy,
  261. destroySecurityCount: trashCount,
  262. cardEffect: activateClass,
  263. fromTop: true).DestroySecurity());
  264. }
  265. }
  266. if (timing == EffectTiming.None)
  267. {
  268. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  269. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseCondition, card);
  270. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  271. cardEffects.Add(canNotAffectedClass);
  272. bool CanUseCondition(Hashtable hashtable)
  273. {
  274. if (CardEffectCommons.IsExistOnBattleArea(card))
  275. {
  276. return true;
  277. }
  278. return false;
  279. }
  280. bool CardCondition(CardSource cardSource)
  281. {
  282. if (cardSource == card)
  283. {
  284. if (CardEffectCommons.IsExistOnBattleArea(card))
  285. {
  286. if (cardSource == card.PermanentOfThisCard().TopCard)
  287. {
  288. return true;
  289. }
  290. }
  291. }
  292. return false;
  293. }
  294. bool SkillCondition(ICardEffect cardEffect)
  295. {
  296. if (CardEffectCommons.IsOpponentEffect(cardEffect, card))
  297. {
  298. if (cardEffect.IsDigimonEffect)
  299. {
  300. return true;
  301. }
  302. if (cardEffect.IsDigimonEffect && cardEffect.IsSecurityEffect)
  303. {
  304. return true;
  305. }
  306. }
  307. return false;
  308. }
  309. }
  310. return cardEffects;
  311. }
  312. }