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