BT13_068.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT13
  5. {
  6. public class BT13_068 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.ContainsCardName("Chessmon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 3;
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.None)
  20. {
  21. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  22. }
  23. if (timing == EffectTiming.OnDestroyedAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Play 1 Digimon card with [Chessmon] in its name from hand", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[On Deletion] If it's your opponent's turn, you may play 1 level 4 or lower Digimon card with [Chessmon] in its name from your hand without paying the cost.";
  32. }
  33. bool CanSelectCardCondition(CardSource cardSource)
  34. {
  35. if (cardSource != null)
  36. {
  37. if (cardSource.ContainsCardName("Chessmon"))
  38. {
  39. if (cardSource.IsDigimon)
  40. {
  41. if (cardSource.Level <= 4)
  42. {
  43. if (cardSource.HasLevel)
  44. {
  45. if (cardSource.Owner == card.Owner)
  46. {
  47. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  62. }
  63. bool CanActivateCondition(Hashtable hashtable)
  64. {
  65. if (CardEffectCommons.IsExistOnTrash(card))
  66. {
  67. if (CardEffectCommons.IsOpponentTurn(card))
  68. {
  69. if (card.Owner.HandCards.Count >= 1)
  70. {
  71. return true;
  72. }
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  78. {
  79. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  80. {
  81. List<CardSource> selectedCards = new List<CardSource>();
  82. int maxCount = 1;
  83. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  84. selectHandEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectCardCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: maxCount,
  90. canNoSelect: true,
  91. canEndNotMax: false,
  92. isShowOpponent: true,
  93. selectCardCoroutine: SelectCardCoroutine,
  94. afterSelectCardCoroutine: null,
  95. mode: SelectHandEffect.Mode.Custom,
  96. cardEffect: activateClass);
  97. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  98. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  99. yield return StartCoroutine(selectHandEffect.Activate());
  100. IEnumerator SelectCardCoroutine(CardSource cardSource)
  101. {
  102. selectedCards.Add(cardSource);
  103. yield return null;
  104. }
  105. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  106. }
  107. }
  108. }
  109. return cardEffects;
  110. }
  111. }
  112. }