BT16_040.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_040 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Digivolve Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. if (targetPermanent.TopCard.CardNames.Contains("Minomon"))
  17. {
  18. return true;
  19. }
  20. return false;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Inherit
  26. if (timing == EffectTiming.OnAllyAttack)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  31. activateClass.SetHashString("Suspend_BT16-040");
  32. activateClass.SetIsInheritedEffect(true);
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "[When Attacking] [Once per turn] Suspend 1 of your opponent's Digimon.";
  37. }
  38. bool IsOpponentDigimon(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  45. }
  46. bool CanActivateCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentDigimon))
  53. {
  54. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsOpponentDigimon));
  55. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  56. selectPermanentEffect.SetUp(
  57. selectPlayer: card.Owner,
  58. canTargetCondition: IsOpponentDigimon,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. maxCount: maxCount,
  62. canNoSelect: false,
  63. canEndNotMax: false,
  64. selectPermanentCoroutine: null,
  65. afterSelectPermanentCoroutine: null,
  66. mode: SelectPermanentEffect.Mode.Tap,
  67. cardEffect: activateClass);
  68. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  69. }
  70. }
  71. }
  72. #endregion
  73. #region Start of Main
  74. if (timing == EffectTiming.OnStartMainPhase)
  75. {
  76. ActivateClass activateClass = new ActivateClass();
  77. activateClass.SetUpICardEffect("1 of your Digimon may Digivolve", CanUseCondition, card);
  78. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  79. activateClass.SetHashString("Digivolve_BT16_040");
  80. cardEffects.Add(activateClass);
  81. string EffectDiscription()
  82. {
  83. return "[Start of Main Phase] If it's your turn, 1 of your Digimon may digivolve into a level 4 Digimon card with the [Insectoid] or [Free] trait from your trash with the digivolution cost reduced by 1.";
  84. }
  85. bool CanSelectCardCondition(CardSource cardSource)
  86. {
  87. if (cardSource.CardTraits.Contains("Insectoid") || cardSource.CardTraits.Contains("Free"))
  88. {
  89. if (cardSource.HasLevel && cardSource.Level == 4)
  90. {
  91. return true;
  92. }
  93. }
  94. return false;
  95. }
  96. bool CanSelectPermanentCondition(Permanent permanent)
  97. {
  98. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  99. {
  100. foreach (CardSource cardSource in card.Owner.TrashCards)
  101. {
  102. if (CanSelectCardCondition(cardSource))
  103. {
  104. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  105. {
  106. return true;
  107. }
  108. }
  109. }
  110. }
  111. return false;
  112. }
  113. bool CanUseCondition(Hashtable hashtable)
  114. {
  115. if (CardEffectCommons.IsExistOnBattleArea(card))
  116. {
  117. if (CardEffectCommons.IsOwnerTurn(card))
  118. {
  119. return true;
  120. }
  121. }
  122. return false;
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. if (CardEffectCommons.IsExistOnBattleArea(card))
  127. {
  128. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  129. {
  130. if (card.Owner.TrashCards.Count >= 1)
  131. {
  132. return true;
  133. }
  134. }
  135. }
  136. return false;
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  139. {
  140. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  141. {
  142. Permanent selectedPermanent = null;
  143. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  144. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  145. selectPermanentEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanSelectPermanentCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: maxCount,
  151. canNoSelect: true,
  152. canEndNotMax: false,
  153. selectPermanentCoroutine: SelectPermanentCoroutine,
  154. afterSelectPermanentCoroutine: null,
  155. mode: SelectPermanentEffect.Mode.Custom,
  156. cardEffect: activateClass);
  157. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  158. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  159. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  160. {
  161. selectedPermanent = permanent;
  162. yield return null;
  163. }
  164. if (selectedPermanent != null)
  165. {
  166. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  167. targetPermanent: selectedPermanent,
  168. cardCondition: CanSelectCardCondition,
  169. payCost: true,
  170. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  171. fixedCostTuple: null,
  172. ignoreDigivolutionRequirementFixedCost: -1,
  173. isHand: false,
  174. activateClass: activateClass,
  175. successProcess: null));
  176. }
  177. }
  178. }
  179. }
  180. #endregion
  181. #region On Play
  182. if (timing == EffectTiming.OnEnterFieldAnyone)
  183. {
  184. ActivateClass activateClass = new ActivateClass();
  185. activateClass.SetUpICardEffect("1 of your Digimon may Digivolve", CanUseCondition, card);
  186. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  187. activateClass.SetHashString("Digivolve_BT16_040");
  188. cardEffects.Add(activateClass);
  189. string EffectDiscription()
  190. {
  191. return "[On Play] If it's your turn, 1 of your Digimon may digivolve into a level 4 Digimon card with the [Insectoid] or [Free] trait from your trash with the digivolution cost reduced by 1.";
  192. }
  193. bool CanSelectCardCondition(CardSource cardSource)
  194. {
  195. if (cardSource.CardTraits.Contains("Insectoid") || cardSource.CardTraits.Contains("Free"))
  196. {
  197. if (cardSource.HasLevel && cardSource.Level == 4)
  198. {
  199. return true;
  200. }
  201. }
  202. return false;
  203. }
  204. bool CanSelectPermanentCondition(Permanent permanent)
  205. {
  206. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  207. {
  208. foreach (CardSource cardSource in card.Owner.TrashCards)
  209. {
  210. if (CanSelectCardCondition(cardSource))
  211. {
  212. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass))
  213. {
  214. return true;
  215. }
  216. }
  217. }
  218. }
  219. return false;
  220. }
  221. bool CanUseCondition(Hashtable hashtable)
  222. {
  223. if (CardEffectCommons.IsOwnerTurn(card))
  224. {
  225. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  226. }
  227. return false;
  228. }
  229. bool CanActivateCondition(Hashtable hashtable)
  230. {
  231. if (CardEffectCommons.IsExistOnBattleArea(card))
  232. {
  233. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  234. {
  235. if (card.Owner.TrashCards.Count >= 1)
  236. {
  237. return true;
  238. }
  239. }
  240. }
  241. return false;
  242. }
  243. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  244. {
  245. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  246. {
  247. Permanent selectedPermanent = null;
  248. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  249. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  250. selectPermanentEffect.SetUp(
  251. selectPlayer: card.Owner,
  252. canTargetCondition: CanSelectPermanentCondition,
  253. canTargetCondition_ByPreSelecetedList: null,
  254. canEndSelectCondition: null,
  255. maxCount: maxCount,
  256. canNoSelect: true,
  257. canEndNotMax: false,
  258. selectPermanentCoroutine: SelectPermanentCoroutine,
  259. afterSelectPermanentCoroutine: null,
  260. mode: SelectPermanentEffect.Mode.Custom,
  261. cardEffect: activateClass);
  262. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  263. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  264. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  265. {
  266. selectedPermanent = permanent;
  267. yield return null;
  268. }
  269. if (selectedPermanent != null)
  270. {
  271. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  272. targetPermanent: selectedPermanent,
  273. cardCondition: CanSelectCardCondition,
  274. payCost: true,
  275. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  276. fixedCostTuple: null,
  277. ignoreDigivolutionRequirementFixedCost: -1,
  278. isHand: false,
  279. activateClass: activateClass,
  280. successProcess: null));
  281. }
  282. }
  283. }
  284. }
  285. #endregion
  286. return cardEffects;
  287. }
  288. }
  289. }