BT25_060.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Rebootmon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_060 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition - Ult.
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasUltimateAppTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region App Fusion (Bootmon, Shutmon)
  23. if (timing == EffectTiming.None)
  24. {
  25. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Bootmon", "Shutmon" }, card));
  26. }
  27. #endregion
  28. #region Security +1
  29. if (timing == EffectTiming.None)
  30. {
  31. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  32. }
  33. #endregion
  34. #region Reboot
  35. if (timing == EffectTiming.None)
  36. {
  37. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  38. }
  39. #endregion
  40. #region Link +1
  41. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(1, false, card, null));
  42. #endregion
  43. #region Shared WD / WA
  44. string SharedHashString = "BT25_060_WD_WA";
  45. string SharedEffectName = "Link from hand or digivolution cards to unsuspend";
  46. string SharedEffectDescription(string tag)
  47. => $"[{tag}] [Once Per Turn] By linking 1 [Appmon] trait Digimon card from your hand or this Digimon's digivolution cards to this Digimon without paying the cost, 1 of your Digimon may unsuspend.";
  48. bool LinkableCard(CardSource cardSource)
  49. {
  50. return cardSource.HasAppmonTraits
  51. && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  52. }
  53. bool IsYourDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  54. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  55. {
  56. return CardEffectCommons.HasMatchConditionOwnersHand(card, LinkableCard)
  57. || card.PermanentOfThisCard().DigivolutionCards.Any(LinkableCard);
  58. }
  59. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  60. {
  61. bool linked = false;
  62. Permanent thisPermanent = card.PermanentOfThisCard();
  63. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, LinkableCard);
  64. bool validDigivolutionCard = thisPermanent.DigivolutionCards.Any(LinkableCard);
  65. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  66. if (validHandCard)
  67. {
  68. selectionElements.Add(new (message: $"Link from Hand", value : 1, spriteIndex: 0));
  69. }
  70. if (validDigivolutionCard)
  71. {
  72. selectionElements.Add(new (message: $"Link from Digivolution Cards", value : 2, spriteIndex: 0));
  73. }
  74. selectionElements.Add( new (message: $"Don't link", value: 3, spriteIndex: 1));
  75. string selectPlayerMessage = "From which area will you link a card?";
  76. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  77. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  78. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  79. bool doLink = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  80. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  81. if (doLink)
  82. {
  83. if (fromHand)
  84. {
  85. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  86. selectHandEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: LinkableCard,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: 1,
  92. canNoSelect: true,
  93. canEndNotMax: false,
  94. isShowOpponent: true,
  95. selectCardCoroutine: SelectCardCoroutine,
  96. afterSelectCardCoroutine: null,
  97. mode: SelectHandEffect.Mode.Custom,
  98. cardEffect: activateClass);
  99. selectHandEffect.SetUpCustomMessage($"Select a card to link.", "The opponent is selecting cards to link.");
  100. yield return StartCoroutine(selectHandEffect.Activate());
  101. }
  102. else
  103. {
  104. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  105. selectCardEffect.SetUp(
  106. canTargetCondition: LinkableCard,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. canNoSelect: () => true,
  110. selectCardCoroutine: SelectCardCoroutine,
  111. afterSelectCardCoroutine: null,
  112. message: "Select card to link.",
  113. maxCount: 1,
  114. canEndNotMax: false,
  115. isShowOpponent: true,
  116. mode: SelectCardEffect.Mode.Custom,
  117. root: SelectCardEffect.Root.DigivolutionCards,
  118. customRootCardList: thisPermanent.DigivolutionCards,
  119. canLookReverseCard: true,
  120. selectPlayer: card.Owner,
  121. cardEffect: activateClass);
  122. selectCardEffect.SetUpCustomMessage($"Select a cards to link.", "The opponent is selecting cards to link.");
  123. yield return StartCoroutine(selectCardEffect.Activate());
  124. }
  125. IEnumerator SelectCardCoroutine(CardSource cardSource)
  126. {
  127. linked = true;
  128. yield return ContinuousController.instance.StartCoroutine(thisPermanent.AddLinkCard(cardSource, activateClass));
  129. }
  130. }
  131. if (linked)
  132. {
  133. if (CardEffectCommons.HasMatchConditionPermanent(IsYourDigimon))
  134. {
  135. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  136. selectPermanentEffect.SetUp(
  137. selectPlayer: card.Owner,
  138. canTargetCondition: IsYourDigimon,
  139. canTargetCondition_ByPreSelecetedList: null,
  140. canEndSelectCondition: null,
  141. maxCount: 1,
  142. canNoSelect: true,
  143. canEndNotMax: false,
  144. selectPermanentCoroutine: null,
  145. afterSelectPermanentCoroutine: null,
  146. mode: SelectPermanentEffect.Mode.UnTap,
  147. cardEffect: activateClass);
  148. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  149. }
  150. }
  151. else activateClass.RemoveUse();
  152. }
  153. CardEffectFactory.ActivateClassesForSharedEffects
  154. (ref cardEffects, timing, card,
  155. SharedEffectName,
  156. SharedActivateCoroutine,
  157. SharedEffectDescription,
  158. additionalActivateCondition: AdditionalActivateCondition,
  159. maxCountPerTurn: 1,
  160. hashValue: SharedHashString,
  161. optional: false,
  162. isSkippable: true,
  163. whenDigivolving: true,
  164. whenAttacking: true);
  165. #endregion
  166. #region Shared All Turns
  167. string AllTurnsHashString = "BT25_060_AT_GAIN_EFFECTS";
  168. string AllTurnsEffectName = "Gain <Piercing>, <Blocker> and Digimon Effect Immunity";
  169. bool AllTurnsActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  170. string AllTurnsEffectDescription()
  171. => "[All Turns] [Once Per Turn] When this Digimon gets linked or unsuspends, until your turn ends, this Digimon gains <Piercing> and <Blocker>, and your opponent's Digimon effects don't affect it.";
  172. IEnumerator AllTurnsActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  173. {
  174. Permanent thisPermanent = card.PermanentOfThisCard();
  175. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(
  176. targetPermanent: thisPermanent,
  177. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  178. activateClass: activateClass));
  179. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  180. targetPermanent: thisPermanent,
  181. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  182. activateClass: activateClass));
  183. ICardEffect GetImmunity(EffectTiming timing)
  184. {
  185. if (timing == EffectTiming.None)
  186. {
  187. return PermanentEffectFactory.DigimonEffectImmunity(thisPermanent);
  188. }
  189. return null;
  190. }
  191. thisPermanent.UntilOwnerTurnEndEffects.Add(GetImmunity);
  192. }
  193. if (timing == EffectTiming.WhenLinked)
  194. {
  195. ActivateClass activateClass = new();
  196. activateClass.SetUpICardEffect(AllTurnsEffectName, CanUseCondition, card);
  197. activateClass.SetUpActivateClass(AllTurnsActivateCondition, hash => AllTurnsActivateCoroutine(hash, activateClass), 1, false, AllTurnsEffectDescription());
  198. activateClass.SetHashString(AllTurnsHashString);
  199. cardEffects.Add(activateClass);
  200. bool CanUseCondition(Hashtable hashtable)
  201. {
  202. return CardEffectCommons.IsExistOnBattleArea(card)
  203. && CardEffectCommons.CanTriggerWhenLinked(hashtable, ThisDigimonPermamentCondition, null);
  204. }
  205. bool ThisDigimonPermamentCondition(Permanent permanent)
  206. {
  207. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  208. && permanent == card.PermanentOfThisCard();
  209. }
  210. }
  211. if (timing == EffectTiming.OnUnTappedAnyone)
  212. {
  213. ActivateClass activateClass = new();
  214. activateClass.SetUpICardEffect(AllTurnsEffectName, CanUseCondition, card);
  215. activateClass.SetUpActivateClass(AllTurnsActivateCondition, hash => AllTurnsActivateCoroutine(hash, activateClass), 1, false, AllTurnsEffectDescription());
  216. activateClass.SetHashString(AllTurnsHashString);
  217. cardEffects.Add(activateClass);
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.IsExistOnBattleArea(card)
  221. && CardEffectCommons.CanTriggerWhenSelfPermanentUnsuspends(hashtable, card);
  222. }
  223. }
  224. #endregion
  225. return cardEffects;
  226. }
  227. }
  228. }