BT23_071.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Dullahamon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_071 : 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
  13. if (timing == EffectTiming.None)
  14. {
  15. bool Condition()
  16. {
  17. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, HasVioletInboots);
  18. }
  19. bool HasVioletInboots(Permanent targetPermanent)
  20. {
  21. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card) &&
  22. targetPermanent.TopCard.EqualsCardName("Violet Inboots");
  23. }
  24. bool PermanentCondition(Permanent targetPermanent)
  25. {
  26. return targetPermanent.TopCard.EqualsCardName("Phantomon");
  27. }
  28. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  29. permanentCondition: PermanentCondition,
  30. digivolutionCost: 6,
  31. ignoreDigivolutionRequirement: false,
  32. card: card,
  33. condition: Condition)
  34. );
  35. }
  36. #endregion
  37. #region Execute
  38. if (timing == EffectTiming.OnEndTurn)
  39. {
  40. cardEffects.Add(CardEffectFactory.ExecuteSelfEffect(isInheritedEffect: false, card: card, condition: null));
  41. }
  42. #endregion
  43. #region Piercing
  44. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  45. {
  46. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  47. }
  48. #endregion
  49. #region Security attack
  50. if (timing == EffectTiming.None)
  51. {
  52. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  53. changeValue: 1,
  54. isInheritedEffect: false,
  55. card: card,
  56. condition: null));
  57. }
  58. #endregion
  59. #region When Digivolving
  60. if (timing == EffectTiming.OnEnterFieldAnyone)
  61. {
  62. ActivateClass activateClass = new ActivateClass();
  63. activateClass.SetUpICardEffect("Delete 1 opponent Digimon with highest level. If not delete, +5000 DP for the turn.", CanUseCondition, card);
  64. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  65. cardEffects.Add(activateClass);
  66. string EffectDiscription()
  67. {
  68. return "[When Digivolving] Delete 1 of your opponent's Digimon with the highest level. If this effect didn't delete, this Digimon gets +5000 DP for the turn.";
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  73. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  74. }
  75. bool CanActivateCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  78. }
  79. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  80. {
  81. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  82. {
  83. if (CardEffectCommons.IsMaxLevel(permanent, card.Owner.Enemy))
  84. {
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  91. {
  92. // Note: this function was copied and modified from BT17_016 Gallantmon
  93. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  94. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  95. {
  96. int maxCount = Math.Min(1,
  97. CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  98. SelectPermanentEffect selectPermanentEffect =
  99. GManager.instance.GetComponent<SelectPermanentEffect>();
  100. selectPermanentEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: CanSelectOpponentPermanentCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: maxCount,
  106. canNoSelect: false,
  107. canEndNotMax: false,
  108. selectPermanentCoroutine: null,
  109. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  110. mode: SelectPermanentEffect.Mode.Custom,
  111. cardEffect: activateClass);
  112. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  113. "The opponent is selecting 1 Digimon to delete.");
  114. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  115. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  116. {
  117. deleteTargetPermanents = permanents.Clone();
  118. yield return null;
  119. }
  120. }
  121. yield return ContinuousController.instance.StartCoroutine(
  122. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  123. targetPermanents: deleteTargetPermanents, activateClass: activateClass,
  124. successProcess: null, failureProcess: FailureProcess));
  125. IEnumerator FailureProcess()
  126. {
  127. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  128. targetPermanent: card.PermanentOfThisCard(),
  129. changeValue: 5000,
  130. effectDuration: EffectDuration.UntilEachTurnEnd,
  131. activateClass: activateClass));
  132. }
  133. }
  134. }
  135. #endregion
  136. #region On Deletion
  137. if (timing == EffectTiming.OnDestroyedAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("You may play 1 level 6 or lower Ghost Digimon", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescriptionShared());
  142. cardEffects.Add(activateClass);
  143. string EffectDescriptionShared()
  144. {
  145. return "[On Deletion] You may play 1 level 6 or lower Digimon card with the [Ghost] trait from your trash without paying the cost.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  150. }
  151. bool CanActivateCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable hashtable)
  156. {
  157. // Note: function copied and modified from BT23_069 Necromon
  158. bool HasCorrectTrait(CardSource cardSource)
  159. {
  160. return cardSource.IsDigimon && cardSource.EqualsTraits("Ghost") &&
  161. cardSource.HasLevel && cardSource.Level <= 6 &&
  162. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  163. }
  164. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasCorrectTrait))
  165. {
  166. CardSource selectedCard = null;
  167. #region Select Digimon
  168. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  169. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, HasCorrectTrait));
  170. selectCardEffect.SetUp(
  171. canTargetCondition: HasCorrectTrait,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. canNoSelect: () => true,
  175. selectCardCoroutine: SelectCardCoroutine,
  176. afterSelectCardCoroutine: null,
  177. message: "Select 1 Digimon card to play.",
  178. maxCount: maxCount,
  179. canEndNotMax: false,
  180. isShowOpponent: true,
  181. mode: SelectCardEffect.Mode.Custom,
  182. root: SelectCardEffect.Root.Trash,
  183. customRootCardList: null,
  184. canLookReverseCard: true,
  185. selectPlayer: card.Owner,
  186. cardEffect: activateClass);
  187. IEnumerator SelectCardCoroutine(CardSource cardSource)
  188. {
  189. selectedCard = cardSource;
  190. yield return null;
  191. }
  192. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card to play.", "The opponent is selecting 1 Digimon card to play.");
  193. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  194. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  195. #endregion
  196. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  197. cardSources: new List<CardSource>() { selectedCard },
  198. activateClass: activateClass,
  199. payCost: false,
  200. isTapped: false,
  201. root: SelectCardEffect.Root.Trash,
  202. activateETB: true)
  203. );
  204. }
  205. }
  206. }
  207. #endregion
  208. return cardEffects;
  209. }
  210. }
  211. }