BT16_016.cs 14 KB

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