BT21_101.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. // Gaiamon
  7. namespace DCGO.CardEffects.BT21
  8. {
  9. public class BT21_101 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Static Effects
  15. #region Alternative Digivolution Condition - Ult.
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. return targetPermanent.TopCard.EqualsTraits("Ult.");
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region App Fusion (Globemon & Charismon)
  26. if (timing == EffectTiming.None)
  27. {
  28. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Globemon", "Charismon" }, card));
  29. }
  30. #endregion
  31. #region Blocker
  32. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  33. #endregion
  34. #region Link +1
  35. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfLinkMaxStaticEffect(1, false, card, null));
  36. #endregion
  37. #endregion
  38. #region YourTurn
  39. if (timing == EffectTiming.WhenLinked)
  40. {
  41. ActivateClass activateClass = new ActivateClass();
  42. activateClass.SetUpICardEffect("Unsuspend, trash top sec", CanUseCondition, card);
  43. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  44. activateClass.SetHashString("BT21_101_WhenLinked");
  45. cardEffects.Add(activateClass);
  46. string EffectDiscription()
  47. => "[Your Turn] [Once Per Turn] When your Digimon get linked, by unsuspending this Digimon, trash your opponent's top security card.";
  48. bool CanUseCondition(Hashtable hashtable)
  49. => CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  50. && CardEffectCommons.IsOwnerTurn(card)
  51. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, cardSource => true)
  52. && card.PermanentOfThisCard().IsSuspended;
  53. bool PermanentCondition(Permanent permanent)
  54. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  55. bool CanActivateCondition(Hashtable hashtable)
  56. => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  57. IEnumerator ActivateCoroutine(Hashtable hashtable)
  58. {
  59. Permanent thisPermanent = card.PermanentOfThisCard();
  60. if (CardEffectCommons.CanUnsuspend(thisPermanent) && thisPermanent.IsSuspended)
  61. {
  62. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  63. new List<Permanent>() { card.PermanentOfThisCard() },
  64. activateClass).Unsuspend());
  65. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  66. player: card.Owner.Enemy,
  67. destroySecurityCount: 1,
  68. cardEffect: activateClass,
  69. fromTop: true).DestroySecurity());
  70. }
  71. }
  72. }
  73. #endregion
  74. #region WD/WA Shared
  75. bool SharedCanActivateCondition(Hashtable hashtable)
  76. {
  77. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  78. {
  79. return true;
  80. }
  81. return false;
  82. }
  83. bool CanSelectLinkCard(CardSource cardSource)
  84. {
  85. return cardSource.IsDigimon
  86. && cardSource.HasAppmonTraits
  87. && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  88. }
  89. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  90. {
  91. bool hasInHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectLinkCard);
  92. bool hasInSources = card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectLinkCard) > 0;
  93. bool selectedRoot = false;
  94. CardSource selectedCard = null;
  95. if (hasInHand || hasInSources)
  96. {
  97. if (hasInHand && hasInSources)
  98. {
  99. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  100. {
  101. new SelectionElement<bool>(message: $"From This Digimon", value: true, spriteIndex: 0),
  102. new SelectionElement<bool>(message: $"From Hand", value: false, spriteIndex: 1),
  103. };
  104. string selectPlayerMessage = "Choose where to get the digimon from";
  105. string notSelectPlayerMessage = "The opponent is choosing effects.";
  106. GManager.instance.userSelectionManager.SetBoolSelection(
  107. selectionElements: selectionElements, selectPlayer: card.Owner,
  108. selectPlayerMessage: selectPlayerMessage,
  109. notSelectPlayerMessage: notSelectPlayerMessage);
  110. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  111. .userSelectionManager.WaitForEndSelect());
  112. selectedRoot = GManager.instance.userSelectionManager.SelectedBoolValue;
  113. }
  114. else if (hasInSources)
  115. {
  116. selectedRoot = true;
  117. }
  118. if (selectedRoot)
  119. {
  120. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  121. selectCardEffect.SetUp(
  122. canTargetCondition: CanSelectLinkCard,
  123. canTargetCondition_ByPreSelecetedList: null,
  124. canEndSelectCondition: null,
  125. canNoSelect: () => true,
  126. selectCardCoroutine: SelectCardCoroutine,
  127. afterSelectCardCoroutine: null,
  128. message: "Select 1 card to link.",
  129. maxCount: 1,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. mode: SelectCardEffect.Mode.Custom,
  133. root: SelectCardEffect.Root.DigivolutionCards,
  134. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  135. canLookReverseCard: true,
  136. selectPlayer: card.Owner,
  137. cardEffect: activateClass);
  138. selectCardEffect.SetUpCustomMessage("Select 1 card to link", "The opponent is selecting 1 card to link");
  139. yield return StartCoroutine(selectCardEffect.Activate());
  140. }
  141. else
  142. {
  143. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  144. selectHandEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: CanSelectLinkCard,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: 1,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. isShowOpponent: true,
  153. selectCardCoroutine: SelectCardCoroutine,
  154. afterSelectCardCoroutine: null,
  155. mode: SelectHandEffect.Mode.Custom,
  156. cardEffect: activateClass);
  157. selectHandEffect.SetUpCustomMessage("Select 1 card to link", "The opponent is selecting 1 card to link");
  158. yield return StartCoroutine(selectHandEffect.Activate());
  159. }
  160. }
  161. IEnumerator SelectCardCoroutine(CardSource cardSource)
  162. {
  163. selectedCard = cardSource;
  164. yield return null;
  165. }
  166. if (selectedCard != null)
  167. {
  168. bool CanSelectDigimon(Permanent permanent)
  169. {
  170. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  171. return selectedCard.CanLinkToTargetPermanent(permanent, false);
  172. return false;
  173. }
  174. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimon))
  175. {
  176. Permanent selectedPermanent = null;
  177. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigimon));
  178. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  179. selectPermanentEffect.SetUp(
  180. selectPlayer: card.Owner,
  181. canTargetCondition: CanSelectDigimon,
  182. canTargetCondition_ByPreSelecetedList: null,
  183. canEndSelectCondition: null,
  184. maxCount: maxCount,
  185. canNoSelect: true,
  186. canEndNotMax: false,
  187. selectPermanentCoroutine: SelectPermanentCoroutine,
  188. afterSelectPermanentCoroutine: null,
  189. mode: SelectPermanentEffect.Mode.Custom,
  190. cardEffect: activateClass);
  191. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to add link", "The opponent is selecting 1 digimon to add link");
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  194. {
  195. selectedPermanent = permanent;
  196. yield return null;
  197. }
  198. if (selectedPermanent != null)
  199. {
  200. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(selectedCard, activateClass));
  201. }
  202. }
  203. }
  204. }
  205. #endregion
  206. #region When Digivolving
  207. if (timing == EffectTiming.OnEnterFieldAnyone)
  208. {
  209. ActivateClass activateClass = new ActivateClass();
  210. activateClass.SetUpICardEffect("Add new link to a digimon", CanUseCondition, card);
  211. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  212. cardEffects.Add(activateClass);
  213. string EffectDiscription()
  214. => "[When Digivolving] You may link 1 Digimon card with the [Appmon] trait from your hand or this Digimon's digivolution cards to 1 of your Digimon without paying the cost.";
  215. bool CanUseCondition(Hashtable hashtable)
  216. {
  217. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  218. {
  219. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  220. {
  221. return true;
  222. }
  223. }
  224. return false;
  225. }
  226. }
  227. #endregion
  228. #region When Attacking
  229. if (timing == EffectTiming.OnAllyAttack)
  230. {
  231. ActivateClass activateClass = new ActivateClass();
  232. activateClass.SetUpICardEffect("Add new link to a digimon", CanUseCondition, card);
  233. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashtable) => SharedActivateCoroutine(hashtable, activateClass), -1, true, EffectDiscription());
  234. cardEffects.Add(activateClass);
  235. string EffectDiscription()
  236. => "[When Attacking] You may link 1 Digimon card with the [Appmon] trait from your hand or this Digimon's digivolution cards to 1 of your Digimon without paying the cost.";
  237. bool CanUseCondition(Hashtable hashtable)
  238. {
  239. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  240. {
  241. if (CardEffectCommons.CanTriggerOnAttack(hashtable, card))
  242. {
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248. }
  249. #endregion
  250. return cardEffects;
  251. }
  252. }
  253. }