EX5_061.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_061 : 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. static bool PermanentCondition(Permanent targetPermanent)
  13. {
  14. return targetPermanent.TopCard.ContainsCardName("Cerberusmon")
  15. && targetPermanent.TopCard.HasLevel
  16. && targetPermanent.TopCard.Level == 5
  17. && !targetPermanent.TopCard.HasXAntibodyTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnEnterFieldAnyone)
  22. {
  23. ActivateClass activateClass = new ActivateClass();
  24. activateClass.SetUpICardEffect("Play 1 purple level 3 Digimon from trash", CanUseCondition, card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  26. cardEffects.Add(activateClass);
  27. string EffectDiscription()
  28. {
  29. return "[On Play] You may play 1 purple level 3 Digimon card from your trash without paying the cost.";
  30. }
  31. bool CanSelectCardCondition(CardSource cardSource)
  32. {
  33. if (cardSource.IsDigimon)
  34. {
  35. if (cardSource.HasCardColor(CardColor.Purple))
  36. {
  37. if (cardSource.Level == 3)
  38. {
  39. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  40. {
  41. if (cardSource.HasLevel)
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  54. }
  55. bool CanActivateCondition(Hashtable hashtable)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  67. {
  68. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  69. {
  70. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  71. List<CardSource> selectedCards = new List<CardSource>();
  72. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  73. selectCardEffect.SetUp(
  74. canTargetCondition: CanSelectCardCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. canNoSelect: () => true,
  78. selectCardCoroutine: SelectCardCoroutine,
  79. afterSelectCardCoroutine: null,
  80. message: "Select 1 card to play.",
  81. maxCount: maxCount,
  82. canEndNotMax: false,
  83. isShowOpponent: true,
  84. mode: SelectCardEffect.Mode.Custom,
  85. root: SelectCardEffect.Root.Trash,
  86. customRootCardList: null,
  87. canLookReverseCard: true,
  88. selectPlayer: card.Owner,
  89. cardEffect: activateClass);
  90. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  91. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  92. yield return StartCoroutine(selectCardEffect.Activate());
  93. IEnumerator SelectCardCoroutine(CardSource cardSource)
  94. {
  95. selectedCards.Add(cardSource);
  96. yield return null;
  97. }
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  99. cardSources: selectedCards,
  100. activateClass: activateClass,
  101. payCost: false,
  102. isTapped: false,
  103. root: SelectCardEffect.Root.Trash,
  104. activateETB: true));
  105. }
  106. }
  107. }
  108. if (timing == EffectTiming.OnEnterFieldAnyone)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("Draw 1, trash 1 card from hand and activate [On Play] effect", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  113. cardEffects.Add(activateClass);
  114. string EffectDiscription()
  115. {
  116. return "[When Digivolving] <Draw 1> (Draw 1 card from your deck). Then, trash 1 card in your hand. If a Digimon card with [Cerberusmon] in its name or [X Antibody] is in this Digimon's digivolution cards, activate this Digimon's [On Play] effects.";
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. if (CardEffectCommons.IsExistOnBattleArea(card))
  125. {
  126. if (card.Owner.LibraryCards.Count >= 1)
  127. {
  128. return true;
  129. }
  130. if (card.Owner.HandCards.Count >= 1)
  131. {
  132. return true;
  133. }
  134. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) =>
  135. (cardSource.IsDigimon && cardSource.ContainsCardName("Cerberusmon"))
  136. || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  137. {
  138. return true;
  139. }
  140. }
  141. return false;
  142. }
  143. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  144. {
  145. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  146. if (card.Owner.HandCards.Count >= 1)
  147. {
  148. int discardCount = Math.Min(1, card.Owner.HandCards.Count);
  149. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  150. selectHandEffect.SetUp(
  151. selectPlayer: card.Owner,
  152. canTargetCondition: (cardSource) => true,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. maxCount: discardCount,
  156. canNoSelect: false,
  157. canEndNotMax: false,
  158. isShowOpponent: true,
  159. selectCardCoroutine: null,
  160. afterSelectCardCoroutine: null,
  161. mode: SelectHandEffect.Mode.Discard,
  162. cardEffect: activateClass);
  163. yield return StartCoroutine(selectHandEffect.Activate());
  164. }
  165. if (CardEffectCommons.IsExistOnBattleArea(card))
  166. {
  167. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) =>
  168. (cardSource.IsDigimon && cardSource.ContainsCardName("Cerberusmon"))
  169. || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  170. {
  171. Permanent selectedPermanent = card.PermanentOfThisCard();
  172. if (selectedPermanent != null)
  173. {
  174. List<ICardEffect> candidateEffects = selectedPermanent.EffectList(EffectTiming.OnEnterFieldAnyone)
  175. .Clone()
  176. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsOnPlay);
  177. if (candidateEffects.Count >= 1)
  178. {
  179. ICardEffect selectedEffect = null;
  180. if (candidateEffects.Count == 1)
  181. {
  182. selectedEffect = candidateEffects[0];
  183. }
  184. else
  185. {
  186. List<SkillInfo> skillInfos = candidateEffects
  187. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  188. List<CardSource> cardSources = candidateEffects
  189. .Map(cardEffect => cardEffect.EffectSourceCard);
  190. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  191. selectCardEffect.SetUp(
  192. canTargetCondition: (cardSource) => true,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. canNoSelect: () => false,
  196. selectCardCoroutine: null,
  197. afterSelectCardCoroutine: null,
  198. message: "Select 1 effect to activate.",
  199. maxCount: 1,
  200. canEndNotMax: false,
  201. isShowOpponent: false,
  202. mode: SelectCardEffect.Mode.Custom,
  203. root: SelectCardEffect.Root.Custom,
  204. customRootCardList: cardSources,
  205. canLookReverseCard: true,
  206. selectPlayer: card.Owner,
  207. cardEffect: activateClass);
  208. selectCardEffect.SetNotShowCard();
  209. selectCardEffect.SetUpSkillInfos(skillInfos);
  210. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  211. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  212. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  213. {
  214. if (selectedIndexes.Count == 1)
  215. {
  216. selectedEffect = candidateEffects[selectedIndexes[0]];
  217. yield return null;
  218. }
  219. }
  220. }
  221. if (selectedEffect != null)
  222. {
  223. if (selectedEffect.EffectSourceCard != null)
  224. {
  225. if (selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  226. {
  227. Hashtable effectHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  228. if (selectedEffect.CanUse(effectHashtable))
  229. {
  230. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. }
  241. if (timing == EffectTiming.OnAllyAttack)
  242. {
  243. ActivateClass activateClass = new ActivateClass();
  244. activateClass.SetUpICardEffect("Delete your another Digimon to unsuspend this Digimon", CanUseCondition, card);
  245. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  246. activateClass.SetIsInheritedEffect(true);
  247. activateClass.SetHashString("Unsuspend_EX5_061");
  248. cardEffects.Add(activateClass);
  249. string EffectDiscription()
  250. {
  251. return "[When Attacking] [Once Per Turn] By deleting 1 of your other Digimon, unsuspend this Digimon.";
  252. }
  253. bool CanSelectPermanentCondition(Permanent permanent)
  254. {
  255. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  256. {
  257. if (permanent != card.PermanentOfThisCard())
  258. {
  259. return true;
  260. }
  261. }
  262. return false;
  263. }
  264. bool CanUseCondition(Hashtable hashtable)
  265. {
  266. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  267. }
  268. bool CanActivateCondition(Hashtable hashtable)
  269. {
  270. if (CardEffectCommons.IsExistOnBattleArea(card))
  271. {
  272. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  273. {
  274. return true;
  275. }
  276. }
  277. return false;
  278. }
  279. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  280. {
  281. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  282. {
  283. int maxCount = Math.Min(1, card.Owner.GetBattleAreaDigimons().Count(CanSelectPermanentCondition));
  284. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  285. selectPermanentEffect.SetUp(
  286. selectPlayer: card.Owner,
  287. canTargetCondition: CanSelectPermanentCondition,
  288. canTargetCondition_ByPreSelecetedList: null,
  289. canEndSelectCondition: null,
  290. maxCount: maxCount,
  291. canNoSelect: true,
  292. canEndNotMax: false,
  293. selectPermanentCoroutine: SelectPermanentCoroutine,
  294. afterSelectPermanentCoroutine: null,
  295. mode: SelectPermanentEffect.Mode.Custom,
  296. cardEffect: activateClass);
  297. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  298. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  299. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  300. {
  301. Permanent thisCardPermanent = card.PermanentOfThisCard();
  302. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent },
  303. activateClass: activateClass,
  304. successProcess: permanents => SuccessProcess(),
  305. failureProcess: null));
  306. IEnumerator SuccessProcess()
  307. {
  308. if (thisCardPermanent.TopCard != null)
  309. {
  310. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { thisCardPermanent }, activateClass).Unsuspend());
  311. }
  312. }
  313. }
  314. }
  315. }
  316. }
  317. return cardEffects;
  318. }
  319. }