BT23_024.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Poseidomon
  4. namespace DCGO.CardEffects.BT23
  5. {
  6. public class BT23_024 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Static Effects
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasUltimateAppTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 4,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region App Fusion (Oujamon & Beautymon)
  29. if (timing == EffectTiming.None)
  30. {
  31. AddAppFusionConditionClass addAppFusionConditionClass = new AddAppFusionConditionClass();
  32. addAppFusionConditionClass.SetUpICardEffect($"App Fusion", (hashtable) => true, card);
  33. addAppFusionConditionClass.SetUpAddAppFusionConditionClass(getAppFusionCondition: GetAppFusion);
  34. addAppFusionConditionClass.SetNotShowUI(true);
  35. cardEffects.Add(addAppFusionConditionClass);
  36. AppFusionCondition GetAppFusion(CardSource cardSource)
  37. {
  38. bool linkCondition(Permanent permanent, CardSource source)
  39. {
  40. if (source != null)
  41. {
  42. if (source != card)
  43. {
  44. if (permanent.TopCard.EqualsCardName("Oujamon"))
  45. {
  46. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Beautymon")))
  47. {
  48. return true;
  49. }
  50. }
  51. if (permanent.TopCard.EqualsCardName("Beautymon"))
  52. {
  53. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Oujamon")))
  54. {
  55. return true;
  56. }
  57. }
  58. }
  59. return false;
  60. }
  61. return false;
  62. }
  63. bool digimonCondition(Permanent permanent)
  64. {
  65. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  66. {
  67. if (permanent.TopCard.EqualsCardName("Oujamon"))
  68. {
  69. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Beautymon")))
  70. {
  71. return true;
  72. }
  73. }
  74. if (permanent.TopCard.EqualsCardName("Beautymon"))
  75. {
  76. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Oujamon")))
  77. {
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. return false;
  84. }
  85. if (cardSource == card)
  86. {
  87. AppFusionCondition AppFusionCondition = new AppFusionCondition(
  88. linkedCondition: linkCondition,
  89. digimonCondition: digimonCondition,
  90. cost: 0);
  91. return AppFusionCondition;
  92. }
  93. return null;
  94. }
  95. }
  96. #endregion
  97. #region Evade
  98. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  99. {
  100. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(
  101. isInheritedEffect: false,
  102. card: card,
  103. condition: null));
  104. }
  105. #endregion
  106. #region Link +1
  107. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(1, false, card, null));
  108. #endregion
  109. #endregion
  110. #region WD/WA Shared
  111. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  112. {
  113. bool CanSelectCardCondition(CardSource cardSource)
  114. {
  115. return cardSource.IsDigimon
  116. && cardSource.HasAppmonTraits
  117. && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  118. }
  119. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  120. bool canselectSources = card.PermanentOfThisCard().StackCards.Exists(CanSelectCardCondition);
  121. if (canSelectHand || canselectSources)
  122. {
  123. if (canSelectHand && canselectSources)
  124. {
  125. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  126. {
  127. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  128. new SelectionElement<bool>(message: $"From digivolution sources", value : false, spriteIndex: 1),
  129. };
  130. string selectPlayerMessage = "From which area do you select a card?";
  131. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  132. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  133. }
  134. else
  135. {
  136. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  137. }
  138. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  139. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  140. CardSource selectedCard = null;
  141. IEnumerator SelectCardCoroutine(CardSource cardSource)
  142. {
  143. selectedCard = cardSource;
  144. yield return null;
  145. }
  146. if (fromHand)
  147. {
  148. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  149. selectHandEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectCardCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: 1,
  155. canNoSelect: true,
  156. canEndNotMax: false,
  157. isShowOpponent: true,
  158. selectCardCoroutine: SelectCardCoroutine,
  159. afterSelectCardCoroutine: null,
  160. mode: SelectHandEffect.Mode.Custom,
  161. cardEffect: activateClass);
  162. selectHandEffect.SetUpCustomMessage("Select 1 card to link", "The opponent is selecting 1 card to link.");
  163. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  164. }
  165. else
  166. {
  167. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  168. selectCardEffect.SetUp(
  169. canTargetCondition: CanSelectCardCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. canNoSelect: () => true,
  173. selectCardCoroutine: SelectCardCoroutine,
  174. afterSelectCardCoroutine: null,
  175. message: "Select 1 card to link",
  176. maxCount: 1,
  177. canEndNotMax: false,
  178. isShowOpponent: true,
  179. mode: SelectCardEffect.Mode.Custom,
  180. root: SelectCardEffect.Root.Custom,
  181. customRootCardList: card.PermanentOfThisCard().StackCards,
  182. canLookReverseCard: true,
  183. selectPlayer: card.Owner,
  184. cardEffect: activateClass);
  185. selectCardEffect.SetUpCustomMessage("Select 1 card to link", "The opponent is selecting 1 card to link.");
  186. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  187. }
  188. if (selectedCard != null)
  189. {
  190. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(
  191. addedLinkCard: selectedCard,
  192. cardEffect: activateClass));
  193. }
  194. }
  195. }
  196. #endregion
  197. #region When Digivolving
  198. if (timing == EffectTiming.OnEnterFieldAnyone)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("Link 1 digimon with [Appmon] trait from hand or this card's digivolution cards", CanUseCondition, card);
  202. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscription());
  203. cardEffects.Add(activateClass);
  204. string EffectDiscription()
  205. {
  206. return "[When Digivolving] [When Attacking] You may link 1 Digimon card with the [Appmon] trait from your hand or this Digimon's digivolution cards to this Digimon without paying the cost.";
  207. }
  208. bool CanUseCondition(Hashtable hashtable)
  209. {
  210. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  211. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  212. }
  213. bool CanActivateCondition(Hashtable hashtable)
  214. {
  215. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  216. }
  217. }
  218. #endregion
  219. #region When Attacking
  220. if (timing == EffectTiming.OnAllyAttack)
  221. {
  222. ActivateClass activateClass = new ActivateClass();
  223. activateClass.SetUpICardEffect("Link 1 digimon with [Appmon] trait from hand or this card's digivolution cards", CanUseCondition, card);
  224. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDiscription());
  225. cardEffects.Add(activateClass);
  226. string EffectDiscription()
  227. {
  228. return "[When Attacking] You may link 1 Digimon card with the [Appmon] trait from your hand or this Digimon's digivolution cards to this Digimon without paying the cost.";
  229. }
  230. bool CanUseCondition(Hashtable hashtable)
  231. {
  232. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  233. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  234. }
  235. bool CanActivateCondition(Hashtable hashtable)
  236. {
  237. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  238. }
  239. }
  240. #endregion
  241. #region When Linked - OPT
  242. if (timing == EffectTiming.WhenLinked)
  243. {
  244. ActivateClass activateClass = new ActivateClass();
  245. activateClass.SetUpICardEffect("By unsuspending this digimon, all but their highest play cost digimon cant suspend", CanUseCondition, card);
  246. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  247. activateClass.SetHashString("BT23-024_WL");
  248. cardEffects.Add(activateClass);
  249. string EffectDiscription()
  250. {
  251. return "[All Turns] [Once Per Turn] When this Digimon gets linked, by unsuspending it, other than their highest play cost Digimon, none of your opponent's Digimon can suspend until their turn ends.";
  252. }
  253. bool CanUseCondition(Hashtable hashtable)
  254. {
  255. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  256. && CardEffectCommons.CanTriggerWhenLinked(hashtable, IsThisDigimon, null);
  257. }
  258. bool CanActivateCondition(Hashtable hashtable)
  259. {
  260. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  261. && CardEffectCommons.IsOwnerTurn(card);
  262. }
  263. bool IsThisDigimon(Permanent permanent)
  264. {
  265. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  266. && permanent == card.PermanentOfThisCard();
  267. }
  268. IEnumerator ActivateCoroutine(Hashtable hashtable)
  269. {
  270. if (card.PermanentOfThisCard().IsSuspended && CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  271. {
  272. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  273. permanents: new List<Permanent>() { card.PermanentOfThisCard() },
  274. cardEffect: activateClass).Unsuspend());
  275. var digimonToStun = CardEffectCommons.GetNonMaxCostPermanents(card.Owner.Enemy);
  276. foreach (var permanent in digimonToStun)
  277. {
  278. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotSuspend(
  279. targetPermanent: permanent,
  280. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  281. activateClass: activateClass,
  282. condition: null,
  283. effectName: "Can not suspend"));
  284. }
  285. }
  286. }
  287. }
  288. #endregion
  289. return cardEffects;
  290. }
  291. }
  292. }