BT15_066.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_066 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region All Turns
  13. if (timing == EffectTiming.None)
  14. {
  15. bool Condition()
  16. {
  17. if (CardEffectCommons.IsExistOnBattleArea(card))
  18. {
  19. if (CardEffectCommons.IsOwnerTurn(card))
  20. {
  21. return true;
  22. }
  23. }
  24. return false;
  25. }
  26. bool CardCondition(CardSource cardSource)
  27. {
  28. return !cardSource.HasCardColor(CardColor.White);
  29. }
  30. cardEffects.Add(CardEffectFactory.CanNotDigivolveStaticSelfEffect(
  31. cardCondition: CardCondition,
  32. isInheritedEffect: false,
  33. card: card,
  34. condition: Condition,
  35. effectName: "This Digimon can digivolve only to white Digimon")
  36. );
  37. }
  38. #endregion
  39. #region Shared OP/WA
  40. string SharedEffectName = "De-Digivolve 2 on 1 Digimon.";
  41. string SharedEffectDescription(string tag)
  42. {
  43. return $"[{tag}] Trigger <De-Digivolve 2> on 1 of your opponent's Digimon. (Trash up to 2 card from the top of one of your opponent's Digimon. If it has no digivolution cards, or becomes a level 3 Digimon, you can't trash any more cards.)";
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  48. }
  49. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  50. {
  51. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  52. {
  53. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  54. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  55. selectPermanentEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: CanSelectPermanentCondition,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: maxCount,
  61. canNoSelect: false,
  62. canEndNotMax: false,
  63. selectPermanentCoroutine: SelectPermanentCoroutine,
  64. afterSelectPermanentCoroutine: null,
  65. mode: SelectPermanentEffect.Mode.Custom,
  66. cardEffect: activateClass);
  67. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  68. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  69. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  70. {
  71. Permanent selectedPermanent = permanent;
  72. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 2, activateClass).Degeneration());
  73. }
  74. }
  75. }
  76. CardEffectFactory.ActivateClassesForSharedEffects
  77. (ref cardEffects, timing, card,
  78. SharedEffectName,
  79. SharedActivateCoroutine,
  80. SharedEffectDescription,
  81. optional: false,
  82. onPlay: true,
  83. whenAttacking: true);
  84. #endregion
  85. #region End of Opponent's Turn
  86. if (timing == EffectTiming.OnEndTurn)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("Delete this Digimon and play 1 Digimon from hand", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  91. cardEffects.Add(activateClass);
  92. string EffectDiscription()
  93. {
  94. return "[End of Opponent's Turn] Delete this Digimon. Then you may play 1 Digimon card with the [Dark Masters] trait, other than [Machinedramon] from your hand without paying the cost.";
  95. }
  96. bool CanSelectCardCondition(CardSource cardSource)
  97. {
  98. if (!cardSource.CardNames.Contains("Machinedramon"))
  99. {
  100. if (cardSource.IsDigimon)
  101. {
  102. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  103. {
  104. if (cardSource.CardTraits.Contains("Dark Masters"))
  105. {
  106. return true;
  107. }
  108. if (cardSource.CardTraits.Contains("DarkMasters"))
  109. {
  110. return true;
  111. }
  112. }
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  120. && CardEffectCommons.IsOpponentTurn(card);
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  125. }
  126. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  127. {
  128. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  129. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  130. {
  131. List<CardSource> selectedCards = new List<CardSource>();
  132. int maxCount = 1;
  133. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  134. selectHandEffect.SetUp(
  135. selectPlayer: card.Owner,
  136. canTargetCondition: CanSelectCardCondition,
  137. canTargetCondition_ByPreSelecetedList: null,
  138. canEndSelectCondition: null,
  139. maxCount: maxCount,
  140. canNoSelect: true,
  141. canEndNotMax: false,
  142. isShowOpponent: true,
  143. selectCardCoroutine: SelectCardCoroutine,
  144. afterSelectCardCoroutine: null,
  145. mode: SelectHandEffect.Mode.Custom,
  146. cardEffect: activateClass);
  147. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  148. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  149. yield return StartCoroutine(selectHandEffect.Activate());
  150. IEnumerator SelectCardCoroutine(CardSource cardSource)
  151. {
  152. selectedCards.Add(cardSource);
  153. yield return null;
  154. }
  155. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  156. cardSources: selectedCards,
  157. activateClass: activateClass,
  158. payCost: false,
  159. isTapped: false,
  160. root: SelectCardEffect.Root.Hand,
  161. activateETB: true));
  162. }
  163. }
  164. }
  165. #endregion
  166. #region Inherited Effect
  167. if (timing == EffectTiming.None)
  168. {
  169. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  170. }
  171. #endregion
  172. return cardEffects;
  173. }
  174. }
  175. }