BT17_071.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_071 : 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("Darcmon") &&
  17. targetPermanent.DigivolutionCards.Some(cardSource =>
  18. cardSource.IsDigimon && cardSource.EqualsCardName("HippoGryphonmon"));
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false,
  22. card: card, condition: null));
  23. }
  24. #endregion
  25. #region When Digivolving
  26. if (timing == EffectTiming.OnEnterFieldAnyone)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Delete 1 of your Digimon to play [Ornismon]",
  30. CanUseCondition, card);
  31. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  32. cardEffects.Add(activateClass);
  33. string EffectDescription()
  34. {
  35. return
  36. "[When Digivolving] If [Darcmon] and [HippoGryphonmon] are in this Digimon's digivolution cards, by deleting 1 of your other Digimon, you may play 1 [Ornismon] from your trash without paying the cost.";
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  41. }
  42. bool CanSelectOwnPermanentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  45. permanent != card.PermanentOfThisCard();
  46. }
  47. bool IsDarcmonCardCondition(CardSource cardSource)
  48. {
  49. return cardSource.IsDigimon &&
  50. cardSource.EqualsCardName("Darcmon");
  51. }
  52. bool IsHippoGryphonmonCardCondition(CardSource cardSource)
  53. {
  54. return cardSource.IsDigimon &&
  55. cardSource.EqualsCardName("HippoGryphonmon");
  56. }
  57. bool IsOrnismonCardCondition(CardSource cardSource)
  58. {
  59. return cardSource.IsDigimon &&
  60. cardSource.EqualsCardName("Ornismon");
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsExistOnBattleArea(card) &&
  65. card.PermanentOfThisCard().DigivolutionCards.Some(IsDarcmonCardCondition) &&
  66. card.PermanentOfThisCard().DigivolutionCards.Some(IsHippoGryphonmonCardCondition) &&
  67. CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition);
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition))
  72. {
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectOwnPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: SelectPermanentCoroutine,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  87. "The opponent is selecting 1 Digimon to delete.");
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  89. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(
  92. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  93. targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass,
  94. successProcess: _ => SuccessProcess(), failureProcess: null));
  95. IEnumerator SuccessProcess()
  96. {
  97. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsOrnismonCardCondition))
  98. {
  99. List<CardSource> selectedCards = new List<CardSource>();
  100. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  101. selectCardEffect.SetUp(
  102. canTargetCondition: IsOrnismonCardCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. canNoSelect: () => true,
  106. selectCardCoroutine: SelectCardCoroutine,
  107. afterSelectCardCoroutine: null,
  108. message: "Select 1 card to play.",
  109. maxCount: 1,
  110. canEndNotMax: false,
  111. isShowOpponent: true,
  112. mode: SelectCardEffect.Mode.Custom,
  113. root: SelectCardEffect.Root.Trash,
  114. customRootCardList: null,
  115. canLookReverseCard: true,
  116. selectPlayer: card.Owner,
  117. cardEffect: activateClass);
  118. selectCardEffect.SetUpCustomMessage("Select 1 card to play.",
  119. "The opponent is selecting 1 card to play.");
  120. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  121. yield return StartCoroutine(selectCardEffect.Activate());
  122. IEnumerator SelectCardCoroutine(CardSource cardSource)
  123. {
  124. selectedCards.Add(cardSource);
  125. yield return null;
  126. }
  127. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  128. cardSources: selectedCards,
  129. activateClass: activateClass,
  130. payCost: false,
  131. isTapped: false,
  132. root: SelectCardEffect.Root.Trash,
  133. activateETB: true));
  134. }
  135. }
  136. }
  137. }
  138. }
  139. }
  140. #endregion
  141. #region All Turns
  142. if (timing == EffectTiming.OnDestroyedAnyone)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect("Delete 1 of your opponent's Digimon", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  147. activateClass.SetHashString("DeleteDigimon_BT17_071");
  148. cardEffects.Add(activateClass);
  149. string EffectDescription()
  150. {
  151. return
  152. "[All Turns][Once Per Turn] When one of your other Digimon is deleted, delete 1 of your opponent's Digimon with level equal to or less than the deleted Digimon.";
  153. }
  154. bool OwnPermanentCondition(Permanent permanent)
  155. {
  156. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  157. permanent != card.PermanentOfThisCard();
  158. }
  159. bool CanUseCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.IsExistOnBattleArea(card) &&
  162. CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, OwnPermanentCondition, activateClass);
  163. }
  164. bool CanActivateCondition(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.IsExistOnBattleArea(card);
  167. }
  168. IEnumerator ActivateCoroutine(Hashtable hashtable)
  169. {
  170. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  171. if (hashtables != null)
  172. {
  173. List<int> levels = hashtables
  174. .Map(CardEffectCommons.GetPermanentFromHashtable)
  175. .Filter(permanent => permanent is { LevelJustBeforeRemoveField: > 0 })
  176. .Map(permanent => permanent.LevelJustBeforeRemoveField);
  177. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  180. permanent.TopCard.HasLevel &&
  181. permanent.Level <= levels.Max();
  182. }
  183. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  184. {
  185. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  186. selectPermanentEffect.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: CanSelectOpponentPermanentCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: 1,
  192. canNoSelect: false,
  193. canEndNotMax: false,
  194. selectPermanentCoroutine: null,
  195. afterSelectPermanentCoroutine: null,
  196. mode: SelectPermanentEffect.Mode.Destroy,
  197. cardEffect: activateClass);
  198. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  199. }
  200. }
  201. }
  202. }
  203. #endregion
  204. return cardEffects;
  205. }
  206. }
  207. }