BT14_072.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT14
  6. {
  7. public class BT14_072 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Return 1 card from trash to hand and trash 1 card from hand", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] Return 1 purple Digimon card with the [Dark Animal] trait from your trash to the hand. Then, trash 1 card in your hand.";
  21. }
  22. bool CanSelectCardCondition(CardSource cardSource)
  23. {
  24. if (cardSource.IsDigimon)
  25. {
  26. if (cardSource.HasCardColor(CardColor.Purple))
  27. {
  28. if (cardSource.CardTraits.Contains("Dark Animal"))
  29. {
  30. return true;
  31. }
  32. if (cardSource.CardTraits.Contains("DarkAnimal"))
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.IsExistOnBattleArea(card))
  47. {
  48. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  49. {
  50. return true;
  51. }
  52. if (card.Owner.HandCards.Count >= 1)
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  60. {
  61. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  62. {
  63. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  64. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  65. selectCardEffect.SetUp(
  66. canTargetCondition: CanSelectCardCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. canNoSelect: () => false,
  70. selectCardCoroutine: null,
  71. afterSelectCardCoroutine: null,
  72. message: "Select 1 card to add to your hand.",
  73. maxCount: maxCount,
  74. canEndNotMax: false,
  75. isShowOpponent: true,
  76. mode: SelectCardEffect.Mode.AddHand,
  77. root: SelectCardEffect.Root.Trash,
  78. customRootCardList: null,
  79. canLookReverseCard: true,
  80. selectPlayer: card.Owner,
  81. cardEffect: activateClass);
  82. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  83. }
  84. if (card.Owner.HandCards.Count >= 1)
  85. {
  86. int discardCount = 1;
  87. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  88. selectHandEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: (cardSource) => true,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: discardCount,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. isShowOpponent: true,
  97. selectCardCoroutine: null,
  98. afterSelectCardCoroutine: null,
  99. mode: SelectHandEffect.Mode.Discard,
  100. cardEffect: activateClass);
  101. yield return StartCoroutine(selectHandEffect.Activate());
  102. }
  103. }
  104. }
  105. if (timing == EffectTiming.OnAllyAttack)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect("Return 1 card from trash to hand and trash 1 card from hand", CanUseCondition, card);
  109. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[When Attacking] Return 1 purple Digimon card with the [Dark Animal] trait from your trash to the hand. Then, trash 1 card in your hand.";
  114. }
  115. bool CanSelectCardCondition(CardSource cardSource)
  116. {
  117. if (cardSource.IsDigimon)
  118. {
  119. if (cardSource.HasCardColor(CardColor.Purple))
  120. {
  121. if (cardSource.CardTraits.Contains("Dark Animal"))
  122. {
  123. return true;
  124. }
  125. if (cardSource.CardTraits.Contains("DarkAnimal"))
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. if (CardEffectCommons.IsExistOnBattleArea(card))
  140. {
  141. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  142. {
  143. return true;
  144. }
  145. if (card.Owner.HandCards.Count >= 1)
  146. {
  147. return true;
  148. }
  149. }
  150. return false;
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  153. {
  154. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  155. {
  156. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  157. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  158. selectCardEffect.SetUp(
  159. canTargetCondition: CanSelectCardCondition,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. canNoSelect: () => false,
  163. selectCardCoroutine: null,
  164. afterSelectCardCoroutine: null,
  165. message: "Select 1 card to add to your hand.",
  166. maxCount: maxCount,
  167. canEndNotMax: false,
  168. isShowOpponent: true,
  169. mode: SelectCardEffect.Mode.AddHand,
  170. root: SelectCardEffect.Root.Trash,
  171. customRootCardList: null,
  172. canLookReverseCard: true,
  173. selectPlayer: card.Owner,
  174. cardEffect: activateClass);
  175. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  176. }
  177. if (card.Owner.HandCards.Count >= 1)
  178. {
  179. int discardCount = 1;
  180. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  181. selectHandEffect.SetUp(
  182. selectPlayer: card.Owner,
  183. canTargetCondition: (cardSource) => true,
  184. canTargetCondition_ByPreSelecetedList: null,
  185. canEndSelectCondition: null,
  186. maxCount: discardCount,
  187. canNoSelect: false,
  188. canEndNotMax: false,
  189. isShowOpponent: true,
  190. selectCardCoroutine: null,
  191. afterSelectCardCoroutine: null,
  192. mode: SelectHandEffect.Mode.Discard,
  193. cardEffect: activateClass);
  194. yield return StartCoroutine(selectHandEffect.Activate());
  195. }
  196. }
  197. }
  198. return cardEffects;
  199. }
  200. }
  201. }