ST22_12.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using UnityEngine;
  5. //DoGatchamon
  6. namespace DCGO.CardEffects.ST22
  7. {
  8. public class ST22_12 : 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.EqualsTraits("Stnd.");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Raid
  25. if (timing == EffectTiming.OnAllyAttack)
  26. {
  27. cardEffects.Add(CardEffectFactory.RaidSelfEffect(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: 2, card: card));
  38. }
  39. #endregion
  40. #region App Fusion (Gatchmon, Navimon, Tweetmon)
  41. if (timing == EffectTiming.None)
  42. {
  43. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Gatchmon", "Navimon", "Tweetmon" }, 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 When Attacking
  54. if (timing == EffectTiming.OnAllyAttack)
  55. {
  56. ActivateClass activateClass = new ActivateClass();
  57. activateClass.SetUpICardEffect("You may Link 1 digimon", CanUseCondition, card);
  58. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  59. activateClass.SetHashString("WA_ST22-12");
  60. cardEffects.Add(activateClass);
  61. string EffectDiscription()
  62. {
  63. return "[When Attacking] [Once Per Turn] You may link 1 Digimon card with the [Social], [Navi] or [Tool] trait from your hand or this Digimon's digivolution cards to this Digimon with the link cost reduced by 2.";
  64. }
  65. bool CanSelectCardConditionShared(CardSource source)
  66. {
  67. return source.IsDigimon &&
  68. source.CanLinkToTargetPermanent(card.PermanentOfThisCard(), true) &&
  69. (source.ContainsTraits("Social") || source.ContainsTraits("Navi") || source.ContainsTraits("Tool"));
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  74. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  75. }
  76. bool CanActivateCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  79. (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared) || card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardConditionShared(x)).Count > 0);
  80. }
  81. IEnumerator ActivateCoroutine(Hashtable hashtable)
  82. {
  83. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardConditionShared);
  84. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardConditionShared(x)).Count > 0;
  85. #region Link Cost Reduction
  86. ICardEffect GetCardEffect(EffectTiming _timing)
  87. {
  88. if (_timing == EffectTiming.None)
  89. {
  90. return CardEffectFactory.GrantedReduceLinkCostClass(
  91. card: card,
  92. reducedCost: 2,
  93. cardSourceCondition: _ => true,
  94. permanentCondition: _ => true,
  95. rootCondition: _ => true
  96. );
  97. }
  98. return null;
  99. }
  100. card.Owner.UntilCalculateFixedCostEffect.Add(GetCardEffect);
  101. #endregion
  102. if (canSelectHand || canSelectSources)
  103. {
  104. if (canSelectHand && canSelectSources)
  105. {
  106. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  107. {
  108. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  109. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  110. };
  111. string selectPlayerMessage = "From which area do you select a card?";
  112. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  113. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  114. }
  115. else
  116. {
  117. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  118. }
  119. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  120. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  121. CardSource selectedCard = null;
  122. if (fromHand)
  123. {
  124. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardConditionShared));
  125. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  126. selectHandEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectCardConditionShared,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: maxCount,
  132. canNoSelect: true,
  133. canEndNotMax: false,
  134. isShowOpponent: true,
  135. selectCardCoroutine: SelectCardCoroutine,
  136. afterSelectCardCoroutine: null,
  137. mode: SelectHandEffect.Mode.Custom,
  138. cardEffect: activateClass);
  139. selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  140. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  141. yield return StartCoroutine(selectHandEffect.Activate());
  142. }
  143. else
  144. {
  145. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  146. selectCardEffect.SetUp(
  147. canTargetCondition: CanSelectCardConditionShared,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. canNoSelect: () => true,
  151. selectCardCoroutine: SelectCardCoroutine,
  152. afterSelectCardCoroutine: null,
  153. message: "Select 1 card to add as source.",
  154. maxCount: 1,
  155. canEndNotMax: false,
  156. isShowOpponent: true,
  157. mode: SelectCardEffect.Mode.Custom,
  158. root: SelectCardEffect.Root.Custom,
  159. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  160. canLookReverseCard: true,
  161. selectPlayer: card.Owner,
  162. cardEffect: activateClass);
  163. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  164. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  165. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  166. }
  167. IEnumerator SelectCardCoroutine(CardSource cardSource)
  168. {
  169. selectedCard = cardSource;
  170. yield return null;
  171. }
  172. if (selectedCard != null)
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(new ILinkCard(true, selectedCard, card.PermanentOfThisCard(), activateClass).LinkCard());
  175. }
  176. }
  177. #region Remove Link Cost Reduction
  178. card.Owner.UntilCalculateFixedCostEffect.Remove(GetCardEffect);
  179. #endregion
  180. }
  181. }
  182. #endregion
  183. #region When Linked
  184. if (timing == EffectTiming.WhenLinked)
  185. {
  186. ActivateClass activateClass = new ActivateClass();
  187. activateClass.SetUpICardEffect("Return a digimon to bottom of deck", CanUseCondition, card);
  188. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  189. activateClass.SetIsLinkedEffect(true);
  190. cardEffects.Add(activateClass);
  191. string EffectDiscription()
  192. => "[When Linking] Return 1 of your opponent's 5000 DP or lower Digimon to the bottom of the deck.";
  193. bool CanUseCondition(Hashtable hashtable)
  194. {
  195. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  196. {
  197. if (CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card))
  198. {
  199. return true;
  200. }
  201. }
  202. return false;
  203. }
  204. bool CanActivateCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  207. CardEffectCommons.HasMatchConditionPermanent(PermanentCondition);
  208. }
  209. bool PermanentCondition(Permanent permanent)
  210. {
  211. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  212. permanent.DP <= 5000;
  213. }
  214. IEnumerator ActivateCoroutine(Hashtable hashtable)
  215. {
  216. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentCondition))
  217. {
  218. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  219. selectPermanentEffect.SetUp(
  220. selectPlayer: card.Owner,
  221. canTargetCondition: PermanentCondition,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. maxCount: 1,
  225. canNoSelect: false,
  226. canEndNotMax: false,
  227. selectPermanentCoroutine: null,
  228. afterSelectPermanentCoroutine: null,
  229. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  230. cardEffect: activateClass);
  231. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon.", "The opponent is selecting 1 Digimon.");
  232. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  233. }
  234. }
  235. }
  236. #endregion
  237. return cardEffects;
  238. }
  239. }
  240. }