BT11_034.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT11
  5. {
  6. public class BT11_034 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return (targetPermanent.TopCard.CardTraits.Contains("Xros Heart") || targetPermanent.TopCard.CardTraits.Contains("XrosHeart")) && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 2;
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Place cards to digivolution cards from trash", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[On Play] Place 1 Digimon card with [Xros Heart] in its traits from your trash under 1 of your Tamers. If you have a Digimon with [Dorulumon] in its name or with [Dorulumon] in its digivolution cards, place up to 2 Digimon cards with [Xros Heart] in their traits from your trash under 1 of your Tamers instead.";
  28. }
  29. bool CanSelectPermanentCondition(Permanent permanent)
  30. {
  31. if (permanent != null)
  32. {
  33. if (permanent.TopCard != null)
  34. {
  35. if (permanent.IsTamer)
  36. {
  37. if (permanent.TopCard.Owner == card.Owner)
  38. {
  39. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  40. {
  41. if (!permanent.IsToken)
  42. {
  43. return true;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
  50. return false;
  51. }
  52. bool CanSelectCardCondition(CardSource cardSource)
  53. {
  54. if (cardSource != null)
  55. {
  56. if (cardSource.IsDigimon)
  57. {
  58. if (cardSource.Owner == card.Owner)
  59. {
  60. if (cardSource.CardTraits.Contains("Xros Heart"))
  61. {
  62. return true;
  63. }
  64. if (cardSource.CardTraits.Contains("XrosHeart"))
  65. {
  66. return true;
  67. }
  68. }
  69. }
  70. }
  71. return false;
  72. }
  73. bool CanUseCondition(Hashtable hashtable)
  74. {
  75. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  76. }
  77. bool CanActivateCondition(Hashtable hashtable)
  78. {
  79. if (CardEffectCommons.IsExistOnBattleArea(card))
  80. {
  81. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  82. {
  83. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  84. {
  85. return true;
  86. }
  87. }
  88. }
  89. return false;
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  92. {
  93. if (isExistOnField(card))
  94. {
  95. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  96. {
  97. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  98. {
  99. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  100. {
  101. List<CardSource> selectedCards = new List<CardSource>();
  102. List<CardSource> digivolutionCards = new List<CardSource>();
  103. int maxCount = 1;
  104. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && (permanent.TopCard.ContainsCardName("Dorulumon") || permanent.DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Dorulumon")) >= 1)))
  105. {
  106. maxCount = 2;
  107. }
  108. if (maxCount == 1)
  109. {
  110. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  111. selectCardEffect.SetUp(
  112. canTargetCondition: CanSelectCardCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. canNoSelect: () => false,
  116. selectCardCoroutine: SelectCardCoroutine,
  117. afterSelectCardCoroutine: null,
  118. message: "Select 1 Digimon card with [Xros Heart] in its traits from trash.",
  119. maxCount: maxCount,
  120. canEndNotMax: false,
  121. isShowOpponent: true,
  122. mode: SelectCardEffect.Mode.Custom,
  123. root: SelectCardEffect.Root.Trash,
  124. customRootCardList: null,
  125. canLookReverseCard: true,
  126. selectPlayer: card.Owner,
  127. cardEffect: activateClass);
  128. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card with [Xros Heart] in its traits from trash.", "The opponent is selecting 1 Digimon card with [Xros Heart] in its traits from trash.");
  129. yield return StartCoroutine(selectCardEffect.Activate());
  130. IEnumerator SelectCardCoroutine(CardSource cardSource)
  131. {
  132. selectedCards.Add(cardSource);
  133. yield return null;
  134. }
  135. }
  136. else if (maxCount == 2)
  137. {
  138. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  139. selectCardEffect.SetUp(
  140. canTargetCondition: CanSelectCardCondition,
  141. canTargetCondition_ByPreSelecetedList: null,
  142. canEndSelectCondition: CanEndSelectCondition,
  143. canNoSelect: () => false,
  144. selectCardCoroutine: SelectCardCoroutine,
  145. afterSelectCardCoroutine: null,
  146. message: "Select up to 2 Digimon cards with [Xros Heart] in its traits from trash\n(cards will be placed so that cards with lower numbers are on top).",
  147. maxCount: maxCount,
  148. canEndNotMax: true,
  149. isShowOpponent: true,
  150. mode: SelectCardEffect.Mode.Custom,
  151. root: SelectCardEffect.Root.Trash,
  152. customRootCardList: null,
  153. canLookReverseCard: true,
  154. selectPlayer: card.Owner,
  155. cardEffect: activateClass);
  156. selectCardEffect.SetUpCustomMessage("Select up to 2 Digimon cards with [Xros Heart] in its traits from trash.", "The opponent is selecting up to 2 Digimon cards with [Xros Heart] in its traits from trash.");
  157. yield return StartCoroutine(selectCardEffect.Activate());
  158. bool CanEndSelectCondition(List<CardSource> cardSources)
  159. {
  160. if (maxCount >= 1)
  161. {
  162. if (cardSources.Count <= 0)
  163. {
  164. return false;
  165. }
  166. }
  167. return true;
  168. }
  169. IEnumerator SelectCardCoroutine(CardSource cardSource)
  170. {
  171. selectedCards.Add(cardSource);
  172. yield return null;
  173. }
  174. }
  175. if (selectedCards.Count >= 1)
  176. {
  177. foreach (CardSource cardSource in selectedCards)
  178. {
  179. digivolutionCards.Add(cardSource);
  180. }
  181. if (digivolutionCards.Count >= 1)
  182. {
  183. maxCount = 1;
  184. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  185. selectPermanentEffect.SetUp(
  186. selectPlayer: card.Owner,
  187. canTargetCondition: CanSelectPermanentCondition,
  188. canTargetCondition_ByPreSelecetedList: null,
  189. canEndSelectCondition: null,
  190. maxCount: maxCount,
  191. canNoSelect: false,
  192. canEndNotMax: false,
  193. selectPermanentCoroutine: SelectPermanentCoroutine,
  194. afterSelectPermanentCoroutine: null,
  195. mode: SelectPermanentEffect.Mode.Custom,
  196. cardEffect: activateClass);
  197. selectPermanentEffect.SetUpCustomMessage($"Select 1 Tamer that will get digivolution cards from trash.", $"The opponent is selecting 1 Tamer that will get a digivolution cards from trash.");
  198. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  199. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  200. {
  201. Permanent selectedPermanent = permanent;
  202. if (selectedPermanent != null)
  203. {
  204. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(digivolutionCards, activateClass));
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. return cardEffects;
  216. }
  217. }
  218. }