EX5_057.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_057 : 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("Trash 1 card from hand to return 1 card from trash to hand", CanUseCondition, card);
  14. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  15. cardEffects.Add(activateClass);
  16. string EffectDiscription()
  17. {
  18. return "[On Play] By trashing 1 card in your hand, you may return 1 Digimon card with the [Dark Animal]/[Shaman] trait from your trash to the hand.";
  19. }
  20. bool CanSelectCardCondition(CardSource cardSource)
  21. {
  22. if (cardSource.IsDigimon)
  23. {
  24. if (cardSource.CardTraits.Contains("Dark Animal"))
  25. {
  26. return true;
  27. }
  28. if (cardSource.CardTraits.Contains("DarkAnimal"))
  29. {
  30. return true;
  31. }
  32. if (cardSource.CardTraits.Contains("Shaman"))
  33. {
  34. return true;
  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 >= 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: cardSource => true,
  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. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  86. {
  87. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  88. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  89. selectCardEffect.SetUp(
  90. canTargetCondition: CanSelectCardCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. canNoSelect: () => true,
  94. selectCardCoroutine: null,
  95. afterSelectCardCoroutine: null,
  96. message: "Select 1 card to add to your hand.",
  97. maxCount: maxCount,
  98. canEndNotMax: false,
  99. isShowOpponent: true,
  100. mode: SelectCardEffect.Mode.AddHand,
  101. root: SelectCardEffect.Root.Trash,
  102. customRootCardList: null,
  103. canLookReverseCard: true,
  104. selectPlayer: card.Owner,
  105. cardEffect: activateClass);
  106. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  107. }
  108. }
  109. }
  110. }
  111. }
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  117. activateClass.SetHashString("Memory1_EX5_065");
  118. activateClass.SetIsInheritedEffect(true);
  119. cardEffects.Add(activateClass);
  120. string EffectDiscription()
  121. {
  122. return "[Your Turn] [Once Per Turn] When an effect plays one of your Digimon, gain 1 memory.";
  123. }
  124. bool PermanentCondition(Permanent permanent)
  125. {
  126. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  127. }
  128. bool CanUseCondition(Hashtable hashtable)
  129. {
  130. if (CardEffectCommons.IsExistOnBattleArea(card))
  131. {
  132. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  133. {
  134. if (CardEffectCommons.IsByEffect(hashtable, null))
  135. {
  136. if (CardEffectCommons.IsOwnerTurn(card))
  137. {
  138. return true;
  139. }
  140. }
  141. }
  142. }
  143. return false;
  144. }
  145. bool CanActivateCondition(Hashtable hashtable)
  146. {
  147. if (CardEffectCommons.IsExistOnBattleArea(card))
  148. {
  149. return true;
  150. }
  151. return false;
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  156. }
  157. }
  158. return cardEffects;
  159. }
  160. }