EX2_042.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX2
  4. {
  5. public class EX2_042 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.OnEnterFieldAnyone)
  11. {
  12. ActivateClass activateClass = new ActivateClass();
  13. activateClass.SetUpICardEffect("Draw 2 and trash 2 cards from hand", CanUseCondition, card);
  14. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  15. cardEffects.Add(activateClass);
  16. string EffectDiscription()
  17. {
  18. return "[On Play] <Draw 2>. (Draw 2 cards from your deck.) Then, trash 2 cards in your hand.";
  19. }
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  23. }
  24. bool CanActivateCondition(Hashtable hashtable)
  25. {
  26. if (isExistOnField(card))
  27. {
  28. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  29. {
  30. if (card.Owner.LibraryCards.Count >= 1)
  31. {
  32. return true;
  33. }
  34. if (card.Owner.HandCards.Count >= 1)
  35. {
  36. return true;
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (isExistOnField(card))
  45. {
  46. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  47. {
  48. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  49. if (card.Owner.HandCards.Count >= 1)
  50. {
  51. int discardCount = 2;
  52. if (card.Owner.HandCards.Count < discardCount)
  53. {
  54. discardCount = card.Owner.HandCards.Count;
  55. }
  56. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  57. selectHandEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: (cardSource) => true,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: discardCount,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. isShowOpponent: true,
  66. selectCardCoroutine: null,
  67. afterSelectCardCoroutine: null,
  68. mode: SelectHandEffect.Mode.Discard,
  69. cardEffect: activateClass);
  70. yield return StartCoroutine(selectHandEffect.Activate());
  71. }
  72. }
  73. }
  74. }
  75. }
  76. if (timing == EffectTiming.OnAllyAttack)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  81. activateClass.SetIsInheritedEffect(true);
  82. activateClass.SetHashString("Memory+1_EX2_042");
  83. cardEffects.Add(activateClass);
  84. string EffectDiscription()
  85. {
  86. return "[When Attacking][Once Per Turn] You may trash 1 card in your hand to gain 1 memory.";
  87. }
  88. bool CanUseCondition(Hashtable hashtable)
  89. {
  90. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  91. }
  92. bool CanActivateCondition(Hashtable hashtable)
  93. {
  94. if (CardEffectCommons.IsExistOnBattleArea(card))
  95. {
  96. if (card.Owner.HandCards.Count >= 1)
  97. {
  98. return true;
  99. }
  100. }
  101. return false;
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  104. {
  105. if (isExistOnField(card))
  106. {
  107. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  108. {
  109. if (card.Owner.HandCards.Count >= 1)
  110. {
  111. bool discarded = false;
  112. int discardCount = 1;
  113. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  114. selectHandEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: (cardSource) => true,
  117. canTargetCondition_ByPreSelecetedList: null,
  118. canEndSelectCondition: null,
  119. maxCount: discardCount,
  120. canNoSelect: true,
  121. canEndNotMax: false,
  122. isShowOpponent: true,
  123. selectCardCoroutine: null,
  124. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  125. mode: SelectHandEffect.Mode.Discard,
  126. cardEffect: activateClass);
  127. yield return StartCoroutine(selectHandEffect.Activate());
  128. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  129. {
  130. if (cardSources.Count >= 1)
  131. {
  132. discarded = true;
  133. yield return null;
  134. }
  135. }
  136. if (discarded)
  137. {
  138. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. return cardEffects;
  146. }
  147. }
  148. }