BT9_108.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. public class BT9_108 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] Delete 1 of your opponent's unsuspended Digimon. If you do, you may play 1 purple level 3 Digimon card from your trash without paying its memory cost. Any [On Play] effects on Digimon played with this effect don't activate.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (!permanent.IsSuspended)
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource.IsDigimon)
  37. {
  38. if (cardSource.HasCardColor(CardColor.Purple))
  39. {
  40. if (cardSource.Level == 3)
  41. {
  42. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  43. {
  44. if (cardSource.HasLevel)
  45. {
  46. return true;
  47. }
  48. }
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. bool deleted = false;
  61. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  62. {
  63. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  64. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  65. selectPermanentEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: CanSelectPermanentCondition,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. maxCount: maxCount,
  71. canNoSelect: true,
  72. canEndNotMax: false,
  73. selectPermanentCoroutine: SelectPermanentCoroutine,
  74. afterSelectPermanentCoroutine: null,
  75. mode: SelectPermanentEffect.Mode.Custom,
  76. cardEffect: activateClass);
  77. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  82. targetPermanents: new List<Permanent>() { permanent },
  83. activateClass: activateClass,
  84. successProcess: permanents => SuccessProcess(),
  85. failureProcess: null));
  86. IEnumerator SuccessProcess()
  87. {
  88. deleted = true;
  89. yield return null;
  90. }
  91. }
  92. }
  93. if (deleted)
  94. {
  95. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  96. {
  97. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  98. List<CardSource> selectedCards = new List<CardSource>();
  99. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  100. selectCardEffect.SetUp(
  101. canTargetCondition: CanSelectCardCondition,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. canNoSelect: () => true,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. message: "Select 1 card to play.",
  108. maxCount: maxCount,
  109. canEndNotMax: false,
  110. isShowOpponent: true,
  111. mode: SelectCardEffect.Mode.Custom,
  112. root: SelectCardEffect.Root.Trash,
  113. customRootCardList: null,
  114. canLookReverseCard: true,
  115. selectPlayer: card.Owner,
  116. cardEffect: activateClass);
  117. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  118. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  119. yield return StartCoroutine(selectCardEffect.Activate());
  120. IEnumerator SelectCardCoroutine(CardSource cardSource)
  121. {
  122. selectedCards.Add(cardSource);
  123. yield return null;
  124. }
  125. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  126. cardSources: selectedCards,
  127. activateClass: activateClass,
  128. payCost: false,
  129. isTapped: false,
  130. root: SelectCardEffect.Root.Trash,
  131. activateETB: false));
  132. }
  133. }
  134. }
  135. }
  136. if (timing == EffectTiming.SecuritySkill)
  137. {
  138. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Delete 1 unsuspended Digimon to play 1 Digimon from trash");
  139. }
  140. return cardEffects;
  141. }
  142. }