BT21_023.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //Globemon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_023 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Static Effects
  13. #region Link Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasAppmonTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  21. }
  22. #endregion
  23. #region App Fusion (DoGatchmon, Timemon)
  24. if (timing == EffectTiming.None)
  25. {
  26. AddAppFusionConditionClass addAppFusionConditionClass = new AddAppFusionConditionClass();
  27. addAppFusionConditionClass.SetUpICardEffect($"App Fusion", (hashtable) => true, card);
  28. addAppFusionConditionClass.SetUpAddAppFusionConditionClass(getAppFusionCondition: GetAppFusion);
  29. addAppFusionConditionClass.SetNotShowUI(true);
  30. cardEffects.Add(addAppFusionConditionClass);
  31. AppFusionCondition GetAppFusion(CardSource cardSource)
  32. {
  33. string selectLinkMessage = "";
  34. string selectDigimonMessage = "";
  35. bool linkCondition(CardSource source)
  36. {
  37. if (source != null)
  38. {
  39. if (source.PermanentOfThisCard().TopCard.EqualsCardName("DoGatchmon"))
  40. {
  41. if (source.PermanentOfThisCard().LinkedCards.Find(x => x.EqualsCardName("Timemon")))
  42. {
  43. selectLinkMessage = "1 [Timemon]";
  44. return true;
  45. }
  46. }
  47. if (source.PermanentOfThisCard().TopCard.EqualsCardName("Timemon"))
  48. {
  49. if (source.PermanentOfThisCard().LinkedCards.Find(x => x.EqualsCardName("DoGatchmon")))
  50. {
  51. selectLinkMessage = "1 [DoGatchmon]";
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool digimonCondition(Permanent permanent)
  59. {
  60. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  61. {
  62. if (permanent.TopCard.EqualsCardName("DoGatchmon"))
  63. {
  64. if (permanent.LinkedCards.Find(x => x.EqualsCardName("Timemon")))
  65. {
  66. selectDigimonMessage = "1 [Timemon]";
  67. return true;
  68. }
  69. }
  70. if (permanent.TopCard.EqualsCardName("Timemon"))
  71. {
  72. if (permanent.LinkedCards.Find(x => x.EqualsCardName("DoGatchmon")))
  73. {
  74. selectDigimonMessage = "1 [DoGatchmon]";
  75. return true;
  76. }
  77. }
  78. }
  79. return false;
  80. }
  81. if (cardSource == card)
  82. {
  83. AppFusionCondition AppFusionCondition = new AppFusionCondition(
  84. linkCondition,
  85. selectLinkMessage,
  86. digimonCondition,
  87. selectDigimonMessage,
  88. 0);
  89. return AppFusionCondition;
  90. }
  91. return null;
  92. }
  93. }
  94. #endregion
  95. #region Sec +1
  96. if (timing == EffectTiming.None)
  97. {
  98. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  99. changeValue: 1,
  100. isInheritedEffect: false,
  101. card: card,
  102. condition: null));
  103. }
  104. #endregion
  105. #endregion
  106. #region On Play / When digivolving Shared
  107. bool CanSelectCardConditionShared(CardSource source)
  108. {
  109. if (source.IsDigimon)
  110. {
  111. if (source.HasLevel && source.Level <= 4)
  112. {
  113. if (source.CanLinkFromTargetPermanent(card.PermanentOfThisCard(), false))
  114. {
  115. return true;
  116. }
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  123. {
  124. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared);
  125. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardConditionShared(x)) != null;
  126. if (canSelectHand || canSelectSources)
  127. {
  128. if (canSelectHand && canSelectSources)
  129. {
  130. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  131. {
  132. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  133. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  134. };
  135. string selectPlayerMessage = "From which area do you select a card?";
  136. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  137. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  138. }
  139. else
  140. {
  141. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  142. }
  143. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  144. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  145. CardSource selectedCard = null;
  146. if (fromHand)
  147. {
  148. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardConditionShared));
  149. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  150. selectHandEffect.SetUp(
  151. selectPlayer: card.Owner,
  152. canTargetCondition: CanSelectCardConditionShared,
  153. canTargetCondition_ByPreSelecetedList: null,
  154. canEndSelectCondition: null,
  155. maxCount: maxCount,
  156. canNoSelect: true,
  157. canEndNotMax: false,
  158. isShowOpponent: true,
  159. selectCardCoroutine: SelectCardCoroutine,
  160. afterSelectCardCoroutine: null,
  161. mode: SelectHandEffect.Mode.Custom,
  162. cardEffect: activateClass);
  163. selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  164. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  165. yield return StartCoroutine(selectHandEffect.Activate());
  166. }
  167. else
  168. {
  169. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  170. selectCardEffect.SetUp(
  171. canTargetCondition: CanSelectCardConditionShared,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. canNoSelect: () => true,
  175. selectCardCoroutine: SelectCardCoroutine,
  176. afterSelectCardCoroutine: null,
  177. message: "Select 1 card to add as source.",
  178. maxCount: 1,
  179. canEndNotMax: false,
  180. isShowOpponent: true,
  181. mode: SelectCardEffect.Mode.Custom,
  182. root: SelectCardEffect.Root.Custom,
  183. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  184. canLookReverseCard: true,
  185. selectPlayer: card.Owner,
  186. cardEffect: activateClass);
  187. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  188. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  189. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  190. }
  191. IEnumerator SelectCardCoroutine(CardSource cardSource)
  192. {
  193. selectedCard = cardSource;
  194. yield return null;
  195. }
  196. if (selectedCard != null)
  197. {
  198. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(card, activateClass));
  199. }
  200. }
  201. }
  202. #endregion
  203. #region On Play
  204. if (timing == EffectTiming.OnEnterFieldAnyone)
  205. {
  206. ActivateClass activateClass = new ActivateClass();
  207. activateClass.SetUpICardEffect("You may Link 1 level 4 or lower digimon", CanUseCondition, card);
  208. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  209. cardEffects.Add(activateClass);
  210. string EffectDiscription()
  211. {
  212. return "[On Play] You may link 1 level 4 or lower Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost.";
  213. }
  214. bool CanUseCondition(Hashtable hashtable)
  215. {
  216. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  217. {
  218. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  219. {
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. bool CanActivateCondition(Hashtable hashtable)
  226. {
  227. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  228. {
  229. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared) || card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardConditionShared(x)) != null)
  230. {
  231. return true;
  232. }
  233. }
  234. return false;
  235. }
  236. }
  237. #endregion
  238. #region When Digivolving
  239. if (timing == EffectTiming.OnEnterFieldAnyone)
  240. {
  241. ActivateClass activateClass = new ActivateClass();
  242. activateClass.SetUpICardEffect("You may Link 1 level 4 or lower digimon", CanUseCondition, card);
  243. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  244. cardEffects.Add(activateClass);
  245. string EffectDiscription()
  246. {
  247. return "[When Digivolving] You may link 1 level 4 or lower Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost.";
  248. }
  249. bool CanUseCondition(Hashtable hashtable)
  250. {
  251. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  252. {
  253. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  254. {
  255. return true;
  256. }
  257. }
  258. return false;
  259. }
  260. bool CanActivateCondition(Hashtable hashtable)
  261. {
  262. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  263. {
  264. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared) || card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardConditionShared(x)) != null)
  265. {
  266. return true;
  267. }
  268. }
  269. return false;
  270. }
  271. }
  272. #endregion
  273. #region When Linked / When Linked ESS Shared
  274. bool CanSelectPermanentCondition(Permanent permanent)
  275. {
  276. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  277. {
  278. if (permanent.HasDP & permanent.DP <= card.PermanentOfThisCard().DP)
  279. {
  280. return true;
  281. }
  282. }
  283. return false;
  284. }
  285. IEnumerator SharedLinkedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  286. {
  287. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  288. {
  289. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  290. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  291. selectPermanentEffect.SetUp(
  292. selectPlayer: card.Owner,
  293. canTargetCondition: CanSelectPermanentCondition,
  294. canTargetCondition_ByPreSelecetedList: null,
  295. canEndSelectCondition: null,
  296. maxCount: maxCount,
  297. canNoSelect: false,
  298. canEndNotMax: false,
  299. selectPermanentCoroutine: null,
  300. afterSelectPermanentCoroutine: null,
  301. mode: SelectPermanentEffect.Mode.Destroy,
  302. cardEffect: activateClass);
  303. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  304. }
  305. }
  306. #endregion
  307. #region Your Turn
  308. if (timing == EffectTiming.WhenLinked)
  309. {
  310. ActivateClass activateClass = new ActivateClass();
  311. activateClass.SetUpICardEffect("Delete 1 digimon", CanUseCondition, card);
  312. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedLinkedActivateCoroutine(hashtable, activateClass), 1, false, EffectDiscription());
  313. activateClass.SetHashString("Delete_BT21_023");
  314. cardEffects.Add(activateClass);
  315. string EffectDiscription()
  316. {
  317. return "[Your Turn] [Once Per Turn] When this Digimon gets linked, delete 1 of your opponent’s Digimon with as much or less DP as this Digimon";
  318. }
  319. bool CanUseCondition(Hashtable hashtable)
  320. {
  321. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  322. {
  323. if (CardEffectCommons.CanTriggerWhenLinked(hashtable, permament => permament == card.PermanentOfThisCard(), null))
  324. {
  325. return true;
  326. }
  327. }
  328. return false;
  329. }
  330. bool CanActivateCondition(Hashtable hashtable)
  331. {
  332. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  333. {
  334. if (CardEffectCommons.IsOwnerTurn(card))
  335. {
  336. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  337. {
  338. return true;
  339. }
  340. }
  341. }
  342. return false;
  343. }
  344. }
  345. if (timing == EffectTiming.WhenLinked)
  346. {
  347. ActivateClass activateClass = new ActivateClass();
  348. activateClass.SetUpICardEffect("Delete 1 digimon", CanUseCondition, card);
  349. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedLinkedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  350. activateClass.SetIsLinkedEffect(true);
  351. cardEffects.Add(activateClass);
  352. string EffectDiscription()
  353. {
  354. return "[When Linking] Delete 1 of your opponent's Digimon. with as much or less DP as this Digimon.";
  355. }
  356. bool CanUseCondition(Hashtable hashtable)
  357. {
  358. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  359. {
  360. if (CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card))
  361. {
  362. return true;
  363. }
  364. }
  365. return false;
  366. }
  367. bool CanActivateCondition(Hashtable hashtable)
  368. {
  369. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  370. {
  371. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  372. {
  373. return true;
  374. }
  375. }
  376. return false;
  377. }
  378. }
  379. #endregion
  380. #region ESS - When Linked
  381. if (timing == EffectTiming.None)
  382. {
  383. ActivateClass activateClass = new ActivateClass();
  384. activateClass.SetUpICardEffect("", CanUseCondition, card);
  385. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  386. cardEffects.Add(activateClass);
  387. string EffectDiscription()
  388. {
  389. return "";
  390. }
  391. bool CanUseCondition(Hashtable hashtable)
  392. {
  393. return true;
  394. }
  395. bool CanActivateCondition(Hashtable hashtable)
  396. {
  397. return true;
  398. }
  399. IEnumerator ActivateCoroutine(Hashtable hashtable)
  400. {
  401. yield return null;
  402. }
  403. }
  404. #endregion
  405. #region ESS - +4k DP
  406. if (timing == EffectTiming.None)
  407. {
  408. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 2000, isInheritedEffect: false, card: card, condition: null, isLinkedEffect: true));
  409. }
  410. #endregion
  411. return cardEffects;
  412. }
  413. }
  414. }