BT25_044.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Junomon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_044 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.HasTSTraits
  19. || permanent.TopCard.EqualsTraits("Angel")
  20. || permanent.TopCard.EqualsTraits("Archangel");
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 5));
  23. }
  24. #endregion
  25. #region Reduce Play Cost
  26. if (timing == EffectTiming.None)
  27. {
  28. ChangeCostClass changeCostClass = new ChangeCostClass();
  29. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
  30. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  31. changeCostClass.SetNotShowUI(true);
  32. cardEffects.Add(changeCostClass);
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return (card.Owner.SecurityCards.Count + card.Owner.Enemy.SecurityCards.Count) <= 6;
  36. }
  37. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  38. List<Permanent> targetPermanents)
  39. {
  40. if (CardSourceCondition(cardSource) &&
  41. RootCondition(root) &&
  42. PermanentsCondition(targetPermanents))
  43. {
  44. cost -= 5;
  45. }
  46. return cost;
  47. }
  48. bool PermanentsCondition(List<Permanent> targetPermanents)
  49. {
  50. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  51. }
  52. bool CardSourceCondition(CardSource cardSource)
  53. {
  54. return cardSource == card;
  55. }
  56. bool RootCondition(SelectCardEffect.Root root)
  57. {
  58. return true;
  59. }
  60. bool isUpDown()
  61. {
  62. return true;
  63. }
  64. }
  65. #endregion
  66. #region Shared OP / WD
  67. string SharedEffectName = "Place another digimon as top security to trash both players' top security";
  68. string SharedEffectDescription(string tag)
  69. => $"[{tag}] By placing 1 other Digimon as the top security card, trash both players' top security cards.";
  70. bool OtherDigimon(Permanent permanent)
  71. {
  72. return permanent != card.PermanentOfThisCard()
  73. && CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  74. }
  75. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  76. {
  77. return CardEffectCommons.HasMatchConditionPermanent(OtherDigimon);
  78. }
  79. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  80. {
  81. Permanent selectedPermanent = null;
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: OtherDigimon,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: 1,
  89. canNoSelect: true,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in security", "The opponent is selecting 1 Digimon place in security.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. selectedPermanent = permanent;
  100. yield return null;
  101. }
  102. if (selectedPermanent != null)
  103. {
  104. yield return ContinuousController.instance.StartCoroutine(
  105. CardEffectCommons.PlacePermanentInSecurityAndProcessAccordingToResult(selectedPermanent, activateClass, toTop: true, SuccessProcess));
  106. IEnumerator SuccessProcess(CardSource cardSource)
  107. {
  108. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  109. player: card.Owner.Enemy,
  110. destroySecurityCount: 1,
  111. cardEffect: activateClass,
  112. fromTop: true).DestroySecurity());
  113. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  114. player: card.Owner,
  115. destroySecurityCount: 1,
  116. cardEffect: activateClass,
  117. fromTop: true).DestroySecurity());
  118. }
  119. }
  120. }
  121. CardEffectFactory.ActivateClassesForSharedEffects
  122. (ref cardEffects, timing, card,
  123. SharedEffectName,
  124. SharedActivateCoroutine,
  125. SharedEffectDescription,
  126. additionalActivateCondition: AdditionalActivateCondition,
  127. optional: false,
  128. isSkippable: true,
  129. onPlay: true,
  130. whenDigivolving: true);
  131. #endregion
  132. #region All Turns
  133. if (timing == EffectTiming.OnLoseSecurity)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Play an 8 cost or less [Angel]/[Archangel]/[Iliad] card for free", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  138. activateClass.SetHashString("BT25_044_AT");
  139. activateClass.SetIsSkippable(true);
  140. cardEffects.Add(activateClass);
  141. string EffectDiscription()
  142. {
  143. return "[All Turns] [Once Per Turn] When your security stack is removed from, you may play 1 play cost 8 or lower [Angel], [Archangel] or [Iliad] trait card from your hand or trash without paying the cost.";
  144. }
  145. bool CanUseCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  148. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, (player) => player == card.Owner);
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  153. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCardCondition)
  154. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTrashCardCondition));
  155. }
  156. bool CanSelectCardCondition(CardSource cardSource, SelectCardEffect.Root root)
  157. {
  158. return cardSource.HasPlayCost
  159. && cardSource.GetCostItself <= 8
  160. && (cardSource.EqualsTraits("Angel") || cardSource.EqualsTraits("Archangel") || cardSource.HasIliadTraits)
  161. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, root);
  162. }
  163. bool CanSelectHandCardCondition(CardSource cardSource) => CanSelectCardCondition(cardSource, SelectCardEffect.Root.Hand);
  164. bool CanSelectTrashCardCondition(CardSource cardSource) => CanSelectCardCondition(cardSource, SelectCardEffect.Root.Trash);
  165. IEnumerator ActivateCoroutine(Hashtable hashtable)
  166. {
  167. bool executed = false;
  168. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCardCondition);
  169. bool validTrashCard = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTrashCardCondition);
  170. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  171. if (validHandCard)
  172. {
  173. selectionElements.Add(new(message: "from Hand", value: 1, spriteIndex: 0));
  174. }
  175. if (validTrashCard)
  176. {
  177. selectionElements.Add(new(message: "from Trash", value: 2, spriteIndex: 0));
  178. }
  179. selectionElements.Add(new(message: "Do not place", value: 3, spriteIndex: 1));
  180. GManager.instance.userSelectionManager.SetIntSelection(
  181. selectionElements: selectionElements,
  182. selectPlayer: card.Owner,
  183. selectPlayerMessage: "From which area will you play a card?",
  184. notSelectPlayerMessage: "The opponent is choosing from which area to play a card.");
  185. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  186. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  187. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  188. if (doPlay)
  189. {
  190. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  191. {
  192. if (cardSources.Count > 0)
  193. executed = true;
  194. yield return null;
  195. }
  196. if (fromHand)
  197. {
  198. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  199. selectHandEffect.SetUp(
  200. selectPlayer: card.Owner,
  201. canTargetCondition: CanSelectHandCardCondition,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canEndSelectCondition: null,
  204. maxCount: 1,
  205. canNoSelect: true,
  206. canEndNotMax: false,
  207. isShowOpponent: true,
  208. selectCardCoroutine: null,
  209. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  210. mode: SelectHandEffect.Mode.PlayForFree,
  211. cardEffect: activateClass);
  212. yield return StartCoroutine(selectHandEffect.Activate());
  213. }
  214. else
  215. {
  216. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  217. selectCardEffect.SetUp(
  218. canTargetCondition: CanSelectTrashCardCondition,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. canNoSelect: () => true,
  222. selectCardCoroutine: null,
  223. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  224. message: "Select 1 card to play.",
  225. maxCount: 1,
  226. canEndNotMax: false,
  227. isShowOpponent: true,
  228. mode: SelectCardEffect.Mode.PlayForFree,
  229. root: SelectCardEffect.Root.Trash,
  230. customRootCardList: null,
  231. canLookReverseCard: true,
  232. selectPlayer: card.Owner,
  233. cardEffect: activateClass);
  234. yield return StartCoroutine(selectCardEffect.Activate());
  235. }
  236. }
  237. if(!executed) activateClass.RemoveUse();
  238. }
  239. }
  240. #endregion
  241. return cardEffects;
  242. }
  243. }
  244. }