BT22_102.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Sayo
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_102 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Main Phase
  13. if (timing == EffectTiming.OnStartMainPhase)
  14. {
  15. cardEffects.Add(CardEffectFactory.Gain1MemoryTamerOpponentDigimonEffect(card));
  16. }
  17. #endregion
  18. #region Your Turn
  19. if (timing == EffectTiming.OnAllyAttack)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Digivolve for a reduced cost", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  24. cardEffects.Add(activateClass);
  25. string EffectDescription()
  26. {
  27. return "[Your Turn] When one of your Digimon with 2 or more same-level cards in its stack attacks, by suspending this Tamer, digivolve it into a Digimon card with the [Night Claw], [Light Fang], [Galaxy] or [CS] trait in the trash with the digivolution cost reduced by 2.";
  28. }
  29. bool AttackingPermanentCondition(Permanent permanent)
  30. {
  31. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  32. {
  33. return permanent.StackCards
  34. .Filter(x => !x.IsFlipped)
  35. .GroupBy(x => x.Level)
  36. .Any(g => g.Count() >= 2);
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.IsExistOnBattleArea(card))
  43. {
  44. if (CardEffectCommons.IsOwnerTurn(card))
  45. {
  46. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, AttackingPermanentCondition))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.IsExistOnBattleArea(card) &&
  57. CardEffectCommons.CanActivateSuspendCostEffect(card);
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  60. {
  61. CardEffectCommons.EnforceLocationCheck();
  62. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  63. Permanent attackingPermanent = CardEffectCommons.GetAttackerFromHashtable(_hashtable);
  64. bool CanSelectDigivolveTarget(CardSource source)
  65. {
  66. return (source.HasLightFangOrNightClawTraits || source.HasGalaxyTraits || source.HasCSTraits) &&
  67. source.CanPlayCardTargetFrame(attackingPermanent.PermanentFrame, true, activateClass, SelectCardEffect.Root.Trash);
  68. }
  69. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  70. targetPermanent: attackingPermanent,
  71. cardCondition: CanSelectDigivolveTarget,
  72. payCost: true,
  73. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  74. fixedCostTuple: null,
  75. ignoreDigivolutionRequirementFixedCost: -1,
  76. isHand: false,
  77. activateClass: activateClass,
  78. successProcess: null));
  79. }
  80. }
  81. #endregion
  82. #region Security
  83. if (timing == EffectTiming.SecuritySkill)
  84. {
  85. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  86. }
  87. #endregion
  88. return cardEffects;
  89. }
  90. }
  91. }