BT16_076.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT16
  4. {
  5. public class BT16_076 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Digivolve Condition
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.ContainsTraits("SoC") && targetPermanent.TopCard.HasLevel &&
  16. targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition,
  19. digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region When Digivolving
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect(
  27. "Delete an opponent's Digimon with 6000 DP or less, if the effect didn't delete, play a level 4 or lower [SoC] card.",
  28. CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  30. cardEffects.Add(activateClass);
  31. string EffectDescription()
  32. {
  33. return
  34. "[When Digivolving] By trashing 2 cards in your hand, delete 1 of your opponent's Digimon with 6000 DP or less. If this effect didn't delete, you may play 1 level 4 or lower card with the [SoC] trait from your trash without paying the cost.";
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  39. }
  40. bool CanSelectPermanentCondition(Permanent permanent)
  41. {
  42. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  43. {
  44. if (permanent.IsDigimon)
  45. {
  46. if (permanent.DP <= 6000)
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanSelectCardCondition(CardSource cardSource)
  55. {
  56. if (cardSource.HasLevel && !cardSource.IsLevel2 && cardSource.Level <= 4 && cardSource.ContainsTraits("SoC"))
  57. {
  58. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.IsExistOnBattleArea(card))
  68. {
  69. if (card.Owner.HandCards.Count >= 2)
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable hashtable)
  77. {
  78. bool discarded = false;
  79. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  80. if (card.Owner.HandCards.Count >= 2)
  81. {
  82. int discardCount = 2;
  83. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  84. selectHandEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: _ => true,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: discardCount,
  90. canNoSelect: false,
  91. canEndNotMax: false,
  92. isShowOpponent: true,
  93. selectCardCoroutine: null,
  94. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  95. mode: SelectHandEffect.Mode.Discard,
  96. cardEffect: activateClass);
  97. yield return StartCoroutine(selectHandEffect.Activate());
  98. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  99. {
  100. if (cardSources.Count >= 2)
  101. {
  102. discarded = true;
  103. yield return null;
  104. }
  105. }
  106. if (discarded)
  107. {
  108. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  109. {
  110. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  111. selectPermanentEffect.SetUp(
  112. canTargetCondition: CanSelectPermanentCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. canNoSelect: false,
  116. selectPermanentCoroutine: null,
  117. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  118. maxCount: 1,
  119. canEndNotMax: false,
  120. mode: SelectPermanentEffect.Mode.Custom,
  121. selectPlayer: card.Owner,
  122. cardEffect: activateClass);
  123. yield return StartCoroutine(selectPermanentEffect.Activate());
  124. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  125. {
  126. deleteTargetPermanents = permanents.Clone();
  127. yield return null;
  128. }
  129. }
  130. yield return ContinuousController.instance.StartCoroutine(
  131. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  132. targetPermanents: deleteTargetPermanents,
  133. activateClass: activateClass,
  134. successProcess: null,
  135. failureProcess: FailureProcess));
  136. IEnumerator FailureProcess()
  137. {
  138. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  139. {
  140. List<CardSource> selectedCards = new List<CardSource>();
  141. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  142. selectCardEffect.SetUp(
  143. canTargetCondition: CanSelectCardCondition,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. canNoSelect: () => true,
  147. selectCardCoroutine: SelectCardCoroutine,
  148. afterSelectCardCoroutine: null,
  149. message: "Select cards to play.",
  150. maxCount: 1,
  151. canEndNotMax: false,
  152. isShowOpponent: true,
  153. mode: SelectCardEffect.Mode.Custom,
  154. root: SelectCardEffect.Root.Trash,
  155. customRootCardList: null,
  156. canLookReverseCard: true,
  157. selectPlayer: card.Owner,
  158. cardEffect: activateClass);
  159. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.",
  160. "The opponent is selecting 1 trash card to play.");
  161. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  162. IEnumerator SelectCardCoroutine(CardSource cardSource)
  163. {
  164. selectedCards.Add(cardSource);
  165. yield return null;
  166. }
  167. yield return StartCoroutine(selectCardEffect.Activate());
  168. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  169. cardSources: selectedCards,
  170. activateClass: activateClass,
  171. payCost: false,
  172. isTapped: false,
  173. root: SelectCardEffect.Root.Trash,
  174. activateETB: true));
  175. }
  176. }
  177. }
  178. }
  179. yield return null;
  180. }
  181. }
  182. #endregion
  183. #region All Turns
  184. if (timing == EffectTiming.OnDestroyedAnyone)
  185. {
  186. ActivateClass activateClass = new ActivateClass();
  187. activateClass.SetUpICardEffect("Digivolve into [Fenriloogamon] from your trash.", CanUseCondition, card);
  188. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  189. cardEffects.Add(activateClass);
  190. string EffectDescription()
  191. {
  192. return
  193. "[All Turns] When one of your other Digimon with the [SoC] trait is deleted, this Digimon with a Tamer with the [SoC] trait in its digivolution cards may digivolve into [Fenriloogamon] from your trash without paying the cost.";
  194. }
  195. bool PermanentCondition(Permanent permanent)
  196. {
  197. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  198. {
  199. if (permanent != card.PermanentOfThisCard())
  200. {
  201. if (permanent.TopCard.CardTraits.Contains("SoC"))
  202. {
  203. return true;
  204. }
  205. }
  206. }
  207. return false;
  208. }
  209. bool CanUseCondition(Hashtable hashtable)
  210. {
  211. if (CardEffectCommons.IsExistOnBattleArea(card))
  212. {
  213. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  214. {
  215. return true;
  216. }
  217. }
  218. return false;
  219. }
  220. bool CanSelectFenriloogamonInTrash(CardSource cardSource)
  221. {
  222. return cardSource.EqualsCardName("Fenriloogamon");
  223. }
  224. bool CanActivateCondition(Hashtable hashtable)
  225. {
  226. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  227. {
  228. if (card.PermanentOfThisCard().DigivolutionCards
  229. .Some(cardSource => cardSource.CardTraits.Contains("SoC") && cardSource.IsTamer))
  230. {
  231. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectFenriloogamonInTrash))
  232. {
  233. return true;
  234. }
  235. }
  236. }
  237. return false;
  238. }
  239. IEnumerator ActivateCoroutine(Hashtable hashtable)
  240. {
  241. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  242. targetPermanent: card.PermanentOfThisCard(),
  243. cardCondition: CanSelectFenriloogamonInTrash,
  244. payCost: false,
  245. reduceCostTuple: null,
  246. fixedCostTuple: null,
  247. ignoreDigivolutionRequirementFixedCost: -1,
  248. isHand: false,
  249. activateClass: activateClass,
  250. successProcess: null));
  251. }
  252. }
  253. #endregion
  254. #region End of Attack - Inherited Effect
  255. if (timing == EffectTiming.OnEndAttack)
  256. {
  257. ActivateClass activateClass = new ActivateClass();
  258. activateClass.SetUpICardEffect("Unsuspend this Digimon.", CanUseCondition, card);
  259. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  260. activateClass.SetIsInheritedEffect(true);
  261. activateClass.SetHashString("Unsuspend_BT16_076");
  262. cardEffects.Add(activateClass);
  263. string EffectDescription()
  264. {
  265. return "[End of Attack] [Once Per Turn] If your opponent has 1 or more memory, unsuspend this Digimon.";
  266. }
  267. bool CanUseCondition(Hashtable hashtable)
  268. {
  269. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  270. }
  271. bool CanActivateCondition(Hashtable hashtable)
  272. {
  273. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  274. {
  275. if (card.Owner.Enemy.MemoryForPlayer >= 1)
  276. {
  277. return true;
  278. }
  279. }
  280. return false;
  281. }
  282. IEnumerator ActivateCoroutine(Hashtable hashtable)
  283. {
  284. Permanent selectedPermanent = card.PermanentOfThisCard();
  285. yield return ContinuousController.instance.StartCoroutine(
  286. new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  287. }
  288. }
  289. #endregion
  290. return cardEffects;
  291. }
  292. }
  293. }