BT19_020.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_020 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Rush
  12. if (timing == EffectTiming.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(
  15. isInheritedEffect: false,
  16. card: card, condition: null));
  17. }
  18. #endregion
  19. #region On Deletion
  20. if (timing == EffectTiming.OnDestroyedAnyone)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("Play 1 Tamer with [Kiriha Aonuma] in its name from hand, then <Save>", CanUseCondition,
  24. card);
  25. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  26. cardEffects.Add(activateClass);
  27. string EffectDescription()
  28. {
  29. return
  30. "[On Deletion] If you have 1 or fewer Tamers, you may play 1 [Kiriha Aonuma] from your hand without paying the cost. Then, <Save>.";
  31. }
  32. bool CanUseCondition(Hashtable hashtable)
  33. {
  34. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  35. }
  36. bool IsTamerCardCondition(CardSource cardSource)
  37. {
  38. return cardSource.IsTamer &&
  39. cardSource.EqualsCardName("Kiriha Aonuma") &&
  40. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  41. }
  42. bool CanSelectSaveTamerPermanentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  45. && permanent.IsTamer;
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  50. ((CardEffectCommons.HasMatchConditionOwnersHand(card, IsTamerCardCondition) &&
  51. card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1) ||
  52. CardEffectCommons.CanActivateSave(hashtable, CanSelectSaveTamerPermanentCondition));
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsTamerCardCondition) &&
  57. card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1)
  58. {
  59. List<CardSource> selectedCards = new List<CardSource>();
  60. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  61. selectHandEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: IsTamerCardCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: 1,
  67. canNoSelect: true,
  68. canEndNotMax: false,
  69. isShowOpponent: true,
  70. selectCardCoroutine: SelectCardCoroutine,
  71. afterSelectCardCoroutine: null,
  72. mode: SelectHandEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  75. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  76. yield return StartCoroutine(selectHandEffect.Activate());
  77. IEnumerator SelectCardCoroutine(CardSource cardSource)
  78. {
  79. selectedCards.Add(cardSource);
  80. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  81. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  82. root: SelectCardEffect.Root.Hand, activateETB: true));
  83. }
  84. }
  85. if (CardEffectCommons.CanActivateSave(hashtable, CanSelectSaveTamerPermanentCondition))
  86. {
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SaveProcess(hashtable, activateClass, card, CanSelectSaveTamerPermanentCondition));
  88. }
  89. }
  90. }
  91. #endregion
  92. #region Reboot - ESS
  93. if (timing == EffectTiming.None)
  94. {
  95. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(
  96. isInheritedEffect: true,
  97. card: card,
  98. condition: null));
  99. }
  100. #endregion
  101. return cardEffects;
  102. }
  103. }
  104. }