BT17_065.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_065 : 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("Dorugamon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition, digivolutionCost: 0, 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 [Dorugamon] into [DexDorugamon] from your trash to prevent deletion",
  29. CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  31. activateClass.SetHashString("DigivolveIntoDex_BT17_065");
  32. cardEffects.Add(activateClass);
  33. string EffectDescription()
  34. {
  35. return
  36. "[All Turns] When one of your [Dorugamon] 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("Dorugamon") &&
  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("Trash 1, Draw 1 and delete opponent's Digimon with play cost of 4 or less", CanUseCondition,
  113. card);
  114. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  115. cardEffects.Add(activateClass);
  116. string EffectDescription()
  117. {
  118. return
  119. "[When Digivolving] Trash 1 card in your hand. Then, <Draw 1>. If [Dorugamon] is in this Digimon's digivolution cards or this digivolved from the trash, delete 1 of your opponent's Digimon with a play cost of 4 or less instead.";
  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("Dorugamon");
  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. permanent.TopCard.HasPlayCost &&
  138. permanent.TopCard.GetCostItself <= 4;
  139. }
  140. bool CanActivateCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.IsExistOnBattleArea(card) &&
  143. (card.Owner.HandCards.Count >= 1 ||
  144. card.Owner.LibraryCards.Count >= 1 ||
  145. CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition));
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable hashtable)
  148. {
  149. if (card.Owner.HandCards.Count >= 1)
  150. {
  151. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  152. selectHandEffect.SetUp(
  153. selectPlayer: card.Owner,
  154. canTargetCondition: _ => true,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. maxCount: 1,
  158. canNoSelect: false,
  159. canEndNotMax: false,
  160. isShowOpponent: true,
  161. selectCardCoroutine: null,
  162. afterSelectCardCoroutine: null,
  163. mode: SelectHandEffect.Mode.Discard,
  164. cardEffect: activateClass);
  165. yield return StartCoroutine(selectHandEffect.Activate());
  166. }
  167. if(card.PermanentOfThisCard().DigivolutionCards.Some(IsDoruCardCondition) || CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card, TrashRootCondition))
  168. {
  169. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  170. {
  171. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  172. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  173. selectPermanentEffect.SetUp(
  174. selectPlayer: card.Owner,
  175. canTargetCondition: CanSelectOpponentPermanentCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. maxCount: maxCount,
  179. canNoSelect: false,
  180. canEndNotMax: false,
  181. selectPermanentCoroutine: null,
  182. afterSelectPermanentCoroutine: null,
  183. mode: SelectPermanentEffect.Mode.Destroy,
  184. cardEffect: activateClass);
  185. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  186. }
  187. }
  188. else
  189. {
  190. if (card.Owner.LibraryCards.Count >= 1)
  191. {
  192. yield return ContinuousController.instance.StartCoroutine(
  193. new DrawClass(card.Owner, 1, activateClass).Draw());
  194. }
  195. }
  196. }
  197. }
  198. #endregion
  199. #region Reboot - ESS
  200. if (timing == EffectTiming.None)
  201. {
  202. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  203. }
  204. #endregion
  205. return cardEffects;
  206. }
  207. }
  208. }