BT19_034.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_034 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region When Digivolving
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 Tamer with [Rika Nonaka] in its name from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 [Rika Nonaka] from your hand without paying the cost.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  26. {
  27. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool IsRikaCardCondition(CardSource cardSource)
  35. {
  36. return cardSource.IsTamer && (cardSource.EqualsCardName("Rika Nonaka") && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass));
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersHand(card, IsRikaCardCondition) && card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. List<CardSource> selectedCards = new List<CardSource>();
  45. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  46. selectHandEffect.SetUp(
  47. selectPlayer: card.Owner,
  48. canTargetCondition: IsRikaCardCondition,
  49. canTargetCondition_ByPreSelecetedList: null,
  50. canEndSelectCondition: null,
  51. maxCount: 1,
  52. canNoSelect: true,
  53. canEndNotMax: false,
  54. isShowOpponent: true,
  55. selectCardCoroutine: SelectCardCoroutine,
  56. afterSelectCardCoroutine: null,
  57. mode: SelectHandEffect.Mode.Custom,
  58. cardEffect: activateClass);
  59. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  60. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  61. yield return StartCoroutine(selectHandEffect.Activate());
  62. IEnumerator SelectCardCoroutine(CardSource cardSource)
  63. {
  64. selectedCards.Add(cardSource);
  65. yield return null;
  66. }
  67. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  68. }
  69. }
  70. #endregion
  71. #region Inherit
  72. if (timing == EffectTiming.OnUseOption)
  73. {
  74. ActivateClass activateClass = new ActivateClass();
  75. activateClass.SetUpICardEffect("DP -2000", CanUseCondition, card);
  76. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  77. activateClass.SetIsInheritedEffect(true);
  78. activateClass.SetHashString("DP-2000_BT19_030");
  79. cardEffects.Add(activateClass);
  80. string EffectDiscription()
  81. {
  82. return "[Your Turn][Once Per Turn] When you use an Option card with a cost of 2 or more, 1 of your opponent's Digimon gets -2000 DP for the turn.";
  83. }
  84. bool CanSelectPermanentCondition(Permanent permanent)
  85. {
  86. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  87. }
  88. bool CanUseCondition(Hashtable hashtable)
  89. {
  90. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  91. {
  92. if (CardEffectCommons.IsOwnerTurn(card))
  93. {
  94. if (CardEffectCommons.CanTriggerWhenOwnerUseOption(hashtable, null, (cost) => cost >= 2, card))
  95. {
  96. return true;
  97. }
  98. }
  99. }
  100. return false;
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  105. {
  106. return true;
  107. }
  108. return false;
  109. }
  110. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  111. {
  112. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectPermanentCondition,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: maxCount,
  120. canNoSelect: false,
  121. canEndNotMax: false,
  122. selectPermanentCoroutine: SelectPermanentCoroutine,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.Custom,
  125. cardEffect: activateClass);
  126. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -2000.", "The opponent is selecting 1 Digimon that will get DP -2000.");
  127. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  128. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  131. }
  132. }
  133. }
  134. #endregion
  135. return cardEffects;
  136. }
  137. }
  138. }