BT24_038.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using UnityEngine;
  5. // Biomon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_038 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static effects
  14. #region Alternative Digivolution Condition - Stnd.
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasSuperAppTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Fortitude
  25. if (timing == EffectTiming.OnDestroyedAnyone)
  26. {
  27. cardEffects.Add(CardEffectFactory.FortitudeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Link Condition
  31. if (timing == EffectTiming.None)
  32. {
  33. static bool PermanentCondition(Permanent targetPermanent)
  34. {
  35. return targetPermanent.TopCard.HasAppmonTraits;
  36. }
  37. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  38. }
  39. #endregion
  40. #region App Fusion (Docmon, Medicmon)
  41. if (timing == EffectTiming.None)
  42. {
  43. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Docmon", "Medicmon" }, card));
  44. }
  45. #endregion
  46. #region Link
  47. if (timing == EffectTiming.OnDeclaration)
  48. {
  49. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  50. }
  51. #endregion
  52. #endregion
  53. #region Shared OP / WD
  54. string SharedEffectName() => "Link 1 level 4 or lower from hand or digivolution cards.";
  55. string SharedEffectDescription(string tag) => $"[{tag}] 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.";
  56. bool CanLinkCardCondition(CardSource cardSource)
  57. {
  58. return cardSource.IsDigimon &&
  59. cardSource.HasLevel && cardSource.Level <= 4 &&
  60. cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  61. }
  62. bool SharedCanActivateCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  65. (CardEffectCommons.HasMatchConditionOwnersHand(card, CanLinkCardCondition) ||
  66. card.PermanentOfThisCard().DigivolutionCards.Exists(CanLinkCardCondition));
  67. }
  68. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  69. {
  70. Permanent thisPermament = card.PermanentOfThisCard();
  71. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanLinkCardCondition);
  72. bool canSelectDigivolutionSources = thisPermament.DigivolutionCards.Exists(CanLinkCardCondition);
  73. if (canSelectHand || canSelectDigivolutionSources)
  74. {
  75. if (canSelectHand && canSelectDigivolutionSources)
  76. {
  77. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  78. {
  79. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  80. new SelectionElement<bool>(message: $"From digivolution", value : false, spriteIndex: 1),
  81. };
  82. string selectPlayerMessage = "From which area do you select a card?";
  83. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  84. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  85. }
  86. else
  87. {
  88. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  89. }
  90. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  91. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  92. CardSource selectedCard = null;
  93. IEnumerator SelectCardCoroutine(CardSource cardSource)
  94. {
  95. selectedCard = cardSource;
  96. yield return null;
  97. }
  98. if (fromHand)
  99. {
  100. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  101. selectHandEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: CanLinkCardCondition,
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: 1,
  107. canNoSelect: true,
  108. canEndNotMax: false,
  109. isShowOpponent: true,
  110. selectCardCoroutine: SelectCardCoroutine,
  111. afterSelectCardCoroutine: null,
  112. mode: SelectHandEffect.Mode.Custom,
  113. cardEffect: activateClass);
  114. selectHandEffect.SetUpCustomMessage("Select 1 card to add as link", "The opponent is selecting 1 card to add as link");
  115. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  116. }
  117. else
  118. {
  119. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  120. selectCardEffect.SetUp(
  121. canTargetCondition: CanLinkCardCondition,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. canNoSelect: () => true,
  125. selectCardCoroutine: SelectCardCoroutine,
  126. afterSelectCardCoroutine: null,
  127. message: "Select 1 card to add as link.",
  128. maxCount: 1,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. mode: SelectCardEffect.Mode.Custom,
  132. root: SelectCardEffect.Root.DigivolutionCards,
  133. customRootCardList: thisPermament.DigivolutionCards,
  134. canLookReverseCard: true,
  135. selectPlayer: card.Owner,
  136. cardEffect: activateClass);
  137. selectCardEffect.SetUpCustomMessage("Select 1 card to add as link.", "The opponent is selecting 1 card to add as link.");
  138. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  139. }
  140. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(thisPermament.AddLinkCard(addedLinkCard: selectedCard, cardEffect: activateClass));
  141. }
  142. }
  143. #endregion
  144. #region On Play
  145. if (timing == EffectTiming.OnEnterFieldAnyone)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  149. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDescription("On Play"));
  150. cardEffects.Add(activateClass);
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  154. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  155. }
  156. }
  157. #endregion
  158. #region When Digivolving
  159. if (timing == EffectTiming.OnEnterFieldAnyone)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  163. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, true, SharedEffectDescription("When Digivolving"));
  164. cardEffects.Add(activateClass);
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  168. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  169. }
  170. }
  171. #endregion
  172. #region All Turns
  173. if (timing == EffectTiming.WhenLinked)
  174. {
  175. ActivateClass activateClass = new ActivateClass();
  176. activateClass.SetUpICardEffect("DP -7000", CanUseCondition, card);
  177. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  178. activateClass.SetHashString("BT24_038_AT");
  179. cardEffects.Add(activateClass);
  180. string EffectDescription()
  181. => "[All Turns] [Once Per Turn] When this Digimon gets linked, 1 of your opponent's Digimon gets -7000 DP for the turn.";
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  185. CardEffectCommons.CanTriggerWhenLinked(hashtable, ThisDigimonPermamentCondition, null);
  186. }
  187. bool ThisDigimonPermamentCondition(Permanent permanent)
  188. {
  189. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  190. && permanent == card.PermanentOfThisCard();
  191. }
  192. bool CanActivateCondition(Hashtable hashtable)
  193. {
  194. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  195. }
  196. bool PermanentCondition(Permanent permanent)
  197. {
  198. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable hashtable)
  201. {
  202. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentCondition))
  203. {
  204. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  205. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  206. selectPermanentEffect.SetUp(
  207. selectPlayer: card.Owner,
  208. canTargetCondition: PermanentCondition,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. maxCount: maxCount,
  212. canNoSelect: false,
  213. canEndNotMax: false,
  214. selectPermanentCoroutine: SelectPermanentCoroutine,
  215. afterSelectPermanentCoroutine: null,
  216. mode: SelectPermanentEffect.Mode.Custom,
  217. cardEffect: activateClass);
  218. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -7000.", "The opponent is selecting 1 Digimon that will get DP -7000.");
  219. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  220. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  221. {
  222. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  223. targetPermanent: permanent,
  224. changeValue: -7000,
  225. effectDuration: EffectDuration.UntilEachTurnEnd,
  226. activateClass: activateClass));
  227. }
  228. }
  229. }
  230. }
  231. #endregion
  232. #region When Linked
  233. if (timing == EffectTiming.WhenLinked)
  234. {
  235. ActivateClass activateClass = new ActivateClass();
  236. activateClass.SetUpICardEffect("DP -7000", CanUseCondition, card);
  237. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  238. activateClass.SetIsLinkedEffect(true);
  239. cardEffects.Add(activateClass);
  240. string EffectDescription()
  241. => "[When Linking] 1 of your opponent's Digimon get -7000 DP for the turn.";
  242. bool CanUseCondition(Hashtable hashtable)
  243. {
  244. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  245. CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  246. }
  247. bool CanActivateCondition(Hashtable hashtable)
  248. {
  249. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  250. }
  251. bool PermanentCondition(Permanent permanent)
  252. {
  253. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  254. }
  255. IEnumerator ActivateCoroutine(Hashtable hashtable)
  256. {
  257. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentCondition))
  258. {
  259. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  260. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  261. selectPermanentEffect.SetUp(
  262. selectPlayer: card.Owner,
  263. canTargetCondition: PermanentCondition,
  264. canTargetCondition_ByPreSelecetedList: null,
  265. canEndSelectCondition: null,
  266. maxCount: maxCount,
  267. canNoSelect: false,
  268. canEndNotMax: false,
  269. selectPermanentCoroutine: SelectPermanentCoroutine,
  270. afterSelectPermanentCoroutine: null,
  271. mode: SelectPermanentEffect.Mode.Custom,
  272. cardEffect: activateClass);
  273. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -7000.", "The opponent is selecting 1 Digimon that will get DP -7000.");
  274. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  275. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  276. {
  277. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  278. targetPermanent: permanent,
  279. changeValue: -7000,
  280. effectDuration: EffectDuration.UntilEachTurnEnd,
  281. activateClass: activateClass));
  282. }
  283. }
  284. }
  285. }
  286. #endregion
  287. return cardEffects;
  288. }
  289. }
  290. }