BT21_101.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Gaiamon
  6. namespace DCGO.CardEffects.BT21
  7. {
  8. public class BT21_101 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition - Ult.
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Ult.");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Static Effects
  24. #region App Fusion (Globemon & Charismon)
  25. if (timing == EffectTiming.None)
  26. {
  27. AddAppFusionConditionClass addAppFusionConditionClass = new AddAppFusionConditionClass();
  28. addAppFusionConditionClass.SetUpICardEffect($"App Fusion", (hashtable) => true, card);
  29. addAppFusionConditionClass.SetUpAddAppFusionConditionClass(getAppFusionCondition: GetAppFusion);
  30. addAppFusionConditionClass.SetNotShowUI(true);
  31. cardEffects.Add(addAppFusionConditionClass);
  32. AppFusionCondition GetAppFusion(CardSource cardSource)
  33. {
  34. string selectLinkMessage = "";
  35. string selectDigimonMessage = "";
  36. bool linkCondition(CardSource source)
  37. {
  38. if (source != null)
  39. {
  40. if (source.PermanentOfThisCard().TopCard.EqualsCardName("Globemon"))
  41. {
  42. if (source.PermanentOfThisCard().LinkedCards.Find(x => x.EqualsCardName("Charismon")))
  43. {
  44. selectLinkMessage = "1 [Charismon]";
  45. return true;
  46. }
  47. }
  48. if (source.PermanentOfThisCard().TopCard.EqualsCardName("Charismon"))
  49. {
  50. if (source.PermanentOfThisCard().LinkedCards.Find(x => x.EqualsCardName("Globemon")))
  51. {
  52. selectLinkMessage = "1 [Globemon]";
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. return false;
  59. }
  60. bool digimonCondition(Permanent permanent)
  61. {
  62. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  63. {
  64. if (permanent.TopCard.EqualsCardName("Globemon"))
  65. {
  66. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Charismon")))
  67. {
  68. selectDigimonMessage = "1 [Charismon]";
  69. return true;
  70. }
  71. }
  72. if (permanent.TopCard.EqualsCardName("Charismon"))
  73. {
  74. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Globemon")))
  75. {
  76. selectDigimonMessage = "1 [Globemon]";
  77. return true;
  78. }
  79. }
  80. return false;
  81. }
  82. return false;
  83. }
  84. if (cardSource == card)
  85. {
  86. AppFusionCondition AppFusionCondition = new AppFusionCondition(
  87. linkedCondition: linkCondition,
  88. selectLinkMessage: selectLinkMessage,
  89. digimonCondition: digimonCondition,
  90. selectDigimonMessage: selectDigimonMessage,
  91. cost: 0);
  92. return AppFusionCondition;
  93. }
  94. return null;
  95. }
  96. }
  97. #endregion
  98. #region Blocker
  99. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  100. #endregion
  101. #region Link +1
  102. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(1, false, card, null));
  103. #endregion
  104. #endregion
  105. #region YourTurn
  106. if (timing == EffectTiming.WhenLinked)
  107. {
  108. ActivateClass activateClass = new ActivateClass();
  109. activateClass.SetUpICardEffect("Unsuspend, trash top sec", CanUseCondition, card);
  110. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  111. activateClass.SetHashString("BT21_101_WhenLinked");
  112. cardEffects.Add(activateClass);
  113. string EffectDiscription()
  114. => "[Your Turn] [Once Per Turn] When your Digimon get linked, by unsuspending this Digimon, trash your opponent's top security card.";
  115. bool CanUseCondition(Hashtable hashtable)
  116. => CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  117. && CardEffectCommons.IsOwnerTurn(card)
  118. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, cardSource => true)
  119. && card.PermanentOfThisCard().IsSuspended
  120. && CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard());
  121. bool PermanentCondition(Permanent permanent)
  122. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  123. bool CanActivateCondition(Hashtable hashtable)
  124. => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  125. IEnumerator ActivateCoroutine(Hashtable hashtable)
  126. {
  127. Permanent thisPermanent = card.PermanentOfThisCard();
  128. if(thisPermanent.CanUnsuspend && thisPermanent.IsSuspended)
  129. {
  130. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  131. new List<Permanent>() { card.PermanentOfThisCard() },
  132. activateClass).Unsuspend());
  133. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  134. player: card.Owner.Enemy,
  135. destroySecurityCount: 1,
  136. cardEffect: activateClass,
  137. fromTop: true).DestroySecurity());
  138. }
  139. }
  140. }
  141. #endregion
  142. #region WD/WA Shared
  143. bool SharedCanActivateCondition(Hashtable hashtable)
  144. {
  145. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  146. {
  147. return true;
  148. }
  149. return false;
  150. }
  151. bool CanSelectLinkCard(CardSource cardSource)
  152. {
  153. if (cardSource.HasAppmonTraits)
  154. return cardSource.CanLink(false);
  155. return false;
  156. }
  157. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  158. {
  159. bool hasInHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectLinkCard);
  160. bool hasInSources = card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectLinkCard) > 0;
  161. bool selectedRoot = false;
  162. CardSource selectedCard = null;
  163. if (hasInHand && hasInSources)
  164. {
  165. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  166. {
  167. new SelectionElement<bool>(message: $"From This Digimon", value: true, spriteIndex: 0),
  168. new SelectionElement<bool>(message: $"From Hand", value: false, spriteIndex: 1),
  169. };
  170. string selectPlayerMessage = "Choose where to get the digimon from";
  171. string notSelectPlayerMessage = "The opponent is choosing effects.";
  172. GManager.instance.userSelectionManager.SetBoolSelection(
  173. selectionElements: selectionElements, selectPlayer: card.Owner,
  174. selectPlayerMessage: selectPlayerMessage,
  175. notSelectPlayerMessage: notSelectPlayerMessage);
  176. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  177. .userSelectionManager.WaitForEndSelect());
  178. selectedRoot = GManager.instance.userSelectionManager.SelectedBoolValue;
  179. }
  180. else if (hasInSources)
  181. {
  182. selectedRoot = true;
  183. }
  184. if (selectedRoot)
  185. {
  186. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  187. selectCardEffect.SetUp(
  188. canTargetCondition: CanSelectLinkCard,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. canNoSelect: () => true,
  192. selectCardCoroutine: SelectCardCoroutine,
  193. afterSelectCardCoroutine: null,
  194. message: "Select 1 card to link.",
  195. maxCount: 1,
  196. canEndNotMax: false,
  197. isShowOpponent: true,
  198. mode: SelectCardEffect.Mode.Custom,
  199. root: SelectCardEffect.Root.Custom,
  200. customRootCardList: card.PermanentOfThisCard().LinkedCards,
  201. canLookReverseCard: true,
  202. selectPlayer: card.Owner,
  203. cardEffect: activateClass);
  204. selectCardEffect.SetUpCustomMessage("Select 1 card to link", "The opponent is selecting 1 card to link");
  205. yield return StartCoroutine(selectCardEffect.Activate());
  206. }
  207. else
  208. {
  209. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  210. selectHandEffect.SetUp(
  211. selectPlayer: card.Owner,
  212. canTargetCondition: CanSelectLinkCard,
  213. canTargetCondition_ByPreSelecetedList: null,
  214. canEndSelectCondition: null,
  215. maxCount: 1,
  216. canNoSelect: true,
  217. canEndNotMax: false,
  218. isShowOpponent: true,
  219. selectCardCoroutine: SelectCardCoroutine,
  220. afterSelectCardCoroutine: null,
  221. mode: SelectHandEffect.Mode.Custom,
  222. cardEffect: activateClass);
  223. selectHandEffect.SetUpCustomMessage("Select 1 card to link", "The opponent is selecting 1 card to link");
  224. yield return StartCoroutine(selectHandEffect.Activate());
  225. }
  226. IEnumerator SelectCardCoroutine(CardSource cardSource)
  227. {
  228. selectedCard = cardSource;
  229. yield return null;
  230. }
  231. if(selectedCard != null)
  232. {
  233. bool CanSelectDigimon(Permanent permanent)
  234. {
  235. UnityEngine.Debug.Log($"CAN SELECT DIGIMON: {CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)}, {selectedCard.CanLinkToTargetPermanent(permanent, false)}");
  236. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  237. return selectedCard.CanLinkToTargetPermanent(permanent, false);
  238. return false;
  239. }
  240. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimon))
  241. {
  242. Permanent selectedPermanent = null;
  243. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigimon));
  244. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  245. selectPermanentEffect.SetUp(
  246. selectPlayer: card.Owner,
  247. canTargetCondition: CanSelectDigimon,
  248. canTargetCondition_ByPreSelecetedList: null,
  249. canEndSelectCondition: null,
  250. maxCount: maxCount,
  251. canNoSelect: true,
  252. canEndNotMax: false,
  253. selectPermanentCoroutine: SelectPermanentCoroutine,
  254. afterSelectPermanentCoroutine: null,
  255. mode: SelectPermanentEffect.Mode.Custom,
  256. cardEffect: activateClass);
  257. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to add link", "The opponent is selecting 1 digimon to add link");
  258. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  259. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  260. {
  261. selectedPermanent = permanent;
  262. yield return null;
  263. }
  264. if (selectedPermanent != null)
  265. {
  266. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(selectedCard, activateClass));
  267. }
  268. }
  269. }
  270. }
  271. #endregion
  272. #region When Digivolving
  273. if (timing == EffectTiming.OnEnterFieldAnyone)
  274. {
  275. ActivateClass activateClass = new ActivateClass();
  276. activateClass.SetUpICardEffect("Add new link to a digimon", CanUseCondition, card);
  277. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  278. cardEffects.Add(activateClass);
  279. string EffectDiscription()
  280. => "[When Digivolving] You may link 1 Digimon card with the [Appmon] trait from your hand or this Digimon's digivolution cards to 1 of your Digimon without paying the cost.";
  281. bool CanUseCondition(Hashtable hashtable)
  282. {
  283. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  284. {
  285. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  286. {
  287. return true;
  288. }
  289. }
  290. return false;
  291. }
  292. }
  293. #endregion
  294. #region When Attacking
  295. if (timing == EffectTiming.OnAllyAttack)
  296. {
  297. ActivateClass activateClass = new ActivateClass();
  298. activateClass.SetUpICardEffect("Add new link to a digimon", CanUseCondition, card);
  299. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  300. cardEffects.Add(activateClass);
  301. string EffectDiscription()
  302. => "[When Attacking] You may link 1 Digimon card with the [Appmon] trait from your hand or this Digimon's digivolution cards to 1 of your Digimon without paying the cost.";
  303. bool CanUseCondition(Hashtable hashtable)
  304. {
  305. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  306. {
  307. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  308. {
  309. return true;
  310. }
  311. }
  312. return false;
  313. }
  314. }
  315. #endregion
  316. return cardEffects;
  317. }
  318. }
  319. }