EX9_057.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Abbadomon Core
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_057 : 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 Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.EqualsCardName("Abbadomon"))
  18. {
  19. return true;
  20. }
  21. return false;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  24. }
  25. #endregion
  26. #region Collision, Piercing, Security Atk +1, Reboot, Blocker
  27. if (timing == EffectTiming.OnCounterTiming)
  28. {
  29. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  30. }
  31. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  32. {
  33. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  34. }
  35. if (timing == EffectTiming.None)
  36. {
  37. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  38. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  39. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  40. }
  41. #endregion
  42. #region Breeding - Opponents Turn
  43. if (timing == EffectTiming.OnAllyAttack)
  44. {
  45. ActivateClass activateClass = new ActivateClass();
  46. activateClass.SetUpICardEffect("Return 4 Digi-Egg [Negamon] to Digi-Egg deck, to move to battle area.", CanUseCondition, card);
  47. activateClass.SetUpActivateClass(CanActivateBreedingCondition, ActivateCoroutine, -1, false, EffectDiscription());
  48. activateClass.SetIsSkippable(true);
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "[Breeding] [Opponent's Turn] When one of your opponent's Digimon attacks, by returning 4 [Negamon] from your trash or your Digimon's digivolution cards to the bottom of the Digi-Egg deck, this Digimon moves to the battle area.";
  53. }
  54. int NegamonCount()
  55. {
  56. int value = 0;
  57. value += CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition);
  58. foreach (Permanent perm in card.Owner.GetBattleAreaDigimons())
  59. {
  60. value += perm.DigivolutionCards.Count(CanSelectCardCondition);
  61. }
  62. return value;
  63. }
  64. bool PermanentCondition(Permanent permanent)
  65. {
  66. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  67. }
  68. bool CanSelectCardCondition(CardSource cardSource)
  69. {
  70. return cardSource.IsDigiEgg &&
  71. cardSource.EqualsCardName("Negamon");
  72. }
  73. bool CanUseCondition(Hashtable hashtable)
  74. {
  75. if (CardEffectCommons.IsExistOnBreedingAreaDigimon(card))
  76. {
  77. if (CardEffectCommons.IsOpponentTurn(card))
  78. {
  79. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  80. {
  81. return (NegamonCount() >= 4);
  82. }
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanActivateBreedingCondition(Hashtable hashtable)
  88. {
  89. if (CardEffectCommons.IsExistOnBreedingAreaDigimon(card))
  90. {
  91. return card.PermanentOfThisCard().CanMove;
  92. }
  93. return false;
  94. }
  95. IEnumerator ActivateCoroutine(Hashtable hashtable)
  96. {
  97. List<CardSource> selectedCards = new List<CardSource>();
  98. List<CardSource> negamonCards = new List<CardSource>();
  99. negamonCards.AddRange(card.Owner.TrashCards.Where(CanSelectCardCondition));
  100. foreach (Permanent perm in card.Owner.GetBattleAreaDigimons())
  101. {
  102. negamonCards.AddRange(perm.DigivolutionCards.Where(CanSelectCardCondition));
  103. }
  104. if (negamonCards.Count >= 4)
  105. {
  106. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  107. {
  108. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  109. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  110. };
  111. string selectPlayerMessage = "Will you return 4 [Negamon] back to Digi-Egg deck?";
  112. string notSelectPlayerMessage = "The opponent is choosing whether or not to return 4 [Negamon].";
  113. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  114. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  115. bool willReturn = GManager.instance.userSelectionManager.SelectedBoolValue;
  116. if (willReturn)
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(negamonCards));
  119. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect(negamonCards, "Digi-Egg deck Bottom Cards", true, true));
  120. if (card.Owner.CanMove)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(CardObjectController.MovePermanent(card.Owner.GetBreedingAreaPermanents()[0].PermanentFrame));
  123. }
  124. }
  125. }
  126. }
  127. }
  128. #endregion
  129. #region When Moving/When Digivolving/When Attacking Shared
  130. bool SourceCondition(CardSource source)
  131. {
  132. return source.IsDigimon &&
  133. source.HasLevel && source.Level <= 6 &&
  134. source.HasText("Negamon");
  135. }
  136. bool OpponentMinLevelPermanentCondition(Permanent permanent)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  139. CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  140. }
  141. bool CanActivateCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  144. CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, SourceCondition) >= 3;
  145. }
  146. #endregion
  147. #region When Moving
  148. if (timing == EffectTiming.OnMove)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("By placing 3 Digimon as sources, delete opponents lowest level digimon", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  153. activateClass.SetIsDigimonEffect(true);
  154. cardEffects.Add(activateClass);
  155. string EffectDiscription()
  156. {
  157. return "[When Moving] By placing 3 level 6 or lower Digimon cards with [Negamon] in their texts from your trash as this Digimon's top digivolution cards, delete all of your opponent's lowest level Digimon.";
  158. }
  159. bool PermanentCondition(Permanent permanent)
  160. {
  161. return permanent == card.PermanentOfThisCard();
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.CanTriggerOnMove(hashtable, PermanentCondition);
  166. }
  167. IEnumerator ActivateCoroutine(Hashtable hashtable)
  168. {
  169. bool sourcesAdded = false;
  170. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  171. selectCardEffect.SetUp(
  172. canTargetCondition: SourceCondition,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. canNoSelect: () => true,
  176. selectCardCoroutine: null,
  177. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  178. message: "Select cards to place as the top digivolution sources",
  179. maxCount: 3,
  180. canEndNotMax: false,
  181. isShowOpponent: false,
  182. mode: SelectCardEffect.Mode.Custom,
  183. root: SelectCardEffect.Root.Trash,
  184. customRootCardList: null,
  185. canLookReverseCard: true,
  186. selectPlayer: card.Owner,
  187. cardEffect: activateClass);
  188. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  189. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  190. {
  191. if (cardSources.Count >= 3)
  192. {
  193. cardSources.Reverse();
  194. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  195. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(cardSources, activateClass));
  196. sourcesAdded = true;
  197. }
  198. }
  199. if (sourcesAdded)
  200. {
  201. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(OpponentMinLevelPermanentCondition);
  202. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  203. destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  204. }
  205. }
  206. }
  207. #endregion
  208. #region When Digivolving
  209. if (timing == EffectTiming.OnEnterFieldAnyone)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect("By placing 3 Digimon as sources, delete opponents lowest level digimon", CanUseCondition, card);
  213. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  214. cardEffects.Add(activateClass);
  215. string EffectDiscription()
  216. {
  217. return "[When Digivolving] By placing 3 level 6 or lower Digimon cards with [Negamon] in their texts from your trash as this Digimon's top digivolution cards, delete all of your opponent's lowest level Digimon.";
  218. }
  219. bool CanUseCondition(Hashtable hashtable)
  220. {
  221. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  222. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  223. }
  224. IEnumerator ActivateCoroutine(Hashtable hashtable)
  225. {
  226. bool sourcesAdded = false;
  227. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  228. selectCardEffect.SetUp(
  229. canTargetCondition: SourceCondition,
  230. canTargetCondition_ByPreSelecetedList: null,
  231. canEndSelectCondition: null,
  232. canNoSelect: () => true,
  233. selectCardCoroutine: null,
  234. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  235. message: "Select cards to place as the top digivolution sources",
  236. maxCount: 3,
  237. canEndNotMax: false,
  238. isShowOpponent: false,
  239. mode: SelectCardEffect.Mode.Custom,
  240. root: SelectCardEffect.Root.Trash,
  241. customRootCardList: null,
  242. canLookReverseCard: true,
  243. selectPlayer: card.Owner,
  244. cardEffect: activateClass);
  245. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  246. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  247. {
  248. if (cardSources.Count >= 3)
  249. {
  250. cardSources.Reverse();
  251. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  252. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(cardSources, activateClass));
  253. sourcesAdded = true;
  254. }
  255. }
  256. if (sourcesAdded)
  257. {
  258. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(OpponentMinLevelPermanentCondition);
  259. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  260. destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  261. }
  262. }
  263. }
  264. #endregion
  265. #region When Attacking
  266. if (timing == EffectTiming.OnAllyAttack)
  267. {
  268. ActivateClass activateClass = new ActivateClass();
  269. activateClass.SetUpICardEffect("By placing 3 Digimon as sources, delete opponents lowest level digimon", CanUseCondition, card);
  270. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  271. cardEffects.Add(activateClass);
  272. string EffectDiscription()
  273. {
  274. return "[When Attacking] By placing 3 level 6 or lower Digimon cards with [Negamon] in their texts from your trash as this Digimon's top digivolution cards, delete all of your opponent's lowest level Digimon.";
  275. }
  276. bool CanUseCondition(Hashtable hashtable)
  277. {
  278. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  279. }
  280. IEnumerator ActivateCoroutine(Hashtable hashtable)
  281. {
  282. bool sourcesAdded = false;
  283. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  284. selectCardEffect.SetUp(
  285. canTargetCondition: SourceCondition,
  286. canTargetCondition_ByPreSelecetedList: null,
  287. canEndSelectCondition: null,
  288. canNoSelect: () => true,
  289. selectCardCoroutine: null,
  290. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  291. message: "Select cards to place as the top digivolution sources",
  292. maxCount: 3,
  293. canEndNotMax: false,
  294. isShowOpponent: false,
  295. mode: SelectCardEffect.Mode.Custom,
  296. root: SelectCardEffect.Root.Trash,
  297. customRootCardList: null,
  298. canLookReverseCard: true,
  299. selectPlayer: card.Owner,
  300. cardEffect: activateClass);
  301. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  302. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  303. {
  304. if (cardSources.Count >= 3)
  305. {
  306. cardSources.Reverse();
  307. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  308. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(cardSources, activateClass));
  309. sourcesAdded = true;
  310. }
  311. }
  312. if (sourcesAdded)
  313. {
  314. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(OpponentMinLevelPermanentCondition);
  315. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  316. destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  317. }
  318. }
  319. }
  320. #endregion
  321. return cardEffects;
  322. }
  323. }
  324. }