EX10_027.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. //DeadlyAxemon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_027 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasText("Knightmon") &&
  19. targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 3;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region On Play
  25. if (timing == EffectTiming.OnEnterFieldAnyone)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Trash 1 card from hand to return 1 digimon from trash to hand", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  30. cardEffects.Add(activateClass);
  31. string EffectDiscription()
  32. {
  33. return "[On Play] By trashing 1 card in your hand, you may return 1 Digimon card with [Knightmon] in its text or the [Bagra Army] or [Twilight] trait from your trash to the hand.";
  34. }
  35. bool CanSelectCardCondition(CardSource cardSource)
  36. {
  37. return cardSource.IsDigimon &&
  38. (cardSource.HasText("Knightmon")
  39. || cardSource.HasBagraArmyTraits
  40. || cardSource.HasTwilightTrait);
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  45. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  50. card.Owner.HandCards.Count >= 1;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  53. {
  54. bool discarded = false;
  55. int discardCount = 1;
  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: true,
  64. canEndNotMax: false,
  65. isShowOpponent: true,
  66. selectCardCoroutine: null,
  67. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  68. mode: SelectHandEffect.Mode.Discard,
  69. cardEffect: activateClass);
  70. yield return StartCoroutine(selectHandEffect.Activate());
  71. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  72. {
  73. if (cardSources.Count >= 1)
  74. {
  75. discarded = true;
  76. yield return null;
  77. }
  78. }
  79. if (discarded)
  80. {
  81. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  82. {
  83. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  84. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  85. selectCardEffect.SetUp(
  86. canTargetCondition: CanSelectCardCondition,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. canNoSelect: () => false,
  90. selectCardCoroutine: null,
  91. afterSelectCardCoroutine: null,
  92. message: "Select 1 card to add to your hand.",
  93. maxCount: maxCount,
  94. canEndNotMax: false,
  95. isShowOpponent: true,
  96. mode: SelectCardEffect.Mode.AddHand,
  97. root: SelectCardEffect.Root.Trash,
  98. customRootCardList: null,
  99. canLookReverseCard: true,
  100. selectPlayer: card.Owner,
  101. cardEffect: activateClass);
  102. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  103. }
  104. }
  105. }
  106. }
  107. #endregion
  108. #region When Digivolving
  109. if (timing == EffectTiming.OnEnterFieldAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Trash 1 card from hand to return 1 digimon from trash to hand", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  114. cardEffects.Add(activateClass);
  115. string EffectDiscription()
  116. {
  117. return "[When Digivolving] By trashing 1 card in your hand, you may return 1 Digimon card with [Knightmon] in its text or the [Bagra Army] or [Twilight] trait from your trash to the hand.";
  118. }
  119. bool CanSelectCardCondition(CardSource cardSource)
  120. {
  121. if (cardSource != null)
  122. {
  123. if (cardSource.Owner == card.Owner)
  124. {
  125. if (cardSource.ContainsCardName("Sukamon"))
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. return cardSource.HasText("Knightmon") ||
  132. cardSource.HasBagraArmyTraits ||
  133. cardSource.EqualsTraits("Twilight");
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  138. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  139. }
  140. bool CanActivateCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  143. card.Owner.HandCards.Count >= 1;
  144. }
  145. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  146. {
  147. bool discarded = false;
  148. int discardCount = 1;
  149. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  150. selectHandEffect.SetUp(
  151. selectPlayer: card.Owner,
  152. canTargetCondition: (cardSource) => true,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. maxCount: discardCount,
  156. canNoSelect: true,
  157. canEndNotMax: false,
  158. isShowOpponent: true,
  159. selectCardCoroutine: null,
  160. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  161. mode: SelectHandEffect.Mode.Discard,
  162. cardEffect: activateClass);
  163. yield return StartCoroutine(selectHandEffect.Activate());
  164. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  165. {
  166. if (cardSources.Count >= 1)
  167. {
  168. discarded = true;
  169. yield return null;
  170. }
  171. }
  172. if (discarded)
  173. {
  174. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  175. {
  176. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  177. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  178. selectCardEffect.SetUp(
  179. canTargetCondition: CanSelectCardCondition,
  180. canTargetCondition_ByPreSelecetedList: null,
  181. canEndSelectCondition: null,
  182. canNoSelect: () => false,
  183. selectCardCoroutine: null,
  184. afterSelectCardCoroutine: null,
  185. message: "Select 1 card to add to your hand.",
  186. maxCount: maxCount,
  187. canEndNotMax: false,
  188. isShowOpponent: true,
  189. mode: SelectCardEffect.Mode.AddHand,
  190. root: SelectCardEffect.Root.Trash,
  191. customRootCardList: null,
  192. canLookReverseCard: true,
  193. selectPlayer: card.Owner,
  194. cardEffect: activateClass);
  195. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  196. }
  197. }
  198. }
  199. }
  200. #endregion
  201. #region Save
  202. if (timing == EffectTiming.OnDestroyedAnyone)
  203. {
  204. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  205. }
  206. #endregion
  207. #region Retaliation - ESS
  208. if (timing == EffectTiming.OnDestroyedAnyone)
  209. {
  210. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(
  211. isInheritedEffect: true,
  212. card: card,
  213. condition: null));
  214. }
  215. #endregion
  216. return cardEffects;
  217. }
  218. }
  219. }