BT16_031.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_031 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Barrier
  13. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  14. {
  15. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null));
  16. }
  17. #endregion
  18. #region Digivolution Condition
  19. if (timing == EffectTiming.None)
  20. {
  21. static bool PermanentCondition(Permanent targetPermanent)
  22. {
  23. if (targetPermanent.TopCard.CardNames.Contains("Salamon"))
  24. {
  25. return true;
  26. }
  27. return false;
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region On Play
  33. if (timing == EffectTiming.OnEnterFieldAnyone)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("Trash 1 card to return 1 card back to you hand.", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  38. activateClass.SetHashString("OnPlay_BT16_031");
  39. cardEffects.Add(activateClass);
  40. string EffectDiscription()
  41. {
  42. return "[On Play] By trashing 1 card in your hand, return 1 level 6 of lower 2-color Digimon card with red or purple from your trash to your hand.";
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleArea(card))
  51. {
  52. if (card.Owner.HandCards.Count >= 1)
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. bool CanSelectCardToTrash(CardSource card)
  60. {
  61. if (card.Owner.HandCards.Count >= 1)
  62. {
  63. return true;
  64. }
  65. return false;
  66. }
  67. bool CanSelectCardToReturnToHand(CardSource cardSource)
  68. {
  69. if (cardSource.CardColors.Count == 2 && (cardSource.HasCardColor(CardColor.Red) || cardSource.HasCardColor(CardColor.Purple)))
  70. {
  71. if (cardSource.HasLevel && cardSource.Level <= 6)
  72. {
  73. return true;
  74. }
  75. }
  76. return false;
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable hashtable)
  79. {
  80. if (card.Owner.HandCards.Count(CanSelectCardToTrash) >= 1)
  81. {
  82. bool discarded = false;
  83. int discardCount = 1;
  84. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  85. selectHandEffect.SetUp(
  86. selectPlayer: card.Owner,
  87. canTargetCondition: CanSelectCardToTrash,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. maxCount: discardCount,
  91. canNoSelect: true,
  92. canEndNotMax: false,
  93. isShowOpponent: true,
  94. selectCardCoroutine: null,
  95. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  96. mode: SelectHandEffect.Mode.Discard,
  97. cardEffect: activateClass);
  98. yield return StartCoroutine(selectHandEffect.Activate());
  99. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  100. {
  101. if (cardSources.Count >= 1)
  102. {
  103. discarded = true;
  104. yield return null;
  105. }
  106. }
  107. if (discarded)
  108. {
  109. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardToReturnToHand));
  110. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  111. selectCardEffect.SetUp(
  112. canTargetCondition: CanSelectCardToReturnToHand,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. canNoSelect: () => false,
  116. selectCardCoroutine: null,
  117. afterSelectCardCoroutine: null,
  118. message: "Select 1 card to add to your hand.",
  119. maxCount: maxCount,
  120. canEndNotMax: false,
  121. isShowOpponent: true,
  122. mode: SelectCardEffect.Mode.AddHand,
  123. root: SelectCardEffect.Root.Trash,
  124. customRootCardList: null,
  125. canLookReverseCard: true,
  126. selectPlayer: card.Owner,
  127. cardEffect: activateClass);
  128. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  129. }
  130. }
  131. }
  132. }
  133. #endregion
  134. #region When Digivolving
  135. if (timing == EffectTiming.OnEnterFieldAnyone)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect("Trash 1 card to return 1 card back to you hand.", CanUseCondition, card);
  139. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  140. activateClass.SetHashString("Digivolving_BT16_031");
  141. cardEffects.Add(activateClass);
  142. string EffectDiscription()
  143. {
  144. return "[When Digivolving] By trashing 1 card in your hand, return 1 level 6 of lower 2-color Digimon card with red or purple from your trash to your hand.";
  145. }
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.IsExistOnBattleArea(card))
  153. {
  154. if (card.Owner.HandCards.Count >= 1)
  155. {
  156. return true;
  157. }
  158. }
  159. return false;
  160. }
  161. bool CanSelectCardToTrash(CardSource card)
  162. {
  163. if (card.Owner.HandCards.Count >= 1)
  164. {
  165. return true;
  166. }
  167. return false;
  168. }
  169. bool CanSelectCardToReturnToHand(CardSource cardSource)
  170. {
  171. if (cardSource.CardColors.Count == 2 && (cardSource.HasCardColor(CardColor.Red) || cardSource.HasCardColor(CardColor.Purple)))
  172. {
  173. if (cardSource.HasLevel && cardSource.Level <= 6)
  174. {
  175. if (cardSource.IsDigimon)
  176. {
  177. return true;
  178. }
  179. }
  180. }
  181. return false;
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable hashtable)
  184. {
  185. if (card.Owner.HandCards.Count(CanSelectCardToTrash) >= 1)
  186. {
  187. bool discarded = false;
  188. int discardCount = 1;
  189. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  190. selectHandEffect.SetUp(
  191. selectPlayer: card.Owner,
  192. canTargetCondition: CanSelectCardToTrash,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. maxCount: discardCount,
  196. canNoSelect: true,
  197. canEndNotMax: false,
  198. isShowOpponent: true,
  199. selectCardCoroutine: null,
  200. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  201. mode: SelectHandEffect.Mode.Discard,
  202. cardEffect: activateClass);
  203. yield return StartCoroutine(selectHandEffect.Activate());
  204. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  205. {
  206. if (cardSources.Count >= 1)
  207. {
  208. discarded = true;
  209. yield return null;
  210. }
  211. }
  212. if (discarded)
  213. {
  214. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardToReturnToHand));
  215. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  216. selectCardEffect.SetUp(
  217. canTargetCondition: CanSelectCardToReturnToHand,
  218. canTargetCondition_ByPreSelecetedList: null,
  219. canEndSelectCondition: null,
  220. canNoSelect: () => false,
  221. selectCardCoroutine: null,
  222. afterSelectCardCoroutine: null,
  223. message: "Select 1 card to add to your hand.",
  224. maxCount: maxCount,
  225. canEndNotMax: false,
  226. isShowOpponent: true,
  227. mode: SelectCardEffect.Mode.AddHand,
  228. root: SelectCardEffect.Root.Trash,
  229. customRootCardList: null,
  230. canLookReverseCard: true,
  231. selectPlayer: card.Owner,
  232. cardEffect: activateClass);
  233. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  234. }
  235. }
  236. }
  237. }
  238. #endregion
  239. #region Inherit
  240. if (timing == EffectTiming.None)
  241. {
  242. bool CardCondition(CardSource cardSource)
  243. {
  244. return cardSource.Owner == card.Owner.Enemy;
  245. }
  246. bool Condition()
  247. {
  248. if (CardEffectCommons.IsExistOnBattleArea(card))
  249. {
  250. if (CardEffectCommons.IsOwnerTurn(card))
  251. {
  252. return true;
  253. }
  254. }
  255. return false;
  256. }
  257. cardEffects.Add(CardEffectFactory.ChangeSecurityDigimonCardDPStaticEffect(
  258. cardCondition: CardCondition,
  259. changeValue: -3000,
  260. isInheritedEffect: true,
  261. card: card,
  262. condition: Condition,
  263. effectName: "Opponent's Security Digimon gains DP -3000"));
  264. }
  265. #endregion
  266. return cardEffects;
  267. }
  268. }
  269. }