AD1_022.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.AD1
  6. {
  7. public class AD1_022 : 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 Your 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.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ();
  22. activateClass.SetUpICardEffect("By suspending this tamer, 1 of your [ADVENTURE] Digimon may digivolve for -1 per 2 colors on your Tamers.", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  24. cardEffects.Add(activateClass);
  25. string EffectDescription()
  26. => "[Your Turn] When any of your other [ADVENTURE] trait Digimon or Tamers are played, by suspending this Tamer, 1 of your Digimon may digivolve into an [ADVENTURE] trait Digimon in the hand. For every 2 of your Tamers' colors, reduce this effect's digivolution cost by 1.";
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.IsExistOnBattleArea(card)
  30. && CardEffectCommons.IsOwnerTurn(card)
  31. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition);
  32. }
  33. bool PermanentCondition(Permanent permanent)
  34. {
  35. return permanent != card.PermanentOfThisCard()
  36. && CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  37. && (permanent.IsDigimon || permanent.IsTamer)
  38. && permanent.TopCard.EqualsTraits("ADVENTURE");
  39. }
  40. bool CanActivateCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.IsExistOnBattleArea(card)
  43. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  44. }
  45. bool IsAdventureDigimon(CardSource cardSource)
  46. {
  47. return cardSource.IsDigimon
  48. && cardSource.EqualsTraits("ADVENTURE");
  49. }
  50. bool IsYourDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  54. new List<Permanent>() { card.PermanentOfThisCard() },
  55. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  56. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYourDigimon) && CardEffectCommons.HasMatchConditionOwnersHand(card, IsAdventureDigimon))
  57. {
  58. List<CardSource> tamerCards = new List<CardSource>();
  59. foreach (Permanent permanent in card.Owner.GetBattleAreaPermanents())
  60. {
  61. if (permanent.IsTamer)
  62. {
  63. tamerCards.Add(permanent.TopCard);
  64. }
  65. }
  66. int reduceCost = Combinations.GetDifferenetColorCardCount(tamerCards) / 2;
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: IsYourDigimon,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: 1,
  74. canNoSelect: true,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  85. permanent,
  86. IsAdventureDigimon,
  87. payCost: true,
  88. reduceCostTuple: (reduceCost, null),
  89. fixedCostTuple: null,
  90. ignoreDigivolutionRequirementFixedCost: -1,
  91. isHand: true,
  92. activateClass,
  93. successProcess: null
  94. ));
  95. }
  96. }
  97. }
  98. }
  99. #endregion
  100. #region Security
  101. if (timing == EffectTiming.SecuritySkill)
  102. {
  103. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  104. }
  105. #endregion
  106. return cardEffects;
  107. }
  108. }
  109. }