BT21_023.cs 21 KB

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