BT19_002.cs 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT19
  4. {
  5. public class BT19_002 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Opponent's Turn - ESS
  11. if (timing == EffectTiming.OnAllyAttack)
  12. {
  13. int bouncedLevel = 0;
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Bottom deck this Digimon to return to hand an opponent's Digimon with the same level", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  17. activateClass.SetIsInheritedEffect(true);
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[Opponent's Turn] When any of your opponent's Digimon attack, by returning this Digimon with [Aqua]/[Sea Animal] in one of its traits to the bottom of the deck, return 1 of your opponent's Digimon with as high or lower a level as the returned Digimon to the hand.";
  22. }
  23. bool AttackingPermanent(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  30. CardEffectCommons.IsOpponentTurn(card) &&
  31. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanent);
  32. }
  33. bool CanSelectPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  36. permanent.TopCard.HasLevel && permanent.Level <= bouncedLevel;
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  41. card.PermanentOfThisCard().TopCard.HasLevel &&
  42. card.PermanentOfThisCard().TopCard.HasAquaTraits;
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable hashtable)
  45. {
  46. bouncedLevel = card.PermanentOfThisCard().TopCard.Level;
  47. yield return ContinuousController.instance.StartCoroutine(
  48. new DeckBottomBounceClass(new List<Permanent> { card.PermanentOfThisCard() }, hashtable).DeckBounce());
  49. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  50. {
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canTargetCondition: CanSelectPermanentCondition,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: null,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Bounce,
  63. cardEffect: activateClass);
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to hand.",
  65. "The opponent is selecting 1 Digimon to return to hand.");
  66. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  67. }
  68. }
  69. }
  70. #endregion
  71. return cardEffects;
  72. }
  73. }
  74. }