ST22_12.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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(), false) &&
  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. if (canSelectHand || canSelectSources)
  86. {
  87. if (canSelectHand && canSelectSources)
  88. {
  89. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  90. {
  91. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  92. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  93. };
  94. string selectPlayerMessage = "From which area do you select a card?";
  95. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  96. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  97. }
  98. else
  99. {
  100. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  101. }
  102. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  103. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  104. CardSource selectedCard = null;
  105. if (fromHand)
  106. {
  107. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardConditionShared));
  108. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  109. selectHandEffect.SetUp(
  110. selectPlayer: card.Owner,
  111. canTargetCondition: CanSelectCardConditionShared,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. maxCount: maxCount,
  115. canNoSelect: true,
  116. canEndNotMax: false,
  117. isShowOpponent: true,
  118. selectCardCoroutine: SelectCardCoroutine,
  119. afterSelectCardCoroutine: null,
  120. mode: SelectHandEffect.Mode.Custom,
  121. cardEffect: activateClass);
  122. selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  123. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  124. yield return StartCoroutine(selectHandEffect.Activate());
  125. }
  126. else
  127. {
  128. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  129. selectCardEffect.SetUp(
  130. canTargetCondition: CanSelectCardConditionShared,
  131. canTargetCondition_ByPreSelecetedList: null,
  132. canEndSelectCondition: null,
  133. canNoSelect: () => true,
  134. selectCardCoroutine: SelectCardCoroutine,
  135. afterSelectCardCoroutine: null,
  136. message: "Select 1 card to add as source.",
  137. maxCount: 1,
  138. canEndNotMax: false,
  139. isShowOpponent: true,
  140. mode: SelectCardEffect.Mode.Custom,
  141. root: SelectCardEffect.Root.Custom,
  142. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  143. canLookReverseCard: true,
  144. selectPlayer: card.Owner,
  145. cardEffect: activateClass);
  146. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  147. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  148. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  149. }
  150. IEnumerator SelectCardCoroutine(CardSource cardSource)
  151. {
  152. selectedCard = cardSource;
  153. yield return null;
  154. }
  155. if (selectedCard != null)
  156. {
  157. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-Mathf.Max(0,selectedCard.linkCondition.cost - 2), activateClass));
  158. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(selectedCard, activateClass));
  159. }
  160. }
  161. }
  162. }
  163. #endregion
  164. #region When Linked
  165. if (timing == EffectTiming.WhenLinked)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect("Return a digimon to bottom of deck", CanUseCondition, card);
  169. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  170. activateClass.SetIsLinkedEffect(true);
  171. cardEffects.Add(activateClass);
  172. string EffectDiscription()
  173. => "[When Linking] Return 1 of your opponent's 5000 DP or lower Digimon to the bottom of the deck.";
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  177. {
  178. if (CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card))
  179. {
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  188. CardEffectCommons.HasMatchConditionPermanent(PermanentCondition);
  189. }
  190. bool PermanentCondition(Permanent permanent)
  191. {
  192. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  193. permanent.DP <= 5000;
  194. }
  195. IEnumerator ActivateCoroutine(Hashtable hashtable)
  196. {
  197. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermanentCondition))
  198. {
  199. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  200. selectPermanentEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition: PermanentCondition,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. maxCount: 1,
  206. canNoSelect: false,
  207. canEndNotMax: false,
  208. selectPermanentCoroutine: null,
  209. afterSelectPermanentCoroutine: null,
  210. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  211. cardEffect: activateClass);
  212. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon.", "The opponent is selecting 1 Digimon.");
  213. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  214. }
  215. }
  216. }
  217. #endregion
  218. return cardEffects;
  219. }
  220. }
  221. }