EX1_047.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX1
  5. {
  6. public class EX1_047 : 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.None)
  12. {
  13. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  14. }
  15. if (timing == EffectTiming.None)
  16. {
  17. bool Condition()
  18. {
  19. return CardEffectCommons.IsOwnerTurn(card);
  20. }
  21. cardEffects.Add(CardEffectFactory.CanNotAttackSelfStaticEffect(defenderCondition: null, isInheritedEffect: false, card: card, condition: Condition, effectName: "Can't Attack"));
  22. }
  23. if (timing == EffectTiming.OnAllyAttack)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Trash 1 card from hand to Draw 2", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  28. activateClass.SetIsInheritedEffect(true);
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[When Attacking] You may trash 1 Digimon card with [Machine] or [Cyborg] in its traits in your hand to <Draw 2>. (Draw 2 cards from your deck.)";
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource != null)
  37. {
  38. if (cardSource.IsDigimon)
  39. {
  40. if (cardSource.Owner == card.Owner)
  41. {
  42. if (cardSource.CardTraits.Contains("Machine"))
  43. {
  44. return true;
  45. }
  46. if (cardSource.CardTraits.Contains("Cyborg"))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. bool CanUseCondition(Hashtable hashtable)
  56. {
  57. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  58. }
  59. bool CanActivateCondition(Hashtable hashtable)
  60. {
  61. if (CardEffectCommons.IsExistOnBattleArea(card))
  62. {
  63. if (card.Owner.HandCards.Count >= 1)
  64. {
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  71. {
  72. if (isExistOnField(card))
  73. {
  74. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  75. {
  76. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  77. {
  78. bool discarded = false;
  79. int discardCount = 1;
  80. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  81. selectHandEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectCardCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: discardCount,
  87. canNoSelect: true,
  88. canEndNotMax: false,
  89. isShowOpponent: true,
  90. selectCardCoroutine: null,
  91. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  92. mode: SelectHandEffect.Mode.Discard,
  93. cardEffect: activateClass);
  94. yield return StartCoroutine(selectHandEffect.Activate());
  95. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  96. {
  97. if (cardSources.Count >= 1)
  98. {
  99. discarded = true;
  100. yield return null;
  101. }
  102. }
  103. if (discarded)
  104. {
  105. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  106. }
  107. }
  108. }
  109. }
  110. }
  111. }
  112. return cardEffects;
  113. }
  114. }
  115. }