ST20_08.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //ST20 Kabuterimon
  5. namespace DCGO.CardEffects.ST20
  6. {
  7. public class ST20_08 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasAdventureTraits && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 3;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region When Digivolving
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Play 1 Tamer with the [ADVENTURE] trait name from hand", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  28. cardEffects.Add(activateClass);
  29. string EffectDescription()
  30. {
  31. return
  32. "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 Tamer card with the [ADVENTURE] trait from your hand without paying the cost.";
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  37. }
  38. bool IsAdventureTamerCondition(CardSource cardSource)
  39. {
  40. return cardSource.IsTamer &&
  41. cardSource.HasAdventureTraits &&
  42. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  47. CardEffectCommons.HasMatchConditionOwnersHand(card, IsAdventureTamerCondition) &&
  48. card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsTamer) <= 1;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable hashtable)
  51. {
  52. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsAdventureTamerCondition))
  53. {
  54. List<CardSource> selectedCards = new List<CardSource>();
  55. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  56. selectHandEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: IsAdventureTamerCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: 1,
  62. canNoSelect: true,
  63. canEndNotMax: false,
  64. isShowOpponent: true,
  65. selectCardCoroutine: SelectCardCoroutine,
  66. afterSelectCardCoroutine: null,
  67. mode: SelectHandEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  70. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  71. yield return StartCoroutine(selectHandEffect.Activate());
  72. IEnumerator SelectCardCoroutine(CardSource cardSource)
  73. {
  74. selectedCards.Add(cardSource);
  75. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  76. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  77. root: SelectCardEffect.Root.Hand, activateETB: true));
  78. }
  79. }
  80. }
  81. }
  82. #endregion
  83. #region Piercing inherit
  84. if(timing == EffectTiming.OnDetermineDoSecurityCheck)
  85. {
  86. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card, null));
  87. }
  88. #endregion
  89. return cardEffects;
  90. }
  91. }
  92. }