BT3_100.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. using System.Net.Security;
  9. public class BT3_100 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. if (timing == EffectTiming.OptionSkill)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[Main] Trash up to 2 digivolution cards from the bottom of all of your opponent's Digimon. Then, if you have a green Digimon in play, suspend 1 of your opponent's Digimon with no digivolution cards.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  27. {
  28. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  29. {
  30. if(permanent.DigivolutionCards.Count == 0)
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  39. }
  40. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  41. {
  42. List<Permanent> selectedPermanents = new List<Permanent>();
  43. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaDigimons())
  44. {
  45. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  46. {
  47. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  48. {
  49. selectedPermanents.Add(permanent);
  50. }
  51. }
  52. }
  53. if (selectedPermanents.Count >= 1)
  54. {
  55. int trashCount = 0;
  56. SelectCountEffect selectCountEffect = GManager.instance.GetComponent<SelectCountEffect>();
  57. selectCountEffect.SetUp(
  58. SelectPlayer: card.Owner,
  59. targetPermanent: null,
  60. MaxCount: 2,
  61. CanNoSelect: false,
  62. Message: $"How many digivolution cards will you trash?",
  63. Message_Enemy: $"The opponent is choosing how many digivolution cards to trash.",
  64. SelectCountCoroutine: SelectCountCoroutine);
  65. yield return ContinuousController.instance.StartCoroutine(selectCountEffect.Activate());
  66. IEnumerator SelectCountCoroutine(int count)
  67. {
  68. trashCount = count;
  69. yield return null;
  70. }
  71. foreach (Permanent selectedPermanent in selectedPermanents)
  72. {
  73. int maxCount = Math.Min(trashCount, selectedPermanent.DigivolutionCards.Count);
  74. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: maxCount, isFromTop: false, activateClass: activateClass));
  75. }
  76. }
  77. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.CardColors.Contains(CardColor.Green)))
  78. {
  79. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  80. {
  81. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: null,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Tap,
  94. cardEffect: activateClass);
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. }
  97. }
  98. }
  99. }
  100. if (timing == EffectTiming.SecuritySkill)
  101. {
  102. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Trash digivolution cards and suspend 1 Digimon");
  103. }
  104. return cardEffects;
  105. }
  106. }