BT21_023.cs 21 KB

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