EX9_051.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Monochromon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_051 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasDMTraits && targetPermanent.TopCard.IsLevel3;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Training
  24. if (timing == EffectTiming.OnDeclaration)
  25. {
  26. cardEffects.Add(CardEffectFactory.TrainingEffect(card: card));
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("Place 1 card from hand face down as bottom source, De-Digivolve 1 digimon", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[On Play] By placing 1 card in your hand face down as this Digimon's bottom digivolution card, <De-Digivolve 1> 1 of your opponent's Digimon (Trash the top card. You can't trash past level 3 cards).";
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  47. }
  48. }
  49. #endregion
  50. #region When Attacking
  51. if (timing == EffectTiming.OnAllyAttack)
  52. {
  53. ActivateClass activateClass = new ActivateClass();
  54. activateClass.SetUpICardEffect("Place 1 card from hand face down as bottom source, De-Digivolve 1 digimon", CanUseCondition, card);
  55. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  56. cardEffects.Add(activateClass);
  57. string EffectDiscription()
  58. {
  59. return "[When Attacking] By placing 1 card in your hand face down as this Digimon's bottom digivolution card, <De-Digivolve 1> 1 of your opponent's Digimon (Trash the top card. You can't trash past level 3 cards).";
  60. }
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  68. }
  69. }
  70. #endregion
  71. #region OP/WA Shared
  72. bool CanSelectPermanentCondition(Permanent permanent)
  73. {
  74. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  75. }
  76. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  77. {
  78. if (card.Owner.HandCards.Any())
  79. {
  80. CardSource selectedCard = null;
  81. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  82. selectHandEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: (cardSource) => true,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: 1,
  88. canNoSelect: true,
  89. canEndNotMax: false,
  90. isShowOpponent: false,
  91. selectCardCoroutine: SelectCardCoroutine,
  92. afterSelectCardCoroutine: null,
  93. mode: SelectHandEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. yield return StartCoroutine(selectHandEffect.Activate());
  96. selectHandEffect.SetUpCustomMessage("Select a card to add face down as a source", "Opponent is selecting a card to add face down as a source");
  97. IEnumerator SelectCardCoroutine(CardSource cardSource)
  98. {
  99. selectedCard = cardSource;
  100. yield return null;
  101. }
  102. if (selectedCard != null)
  103. {
  104. Permanent permanent = card.PermanentOfThisCard();
  105. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard));
  106. yield return ContinuousController.instance.StartCoroutine(permanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass, isFacedown: true));
  107. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  108. {
  109. Permanent selectedPermanent = null;
  110. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition));
  111. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  112. selectPermanentEffect.SetUp(
  113. selectPlayer: card.Owner,
  114. canTargetCondition: CanSelectPermanentCondition,
  115. canTargetCondition_ByPreSelecetedList: null,
  116. canEndSelectCondition: null,
  117. maxCount: maxCount,
  118. canNoSelect: false,
  119. canEndNotMax: false,
  120. selectPermanentCoroutine: SelectPermanentCoroutine,
  121. afterSelectPermanentCoroutine: null,
  122. mode: SelectPermanentEffect.Mode.Custom,
  123. cardEffect: activateClass
  124. );
  125. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve", "Opponent is selecting 1 Digimon to De-Digivolve");
  126. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  127. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  128. {
  129. selectedPermanent = permanent;
  130. yield return null;
  131. }
  132. if (selectedPermanent != null)
  133. {
  134. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  135. }
  136. }
  137. }
  138. }
  139. }
  140. #endregion
  141. #region ESS
  142. if (timing == EffectTiming.None)
  143. {
  144. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  145. }
  146. #endregion
  147. return cardEffects;
  148. }
  149. }
  150. }