BT9_110.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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_110 : 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.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (card.Owner.GetBattleAreaDigimons().Count((permanet) => permanet.TopCard.ContainsCardName("Dex") || permanet.TopCard.ContainsCardName("DeathX")) >= 1)
  22. {
  23. return true;
  24. }
  25. return false;
  26. }
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. }
  36. if (timing == EffectTiming.OptionSkill)
  37. {
  38. ActivateClass activateClass = new ActivateClass();
  39. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  40. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[Main] Delete 1 Digimon without [X Antibody] in its traits. If there are 3 or more Digimon in play, delete all Digimon without [X Antibody] in their traits instead.";
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. if (permanent != null)
  49. {
  50. if (permanent.TopCard != null)
  51. {
  52. if (permanent.IsDigimon)
  53. {
  54. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  55. {
  56. if (!permanent.TopCard.HasXAntibodyTraits)
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanUseCondition(Hashtable hashtable)
  67. {
  68. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  71. {
  72. if (card.Owner.GetBattleAreaDigimons().Count + card.Owner.Enemy.GetBattleAreaDigimons().Count >= 3)
  73. {
  74. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  75. {
  76. List<Permanent> destroyedPermanetns = new List<Permanent>();
  77. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  78. {
  79. foreach (Permanent permanent in player.GetBattleAreaDigimons())
  80. {
  81. if (CanSelectPermanentCondition(permanent))
  82. {
  83. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  84. {
  85. destroyedPermanetns.Add(permanent);
  86. }
  87. }
  88. }
  89. }
  90. if (destroyedPermanetns.Count >= 1)
  91. {
  92. Hashtable hashtable = new Hashtable();
  93. hashtable.Add("CardEffect", activateClass);
  94. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyedPermanetns, hashtable).Destroy());
  95. }
  96. }
  97. }
  98. else
  99. {
  100. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  101. {
  102. int maxCount = 1;
  103. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  104. selectPermanentEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: CanSelectPermanentCondition,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: maxCount,
  110. canNoSelect: false,
  111. canEndNotMax: false,
  112. selectPermanentCoroutine: null,
  113. afterSelectPermanentCoroutine: null,
  114. mode: SelectPermanentEffect.Mode.Destroy,
  115. cardEffect: activateClass);
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. }
  118. }
  119. }
  120. }
  121. if (timing == EffectTiming.SecuritySkill)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect($"Delete 1 Digimon without [X Antibody] in its traits.", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  126. activateClass.SetIsSecurityEffect(true);
  127. cardEffects.Add(activateClass);
  128. string EffectDiscription()
  129. {
  130. return "[Security] Delete 1 of your opponent's Digimon without [X Antibody] in its traits.";
  131. }
  132. bool CanSelectPermanentCondition(Permanent permanent)
  133. {
  134. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  135. {
  136. if (!permanent.TopCard.HasXAntibodyTraits)
  137. {
  138. return true;
  139. }
  140. }
  141. return false;
  142. }
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  148. {
  149. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  150. {
  151. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  152. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  153. selectPermanentEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: CanSelectPermanentCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: maxCount,
  159. canNoSelect: false,
  160. canEndNotMax: false,
  161. selectPermanentCoroutine: null,
  162. afterSelectPermanentCoroutine: null,
  163. mode: SelectPermanentEffect.Mode.Destroy,
  164. cardEffect: activateClass);
  165. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  166. }
  167. }
  168. }
  169. return cardEffects;
  170. }
  171. }