EX3_004.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX3
  5. {
  6. public class EX3_004 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Trash 1 card from hand to Draw 2", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[On Play] You may trash 1 card with [Imperialdramon] in its name or [Free] in its traits from your hand to <Draw 2>. (Draw 2 cards from your deck.)";
  20. }
  21. bool CanSelectCardCondition(CardSource cardSource)
  22. {
  23. if (cardSource != null)
  24. {
  25. if (cardSource.Owner == card.Owner)
  26. {
  27. if (cardSource.ContainsCardName("Imperialdramon"))
  28. {
  29. return true;
  30. }
  31. if (cardSource.CardTraits.Contains("Free"))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (card.Owner.HandCards.Count >= 1)
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  57. {
  58. bool discarded = false;
  59. int discardCount = 1;
  60. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  61. selectHandEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: CanSelectCardCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: discardCount,
  67. canNoSelect: true,
  68. canEndNotMax: false,
  69. isShowOpponent: true,
  70. selectCardCoroutine: null,
  71. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  72. mode: SelectHandEffect.Mode.Discard,
  73. cardEffect: activateClass);
  74. yield return StartCoroutine(selectHandEffect.Activate());
  75. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  76. {
  77. if (cardSources.Count >= 1)
  78. {
  79. discarded = true;
  80. yield return null;
  81. }
  82. }
  83. if (discarded)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  86. }
  87. }
  88. }
  89. }
  90. if (timing == EffectTiming.None)
  91. {
  92. bool Condition()
  93. {
  94. if (CardEffectCommons.IsExistOnBattleArea(card))
  95. {
  96. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.CardColors.Contains(CardColor.Purple)))
  97. {
  98. if (CardEffectCommons.IsOwnerTurn(card))
  99. {
  100. return true;
  101. }
  102. }
  103. }
  104. return false;
  105. }
  106. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 2000, isInheritedEffect: true, card: card, condition: Condition));
  107. }
  108. return cardEffects;
  109. }
  110. }
  111. }