BT21_001.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //Gigimon
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_001 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Your Turn - ESS
  14. if (timing == EffectTiming.OnLoseSecurity)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Digivolve a digimon", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  19. activateClass.SetIsInheritedEffect(true);
  20. activateClass.SetHashString("Digivolve_BT21_001");
  21. cardEffects.Add(activateClass);
  22. string EffectDescription()
  23. => "[Your Turn] [Once Per Turn] When your opponent's security stack is removed from, 1 of your Digimon may digivolve into a Digimon card with the [Reptile]/[Dragonkin] trait in the hand with the digivolution cost reduced by 1.";
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  27. {
  28. if (CardEffectCommons.IsOwnerTurn(card))
  29. {
  30. if (CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner.Enemy))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. return false;
  37. }
  38. bool CanSelectDigivolvePermanent(Permanent permanent)
  39. {
  40. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  41. {
  42. return card.Owner.HandCards.Any(source =>
  43. CanSelectCardCondition(source) &&
  44. source.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass));
  45. }
  46. return false;
  47. }
  48. bool CanSelectCardCondition(CardSource digivolveTarget)
  49. {
  50. return digivolveTarget.EqualsTraits("Reptile") || digivolveTarget.EqualsTraits("Dragonkin");
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable hashtable)
  57. {
  58. Permanent selectedPermanent = null;
  59. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigivolvePermanent));
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: CanSelectDigivolvePermanent,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: maxCount,
  67. canNoSelect: true,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to digivolve", "The opponent is selecting 1 digimon to digivolve");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  76. {
  77. selectedPermanent = permanent;
  78. yield return null;
  79. }
  80. if (selectedPermanent != null)
  81. {
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  83. targetPermanent: selectedPermanent,
  84. cardCondition: CanSelectCardCondition,
  85. payCost: true,
  86. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  87. fixedCostTuple: null,
  88. ignoreDigivolutionRequirementFixedCost: -1,
  89. isHand: true,
  90. activateClass: activateClass,
  91. successProcess: null));
  92. }
  93. }
  94. }
  95. #endregion
  96. return cardEffects;
  97. }
  98. }
  99. }