BT12_054.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_054 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnDestroyedAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play [Yakiimon] or [Potamon] from hand", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Deletion] You may play up to 2 [Yakiimon] or [Potamon] cards from your hand without paying their costs.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource != null)
  25. {
  26. if (cardSource.Owner == card.Owner)
  27. {
  28. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  29. {
  30. if (cardSource.CardNames.Contains("Yakiimon"))
  31. {
  32. return true;
  33. }
  34. if (cardSource.CardNames.Contains("Potamon"))
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnTrash(card))
  50. {
  51. if (card.Owner.HandCards.Count >= 1)
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  61. {
  62. List<CardSource> selectedCards = new List<CardSource>();
  63. int maxCount = Math.Min(2, card.Owner.HandCards.Count(CanSelectCardCondition));
  64. if (card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) < maxCount)
  65. {
  66. maxCount = card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame());
  67. }
  68. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  69. selectHandEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectCardCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: CanEndSelectCondition,
  74. maxCount: maxCount,
  75. canNoSelect: true,
  76. canEndNotMax: true,
  77. isShowOpponent: true,
  78. selectCardCoroutine: SelectCardCoroutine,
  79. afterSelectCardCoroutine: null,
  80. mode: SelectHandEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectHandEffect.SetUpCustomMessage("Select cards to play.", "The opponent is selecting cards to play.");
  83. selectHandEffect.SetUpCustomMessage_ShowCard("Played Cards");
  84. yield return StartCoroutine(selectHandEffect.Activate());
  85. IEnumerator SelectCardCoroutine(CardSource cardSource)
  86. {
  87. selectedCards.Add(cardSource);
  88. yield return null;
  89. }
  90. bool CanEndSelectCondition(List<CardSource> cardSources)
  91. {
  92. if (maxCount >= 1)
  93. {
  94. if (cardSources.Count <= 0)
  95. {
  96. return false;
  97. }
  98. }
  99. return true;
  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. return cardEffects;
  106. }
  107. }
  108. }