BT12_109.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_109 : 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.None)
  13. {
  14. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  15. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  16. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  17. cardEffects.Add(ignoreColorConditionClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer && permanent.TopCard.CardTraits.Contains("Hunter")))
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. bool CardCondition(CardSource cardSource)
  27. {
  28. if (cardSource == card)
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. }
  35. if (timing == EffectTiming.OptionSkill)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  39. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  40. cardEffects.Add(activateClass);
  41. string EffectDiscription()
  42. {
  43. return "[Main] Digivolve 1 of your Digimon into a Digimon card with <Save> in its text under one of your Tamers for its digivolution cost.";
  44. }
  45. bool CanSelectPermanentCondition(Permanent permanent)
  46. {
  47. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  48. {
  49. bool CanSelectCardCondition(CardSource cardSource)
  50. {
  51. if (CardEffectCommons.IsExistOnBattleArea(cardSource))
  52. {
  53. if (cardSource.Owner == permanent.TopCard.Owner)
  54. {
  55. if (cardSource.PermanentOfThisCard().IsTamer)
  56. {
  57. if (cardSource.PermanentOfThisCard().DigivolutionCards.Contains(cardSource))
  58. {
  59. if (cardSource.IsDigimon)
  60. {
  61. if (cardSource.HasSaveText)
  62. {
  63. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass, root: SelectCardEffect.Root.DigivolutionCards))
  64. {
  65. return true;
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. return false;
  74. }
  75. bool CanSelectPermanentCondition1(Permanent permanent1)
  76. {
  77. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent1, card))
  78. {
  79. if (permanent1.IsTamer)
  80. {
  81. if (permanent1.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  82. {
  83. return true;
  84. }
  85. }
  86. }
  87. return false;
  88. }
  89. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  90. {
  91. return true;
  92. }
  93. }
  94. return false;
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  99. }
  100. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  101. {
  102. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  103. {
  104. Permanent selectedPermanent = null;
  105. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  106. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  107. selectPermanentEffect.SetUp(
  108. selectPlayer: card.Owner,
  109. canTargetCondition: CanSelectPermanentCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. maxCount: maxCount,
  113. canNoSelect: false,
  114. canEndNotMax: false,
  115. selectPermanentCoroutine: SelectPermanentCoroutine,
  116. afterSelectPermanentCoroutine: null,
  117. mode: SelectPermanentEffect.Mode.Custom,
  118. cardEffect: activateClass);
  119. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  120. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  121. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  122. {
  123. selectedPermanent = permanent;
  124. yield return null;
  125. }
  126. if (selectedPermanent != null)
  127. {
  128. bool CanSelectCardCondition(CardSource cardSource)
  129. {
  130. if (CardEffectCommons.IsExistOnBattleArea(cardSource))
  131. {
  132. if (cardSource.Owner == selectedPermanent.TopCard.Owner)
  133. {
  134. if (cardSource.PermanentOfThisCard().IsTamer)
  135. {
  136. if (cardSource.PermanentOfThisCard().DigivolutionCards.Contains(cardSource))
  137. {
  138. if (cardSource.IsDigimon)
  139. {
  140. if (cardSource.HasSaveText)
  141. {
  142. if (cardSource.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, true, activateClass, root: SelectCardEffect.Root.DigivolutionCards))
  143. {
  144. return true;
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. return false;
  153. }
  154. bool CanSelectPermanentCondition1(Permanent permanent1)
  155. {
  156. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent1, card))
  157. {
  158. if (permanent1.IsTamer)
  159. {
  160. if (permanent1.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  161. {
  162. return true;
  163. }
  164. }
  165. }
  166. return false;
  167. }
  168. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  169. {
  170. Permanent selectedTamer = null;
  171. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  172. selectPermanentEffect.SetUp(
  173. selectPlayer: card.Owner,
  174. canTargetCondition: CanSelectPermanentCondition1,
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. maxCount: maxCount,
  178. canNoSelect: false,
  179. canEndNotMax: false,
  180. selectPermanentCoroutine: SelectPermanentCoroutine1,
  181. afterSelectPermanentCoroutine: null,
  182. mode: SelectPermanentEffect.Mode.Custom,
  183. cardEffect: activateClass);
  184. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer.", "The opponent is selecting 1 Tamer.");
  185. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  186. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  187. {
  188. selectedTamer = permanent;
  189. yield return null;
  190. }
  191. if (selectedTamer != null)
  192. {
  193. if (selectedTamer.DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)) >= 1)
  194. {
  195. maxCount = Math.Min(1, selectedTamer.DigivolutionCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  196. List<CardSource> selectedCards = new List<CardSource>();
  197. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  198. selectCardEffect.SetUp(
  199. canTargetCondition: CanSelectCardCondition,
  200. canTargetCondition_ByPreSelecetedList: null,
  201. canEndSelectCondition: null,
  202. canNoSelect: () => false,
  203. selectCardCoroutine: SelectCardCoroutine,
  204. afterSelectCardCoroutine: null,
  205. message: "Select 1 Digimon card with <Save> in its text to digivolve from digivolution cards.",
  206. maxCount: maxCount,
  207. canEndNotMax: false,
  208. isShowOpponent: true,
  209. mode: SelectCardEffect.Mode.Custom,
  210. root: SelectCardEffect.Root.Custom,
  211. customRootCardList: selectedTamer.DigivolutionCards,
  212. canLookReverseCard: true,
  213. selectPlayer: card.Owner,
  214. cardEffect: activateClass);
  215. selectCardEffect.SetUpCustomMessage("Select 1 Digimon card with <Save> in its text to digivolve from digivolution cards.", "The opponent is selecting 1 Digimon card with <Save> in its text to digivolve from digivolution cards.");
  216. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  217. yield return StartCoroutine(selectCardEffect.Activate());
  218. IEnumerator SelectCardCoroutine(CardSource cardSource)
  219. {
  220. selectedCards.Add(cardSource);
  221. yield return null;
  222. }
  223. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  224. cardSources: selectedCards,
  225. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  226. payCost: true,
  227. targetPermanent: selectedPermanent,
  228. isTapped: false,
  229. root: SelectCardEffect.Root.DigivolutionCards,
  230. activateETB: true).PlayCard());
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. if (timing == EffectTiming.SecuritySkill)
  239. {
  240. ActivateClass activateClass = new ActivateClass();
  241. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  242. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  243. activateClass.SetIsSecurityEffect(true);
  244. cardEffects.Add(activateClass);
  245. string EffectDiscription()
  246. {
  247. return "[Security] Add this card to its owner's hand.";
  248. }
  249. bool CanUseCondition(Hashtable hashtable)
  250. {
  251. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  252. }
  253. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  254. {
  255. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  256. }
  257. }
  258. return cardEffects;
  259. }
  260. }
  261. }