Wormmon_BT16_040.cs 15 KB

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