BT19_009.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT19
  5. {
  6. public class BT19_009 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region When Digivolving
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play 1 Tamer with [Takato Matsuki] in its name from hand", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 [Takato Matsuki] from your hand without paying the cost.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  25. {
  26. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  27. {
  28. return true;
  29. }
  30. }
  31. return false;
  32. }
  33. bool IsTakatoCardCondition(CardSource cardSource)
  34. {
  35. return cardSource.IsTamer && (cardSource.EqualsCardName("Takato Matsuki") && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass));
  36. }
  37. bool CanActivateCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersHand(card, IsTakatoCardCondition) && card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1;
  40. }
  41. IEnumerator ActivateCoroutine(Hashtable hashtable)
  42. {
  43. List<CardSource> selectedCards = new List<CardSource>();
  44. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  45. selectHandEffect.SetUp(
  46. selectPlayer: card.Owner,
  47. canTargetCondition: IsTakatoCardCondition,
  48. canTargetCondition_ByPreSelecetedList: null,
  49. canEndSelectCondition: null,
  50. maxCount: 1,
  51. canNoSelect: true,
  52. canEndNotMax: false,
  53. isShowOpponent: true,
  54. selectCardCoroutine: SelectCardCoroutine,
  55. afterSelectCardCoroutine: null,
  56. mode: SelectHandEffect.Mode.Custom,
  57. cardEffect: activateClass);
  58. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  59. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  60. yield return StartCoroutine(selectHandEffect.Activate());
  61. IEnumerator SelectCardCoroutine(CardSource cardSource)
  62. {
  63. selectedCards.Add(cardSource);
  64. yield return null;
  65. }
  66. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  67. }
  68. }
  69. #endregion
  70. #region Inherit
  71. if (timing == EffectTiming.None)
  72. {
  73. ChangeDPDeleteEffectMaxDPClass changeDPDeleteEffectMaxDPClass = new ChangeDPDeleteEffectMaxDPClass();
  74. changeDPDeleteEffectMaxDPClass.SetUpICardEffect("Maximum DP of DP-based deletion effects gets +2000 DP if 0 or less memory", CanUseCondition, card);
  75. changeDPDeleteEffectMaxDPClass.SetUpChangeDPDeleteEffectMaxDPClass(changeMaxDP: ChangeMaxDP);
  76. changeDPDeleteEffectMaxDPClass.SetIsInheritedEffect(true);
  77. cardEffects.Add(changeDPDeleteEffectMaxDPClass);
  78. bool CanUseCondition(Hashtable hashtable)
  79. {
  80. if (isExistOnField(card))
  81. {
  82. if (card.Owner.MemoryForPlayer <= 0)
  83. {
  84. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  85. {
  86. return true;
  87. }
  88. }
  89. }
  90. return false;
  91. }
  92. int ChangeMaxDP(int maxDP, ICardEffect cardEffect)
  93. {
  94. if (cardEffect != null)
  95. {
  96. if (cardEffect.EffectSourceCard != null)
  97. {
  98. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  99. {
  100. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == card.PermanentOfThisCard()) maxDP += 2000;
  101. }
  102. }
  103. }
  104. return maxDP;
  105. }
  106. }
  107. #endregion
  108. return cardEffects;
  109. }
  110. }
  111. }