BT21_023.cs 17 KB

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