BT11_088.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Bagramon
  5. namespace DCGO.CardEffects.BT11
  6. {
  7. public class BT11_088 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Shared OP/WD
  13. string SharedEffectName = "Depending on enemy Digimon count, look at opponent's hand and trash 1 or place 1 enemy Digimon under 1 other Digimon";
  14. CardEffectFactory.ActivateClassesForSharedEffects
  15. (ref cardEffects, timing, card,
  16. SharedEffectName,
  17. SharedActivateCoroutine,
  18. SharedEffectDescription,
  19. optional: false,
  20. onPlay: true,
  21. whenDigivolving: true);
  22. string SharedEffectDescription(string tag) => $"[{tag}] If your opponent has 1 or fewer Digimon in play, look at your opponent's hand and trash 1 card in it. If your opponent has 2 or more Digimon in play, place 1 of your opponent's Digimon under 1 of your opponent's other Digimon as its bottom digivolution card.";
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  28. {
  29. if (card.Owner.Enemy.GetBattleAreaDigimons().Count <= 1
  30. && card.Owner.Enemy.HandCards.Count >= 1)
  31. {
  32. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  33. selectCardEffect.SetUp(
  34. canTargetCondition: (cardSource) => true,
  35. canTargetCondition_ByPreSelecetedList: null,
  36. canEndSelectCondition: null,
  37. canNoSelect: () => false,
  38. selectCardCoroutine: null,
  39. afterSelectCardCoroutine: null,
  40. message: "Select 1 card to discard from opponent's hand.",
  41. maxCount: 1,
  42. canEndNotMax: false,
  43. isShowOpponent: true,
  44. mode: SelectCardEffect.Mode.Discard,
  45. root: SelectCardEffect.Root.Custom,
  46. customRootCardList: card.Owner.Enemy.HandCards,
  47. canLookReverseCard: true,
  48. selectPlayer: card.Owner,
  49. cardEffect: null);
  50. selectCardEffect.SetUpCustomMessage("Select 1 card to discard from opponent's hand.", "The opponent is selecting 1 card to discard from your hand.");
  51. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  52. }
  53. if (card.Owner.Enemy.GetBattleAreaDigimons().Count >= 2)
  54. {
  55. Permanent selectedPermanent = null;
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: 1,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: SelectPermanentCoroutine,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that place under other Digimon's digivolution cards.", "The opponent is selecting 1 Digimon that place under other Digimon's digivolution cards.");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. selectedPermanent = permanent;
  74. yield return null;
  75. }
  76. if (selectedPermanent != null)
  77. {
  78. bool CanSelectPermanentCondition1(Permanent permanent)
  79. {
  80. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  81. && permanent != selectedPermanent
  82. && !permanent.IsToken;
  83. }
  84. selectPermanentEffect.SetUp(
  85. selectPlayer: card.Owner,
  86. canTargetCondition: CanSelectPermanentCondition1,
  87. canTargetCondition_ByPreSelecetedList: null,
  88. canEndSelectCondition: null,
  89. maxCount: 1,
  90. canNoSelect: false,
  91. canEndNotMax: false,
  92. selectPermanentCoroutine: SelectPermanentCoroutine1,
  93. afterSelectPermanentCoroutine: null,
  94. mode: SelectPermanentEffect.Mode.Custom,
  95. cardEffect: activateClass);
  96. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get digivolution cards.", "The opponent is selecting 1 Digimon that will get digivolution cards.");
  97. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  98. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { selectedPermanent, permanent } }, false, activateClass).PlacePermanentToDigivolutionCards());
  101. }
  102. }
  103. }
  104. }
  105. #endregion
  106. #region Shared All Turns
  107. string SharedEffectName2() => "Trash 1 of this Digimon's sources to trash enemy top sec";
  108. string SharedEffectDescription2() => "[All Turns][Once Per Turn] When an opponent's Digimon digivolves or an effect adds cards to the digivolution cards of an opponent's Digimon, by trashing 1 card in this Digimon's digivolution cards, trash the top card of your opponent's security stack.";
  109. string SharedHashString2 = "BT11_088_AT";
  110. bool SharedCanActivateCondition2(Hashtable hashtable, ActivateClass activateClass)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  113. && card.PermanentOfThisCard().DigivolutionCards.Count(cardSource => CanSelectCardCondition2(cardSource, activateClass)) >= 1;
  114. }
  115. bool CanSelectCardCondition2(CardSource cardSource, ActivateClass activateClass)
  116. {
  117. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass)
  118. || cardSource.IsFaceDown;
  119. }
  120. IEnumerator SharedActivateCoroutine2(Hashtable hashtable, ActivateClass activateClass)
  121. {
  122. List<CardSource> selectedCards = new List<CardSource>();
  123. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  124. selectCardEffect.SetUp(
  125. canTargetCondition: (cardSource) => CanSelectCardCondition2(cardSource, activateClass),
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. canNoSelect: () => false,
  129. selectCardCoroutine: SelectCardCoroutine,
  130. afterSelectCardCoroutine: null,
  131. message: "Select 1 digivolution card to discard.",
  132. maxCount: 1,
  133. canEndNotMax: false,
  134. isShowOpponent: true,
  135. mode: SelectCardEffect.Mode.Custom,
  136. root: SelectCardEffect.Root.DigivolutionCards,
  137. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  138. canLookReverseCard: true,
  139. selectPlayer: card.Owner,
  140. cardEffect: null);
  141. selectCardEffect.SetUseFaceDown();
  142. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to discard.", "The opponent is selecting 1 digivolution card to discard.");
  143. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  144. IEnumerator SelectCardCoroutine(CardSource cardSource)
  145. {
  146. selectedCards.Add(cardSource);
  147. yield return null;
  148. }
  149. if (selectedCards.Count >= 1)
  150. {
  151. yield return ContinuousController.instance.StartCoroutine(new ITrashDigivolutionCards(card.PermanentOfThisCard(), selectedCards, activateClass).TrashDigivolutionCards());
  152. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  153. player: card.Owner.Enemy,
  154. destroySecurityCount: 1,
  155. cardEffect: activateClass,
  156. fromTop: true).DestroySecurity());
  157. }
  158. }
  159. #endregion
  160. #region All Turns - Digivolve
  161. if (timing == EffectTiming.OnEnterFieldAnyone)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect(SharedEffectName2(), CanUseCondition, card);
  165. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition2(hash, activateClass), hash => SharedActivateCoroutine2(hash, activateClass), 1, true, SharedEffectDescription2());
  166. activateClass.SetHashString(SharedHashString2);
  167. cardEffects.Add(activateClass);
  168. bool PermanentCondition(Permanent permanent)
  169. {
  170. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  171. }
  172. bool CanUseCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  175. && CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition);
  176. }
  177. }
  178. #endregion
  179. #region All Turns - Add Digivolution Card
  180. if (timing == EffectTiming.OnAddDigivolutionCards)
  181. {
  182. ActivateClass activateClass = new ActivateClass();
  183. activateClass.SetUpICardEffect(SharedEffectName2(), CanUseCondition, card);
  184. activateClass.SetUpActivateClass(hash => SharedCanActivateCondition2(hash, activateClass), hash => SharedActivateCoroutine2(hash, activateClass), 1, true, SharedEffectDescription2());
  185. activateClass.SetHashString(SharedHashString2);
  186. cardEffects.Add(activateClass);
  187. bool CanUseCondition(Hashtable hashtable)
  188. {
  189. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  190. && CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  191. hashtable: hashtable,
  192. permanentCondition: permanent => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card),
  193. cardEffectCondition: cardEffect => cardEffect != null,
  194. cardCondition: null);
  195. }
  196. }
  197. #endregion
  198. return cardEffects;
  199. }
  200. }
  201. }