BT25_044.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. bool Condition()
  29. {
  30. return (card.Owner.SecurityCards.Count + card.Owner.Enemy.SecurityCards.Count) <= 6;
  31. }
  32. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  33. }
  34. #endregion
  35. #region Shared OP / WD
  36. string SharedEffectName = "Place another digimon as top security to trash both players' top security";
  37. string SharedEffectDescription(string tag)
  38. => $"[{tag}] By placing 1 other Digimon as the top security card, trash both players' top security cards.";
  39. bool OtherDigimon(Permanent permanent)
  40. {
  41. return permanent != card.PermanentOfThisCard()
  42. && CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  43. }
  44. bool AdditionalActivateCondition(Hashtable hashtable, ActivateClass activateClass)
  45. {
  46. return CardEffectCommons.HasMatchConditionPermanent(OtherDigimon);
  47. }
  48. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  49. {
  50. Permanent selectedPermanent = null;
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: OtherDigimon,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: true,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: SelectPermanentCoroutine,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Custom,
  63. cardEffect: activateClass);
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in security", "The opponent is selecting 1 Digimon place in security.");
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  67. {
  68. selectedPermanent = permanent;
  69. yield return null;
  70. }
  71. if (selectedPermanent != null)
  72. {
  73. yield return ContinuousController.instance.StartCoroutine(
  74. CardEffectCommons.PlacePermanentInSecurityAndProcessAccordingToResult(selectedPermanent, activateClass, toTop: true, SuccessProcess));
  75. IEnumerator SuccessProcess(CardSource cardSource)
  76. {
  77. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  78. player: card.Owner.Enemy,
  79. destroySecurityCount: 1,
  80. cardEffect: activateClass,
  81. fromTop: true).DestroySecurity());
  82. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  83. player: card.Owner,
  84. destroySecurityCount: 1,
  85. cardEffect: activateClass,
  86. fromTop: true).DestroySecurity());
  87. }
  88. }
  89. }
  90. CardEffectFactory.ActivateClassesForSharedEffects
  91. (ref cardEffects, timing, card,
  92. SharedEffectName,
  93. SharedActivateCoroutine,
  94. SharedEffectDescription,
  95. additionalActivateCondition: AdditionalActivateCondition,
  96. optional: false,
  97. isSkippable: true,
  98. onPlay: true,
  99. whenDigivolving: true);
  100. #endregion
  101. #region All Turns
  102. if (timing == EffectTiming.OnLoseSecurity)
  103. {
  104. ActivateClass activateClass = new ActivateClass();
  105. activateClass.SetUpICardEffect("Play an 8 cost or less [Angel]/[Archangel]/[Iliad] card for free", CanUseCondition, card);
  106. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  107. activateClass.SetHashString("BT25_044_AT");
  108. activateClass.SetIsSkippable(true);
  109. cardEffects.Add(activateClass);
  110. string EffectDiscription()
  111. {
  112. 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.";
  113. }
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  117. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, (player) => player == card.Owner);
  118. }
  119. bool CanActivateCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  122. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCardCondition)
  123. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTrashCardCondition));
  124. }
  125. bool CanSelectCardCondition(CardSource cardSource, SelectCardEffect.Root root)
  126. {
  127. return cardSource.HasPlayCost
  128. && cardSource.GetCostItself <= 8
  129. && (cardSource.EqualsTraits("Angel") || cardSource.EqualsTraits("Archangel") || cardSource.HasIliadTraits)
  130. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, root);
  131. }
  132. bool CanSelectHandCardCondition(CardSource cardSource) => CanSelectCardCondition(cardSource, SelectCardEffect.Root.Hand);
  133. bool CanSelectTrashCardCondition(CardSource cardSource) => CanSelectCardCondition(cardSource, SelectCardEffect.Root.Trash);
  134. IEnumerator ActivateCoroutine(Hashtable hashtable)
  135. {
  136. bool executed = false;
  137. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectHandCardCondition);
  138. bool validTrashCard = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectTrashCardCondition);
  139. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  140. if (validHandCard)
  141. {
  142. selectionElements.Add(new(message: "from Hand", value: 1, spriteIndex: 0));
  143. }
  144. if (validTrashCard)
  145. {
  146. selectionElements.Add(new(message: "from Trash", value: 2, spriteIndex: 0));
  147. }
  148. selectionElements.Add(new(message: "Do not place", value: 3, spriteIndex: 1));
  149. GManager.instance.userSelectionManager.SetIntSelection(
  150. selectionElements: selectionElements,
  151. selectPlayer: card.Owner,
  152. selectPlayerMessage: "From which area will you play a card?",
  153. notSelectPlayerMessage: "The opponent is choosing from which area to play a card.");
  154. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  155. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  156. SelectCardEffect.Root root = GManager.instance.userSelectionManager.SelectedIntValue == 1 ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  157. if (doPlay)
  158. {
  159. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  160. {
  161. if (cardSources.Count > 0)
  162. executed = true;
  163. yield return null;
  164. }
  165. #region Hand/Trash Card Selection & Play
  166. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  167. canTargetCondition: CanSelectHandCardCondition,
  168. root,
  169. activateClass,
  170. payCost: false,
  171. afterSelectCardCoroutine: AfterSelectCardCoroutine
  172. ));
  173. #endregion
  174. }
  175. if(!executed) activateClass.RemoveUse();
  176. }
  177. }
  178. #endregion
  179. return cardEffects;
  180. }
  181. }
  182. }