BT22_039.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Ouranosmon
  6. namespace DCGO.CardEffects.BT22
  7. {
  8. public class BT22_039 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Ultimate Appmon Alternative Digivolution Requirement
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasUltimateAppTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region App Fusion (Entermon & Fakemon)
  25. if (timing == EffectTiming.None)
  26. {
  27. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Entermon", "Fakemon" }, card));
  28. }
  29. #endregion
  30. #region Alliance
  31. if (timing == EffectTiming.OnAllyAttack)
  32. {
  33. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  34. }
  35. #endregion
  36. #region Link +1
  37. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(1, false, card, null));
  38. #endregion
  39. #endregion
  40. #region When Digivolving
  41. if (timing == EffectTiming.OnEnterFieldAnyone)
  42. {
  43. ActivateClass activateClass = new ActivateClass();
  44. activateClass.SetUpICardEffect("Play 1 Level 4 or lower [Appmon]", CanUseCondition, card);
  45. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  46. activateClass.SetHashString("BT22_039_WDWA");
  47. cardEffects.Add(activateClass);
  48. string EffectDiscription()
  49. {
  50. return "[When Digivolving] [Once Per Turn] You may play 1 level 4 or lower [Appmon] trait Digimon card from your hand without paying the cost.";
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  55. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  60. && CardEffectCommons.HasMatchConditionOwnersHand(card, IsAppMon);
  61. }
  62. bool IsAppMon(CardSource cardSource)
  63. {
  64. return cardSource.IsDigimon
  65. && cardSource.HasLevel && cardSource.Level <= 4
  66. && cardSource.HasAppmonTraits
  67. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsAppMon))
  72. {
  73. CardSource selectedCard = null;
  74. #region Select Card From Hand
  75. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsAppMon));
  76. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  77. selectHandEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: IsAppMon,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: true,
  84. canEndNotMax: false,
  85. isShowOpponent: true,
  86. selectCardCoroutine: SelectCardCoroutine,
  87. afterSelectCardCoroutine: null,
  88. mode: SelectHandEffect.Mode.Custom,
  89. cardEffect: activateClass);
  90. IEnumerator SelectCardCoroutine(CardSource cardSource)
  91. {
  92. selectedCard = cardSource;
  93. yield return null;
  94. }
  95. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  96. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  97. #endregion
  98. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  99. CardEffectCommons.PlayPermanentCards(
  100. cardSources: new List<CardSource>() { selectedCard },
  101. activateClass: activateClass,
  102. payCost: false,
  103. isTapped: false,
  104. root: SelectCardEffect.Root.Hand,
  105. activateETB: true));
  106. }
  107. }
  108. }
  109. #endregion
  110. #region When Attacking
  111. if (timing == EffectTiming.OnAllyAttack)
  112. {
  113. ActivateClass activateClass = new ActivateClass();
  114. activateClass.SetUpICardEffect("Play 1 Level 4 or lower [Appmon]", CanUseCondition, card);
  115. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  116. activateClass.SetHashString("BT22_039_WDWA");
  117. cardEffects.Add(activateClass);
  118. string EffectDiscription()
  119. {
  120. return "[When Attacking] [Once Per Turn] You may play 1 level 4 or lower [Appmon] trait Digimon card from your hand without paying the cost.";
  121. }
  122. bool CanUseCondition(Hashtable hashtable)
  123. {
  124. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  125. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  126. }
  127. bool CanActivateCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  130. && CardEffectCommons.HasMatchConditionOwnersHand(card, IsAppMon);
  131. }
  132. bool IsAppMon(CardSource cardSource)
  133. {
  134. return cardSource.IsDigimon
  135. && cardSource.HasLevel && cardSource.Level <= 4
  136. && cardSource.HasAppmonTraits
  137. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  138. }
  139. IEnumerator ActivateCoroutine(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsAppMon))
  142. {
  143. CardSource selectedCard = null;
  144. #region Select Card From Hand
  145. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsAppMon));
  146. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  147. selectHandEffect.SetUp(
  148. selectPlayer: card.Owner,
  149. canTargetCondition: IsAppMon,
  150. canTargetCondition_ByPreSelecetedList: null,
  151. canEndSelectCondition: null,
  152. maxCount: maxCount,
  153. canNoSelect: true,
  154. canEndNotMax: false,
  155. isShowOpponent: true,
  156. selectCardCoroutine: SelectCardCoroutine,
  157. afterSelectCardCoroutine: null,
  158. mode: SelectHandEffect.Mode.Custom,
  159. cardEffect: activateClass);
  160. IEnumerator SelectCardCoroutine(CardSource cardSource)
  161. {
  162. selectedCard = cardSource;
  163. yield return null;
  164. }
  165. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  166. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  167. #endregion
  168. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  169. CardEffectCommons.PlayPermanentCards(
  170. cardSources: new List<CardSource>() { selectedCard },
  171. activateClass: activateClass,
  172. payCost: false,
  173. isTapped: false,
  174. root: SelectCardEffect.Root.Hand,
  175. activateETB: true));
  176. }
  177. }
  178. }
  179. #endregion
  180. #region All Turns
  181. if (timing == EffectTiming.OnEnterFieldAnyone)
  182. {
  183. ActivateClass activateClass = new ActivateClass();
  184. activateClass.SetUpICardEffect("Link 1 [Appmon] digimon in sources to 1 digimon", CanUseCondition, card);
  185. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  186. activateClass.SetHashString("BT22_039_FreeLink");
  187. cardEffects.Add(activateClass);
  188. string EffectDiscription()
  189. {
  190. return "[All Turns] [Once Per Turn] When any of your Digimon are played, you may link 1 [Appmon] trait Digimon card from this Digimon's digivolution cards to 1 of your Digimon without paying the cost.";
  191. }
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. return CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition, null);
  195. }
  196. bool CanActivateCondition(Hashtable hashtable)
  197. {
  198. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  199. && card.PermanentOfThisCard().DigivolutionCards.Filter(x => x.CanLink(false)).Count >= 1;
  200. }
  201. bool PermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  202. bool OwnPermamentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  203. bool LinkCardCondition(CardSource cardSource, Permanent targetPermament) => cardSource.CanLinkToTargetPermanent(targetPermament, false);
  204. IEnumerator ActivateCoroutine(Hashtable hashtable)
  205. {
  206. Permanent selectedPermament = null;
  207. #region Select Permanent
  208. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, OwnPermamentCondition));
  209. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  210. selectPermanentEffect.SetUp(
  211. selectPlayer: card.Owner,
  212. canTargetCondition: OwnPermamentCondition,
  213. canTargetCondition_ByPreSelecetedList: null,
  214. canEndSelectCondition: null,
  215. maxCount: maxCount,
  216. canNoSelect: true,
  217. canEndNotMax: false,
  218. selectPermanentCoroutine: SelectPermanentCoroutine,
  219. afterSelectPermanentCoroutine: null,
  220. mode: SelectPermanentEffect.Mode.Custom,
  221. cardEffect: activateClass);
  222. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  223. {
  224. selectedPermament = permanent;
  225. yield return null;
  226. }
  227. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to get link", "The opponent is selecting 1 Digimon to get link");
  228. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  229. #endregion
  230. if (selectedPermament != null)
  231. {
  232. CardSource selectedLink = null;
  233. #region Select Digivolution
  234. int maxCount1 = Math.Min(1, card.PermanentOfThisCard().DigivolutionCards.Count(cs => LinkCardCondition(cs, selectedPermament)));
  235. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  236. selectCardEffect.SetUp(
  237. canTargetCondition: cs => LinkCardCondition(cs, selectedPermament),
  238. canTargetCondition_ByPreSelecetedList: null,
  239. canEndSelectCondition: null,
  240. canNoSelect: () => false,
  241. selectCardCoroutine: SelectCardCoroutine,
  242. afterSelectCardCoroutine: null,
  243. message: "Select 1 digivolution card to link.",
  244. maxCount: maxCount1,
  245. canEndNotMax: false,
  246. isShowOpponent: true,
  247. mode: SelectCardEffect.Mode.Custom,
  248. root: SelectCardEffect.Root.DigivolutionCards,
  249. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  250. canLookReverseCard: true,
  251. selectPlayer: card.Owner,
  252. cardEffect: activateClass);
  253. IEnumerator SelectCardCoroutine(CardSource cardSource)
  254. {
  255. selectedLink = cardSource;
  256. yield return null;
  257. }
  258. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  259. yield return StartCoroutine(selectCardEffect.Activate());
  260. #endregion
  261. if (selectedLink != null) yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddLinkCard(selectedLink, activateClass));
  262. }
  263. }
  264. }
  265. #endregion
  266. return cardEffects;
  267. }
  268. }
  269. }