BT17_073.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_073 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("Dorugoramon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false,
  20. card: card, condition: null));
  21. }
  22. #endregion
  23. #region Trash - All Turns
  24. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect(
  28. "Digivolve into [Dorugoramon] into [DexDorugoramon] from your trash to prevent deletion",
  29. CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  31. activateClass.SetHashString("DigivolveIntoDex_BT17_073");
  32. cardEffects.Add(activateClass);
  33. string EffectDescription()
  34. {
  35. return
  36. "[All Turns] When one of your [Dorugoramon] would be deleted, by digivolving it into this card without paying the cost, prevent that deletion.";
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnTrash(card) &&
  41. CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsOwnerPermanentCondition);
  42. }
  43. bool IsOwnerPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  46. permanent.TopCard.EqualsCardName("Dorugoramon") &&
  47. card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash);
  48. }
  49. bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent)
  50. {
  51. return IsOwnerPermanentCondition(permanent) && permanent.willBeRemoveField;
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnTrash(card) &&
  56. CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentCondition);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentToBeDeletedCondition))
  61. {
  62. Permanent selectedPermanent = null;
  63. int maxCount = Math.Min(1,
  64. CardEffectCommons.MatchConditionPermanentCount(IsOwnerPermanentToBeDeletedCondition));
  65. SelectPermanentEffect selectPermanentEffect =
  66. GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: IsOwnerPermanentToBeDeletedCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: true,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: SelectPermanentCoroutine,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectPermanentEffect.SetUpCustomMessage(
  80. "Select 1 Digimon to digivolve.",
  81. "The opponent is selecting 1 Digimon to digivolve.");
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. selectedPermanent = permanent;
  86. yield return null;
  87. }
  88. if (selectedPermanent != null)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  91. targetPermanent: selectedPermanent,
  92. cardCondition: null,
  93. payCost: false,
  94. reduceCostTuple: null,
  95. fixedCostTuple: null,
  96. ignoreDigivolutionRequirementFixedCost: -1,
  97. isHand: false,
  98. activateClass: activateClass,
  99. successProcess: null,
  100. ignoreSelection: true));
  101. selectedPermanent.willBeRemoveField = false;
  102. selectedPermanent.HideDeleteEffect();
  103. }
  104. }
  105. }
  106. }
  107. #endregion
  108. #region When Digivolving
  109. if (timing == EffectTiming.OnEnterFieldAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("<De-Digivolve 3> and delete all of your opponent's Digimon with the lowest level",
  113. CanUseCondition, card);
  114. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  115. cardEffects.Add(activateClass);
  116. string EffectDescription()
  117. {
  118. return
  119. "[When Digivolving] <De-Digivolve 3> 1 of your opponent's Digimon (Trash up to 3 cards from the top. You can't trash past level 3 cards). Then, if [Dorugoramon] is in this Digimon's digivolution cards or this card is digivolving from the trash, delete all of your opponent's Digimon with the lowest level.";
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  124. }
  125. bool IsDoruCardCondition(CardSource cardSource)
  126. {
  127. return cardSource.IsDigimon &&
  128. cardSource.EqualsCardName("Dorugoramon");
  129. }
  130. bool TrashRootCondition(SelectCardEffect.Root root)
  131. {
  132. return root == SelectCardEffect.Root.Trash;
  133. }
  134. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  135. {
  136. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  137. }
  138. bool OpponentMinLevelPermanentCondition(Permanent permanent)
  139. {
  140. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  141. CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  142. }
  143. bool CanActivateCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleArea(card) &&
  146. CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition);
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  151. {
  152. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  153. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  154. selectPermanentEffect.SetUp(
  155. selectPlayer: card.Owner,
  156. canTargetCondition: CanSelectOpponentPermanentCondition,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. maxCount: maxCount,
  160. canNoSelect: false,
  161. canEndNotMax: false,
  162. selectPermanentCoroutine: SelectPermanentCoroutine,
  163. afterSelectPermanentCoroutine: null,
  164. mode: SelectPermanentEffect.Mode.Custom,
  165. cardEffect: activateClass);
  166. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  167. "The opponent is selecting 1 Digimon to De-Digivolve.");
  168. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  169. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  170. {
  171. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 3, activateClass)
  172. .Degeneration());
  173. }
  174. }
  175. if (card.PermanentOfThisCard().DigivolutionCards.Some(IsDoruCardCondition) ||
  176. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card, TrashRootCondition))
  177. {
  178. List<Permanent> destroyTargetPermanents =
  179. card.Owner.Enemy.GetBattleAreaDigimons().Filter(OpponentMinLevelPermanentCondition);
  180. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  181. destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  182. }
  183. }
  184. }
  185. #endregion
  186. #region All Turns
  187. if (timing == EffectTiming.OnDestroyedAnyone)
  188. {
  189. ActivateClass activateClass = new ActivateClass();
  190. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  191. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  192. activateClass.SetHashString("BT17_073_Unsuspend");
  193. cardEffects.Add(activateClass);
  194. string EffectDescription()
  195. {
  196. return "[All Turns] (Once Per Turn) When another Digimon is deleted, you may unsuspend this Digimon.";
  197. }
  198. bool PermanentCondition(Permanent permanent)
  199. {
  200. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent) &&
  201. permanent.IsDigimon &&
  202. permanent != card.PermanentOfThisCard();
  203. }
  204. bool CanUseCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.IsExistOnBattleArea(card) &&
  207. CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass);
  208. }
  209. bool CanActivateCondition(Hashtable hashtable)
  210. {
  211. return CardEffectCommons.IsExistOnBattleArea(card) &&
  212. CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()) &&
  213. CardEffectCommons.GetHashtablesFromHashtable(hashtable) is { Count: >= 1 };
  214. }
  215. IEnumerator ActivateCoroutine(Hashtable hashtable)
  216. {
  217. yield return ContinuousController.instance.StartCoroutine(
  218. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  219. }
  220. }
  221. #endregion
  222. return cardEffects;
  223. }
  224. }
  225. }