BT9_106.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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_106 : 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.HasXAntibodyTraits) >= 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] Digivolve 1 of your Digimon into a Digimon card with [Dex] or [DeathX] in its name from your trash for its memory cost.";
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. List<Permanent> candidatePermanents = new List<Permanent>();
  53. foreach (CardSource cardSource in card.Owner.TrashCards)
  54. {
  55. if (cardSource.ContainsCardName("Dex") || cardSource.ContainsCardName("DeathX"))
  56. {
  57. if (cardSource.IsDigimon)
  58. {
  59. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  60. {
  61. if (permanent.IsDigimon)
  62. {
  63. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass, root: SelectCardEffect.Root.Trash))
  64. {
  65. candidatePermanents.Add(permanent);
  66. }
  67. }
  68. }
  69. }
  70. }
  71. }
  72. bool CanSelectPermanentCondition(Permanent permanent)
  73. {
  74. if (permanent != null)
  75. {
  76. if (candidatePermanents.Contains(permanent))
  77. {
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  84. {
  85. Permanent selectedPermanent = null;
  86. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  87. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  88. selectPermanentEffect.SetUp(
  89. selectPlayer: card.Owner,
  90. canTargetCondition: CanSelectPermanentCondition,
  91. canTargetCondition_ByPreSelecetedList: null,
  92. canEndSelectCondition: null,
  93. maxCount: maxCount,
  94. canNoSelect: false,
  95. canEndNotMax: false,
  96. selectPermanentCoroutine: SelectPermanentCoroutine,
  97. afterSelectPermanentCoroutine: null,
  98. mode: SelectPermanentEffect.Mode.Custom,
  99. cardEffect: activateClass);
  100. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  101. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  102. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  103. {
  104. selectedPermanent = permanent;
  105. yield return null;
  106. }
  107. if (selectedPermanent != null)
  108. {
  109. bool CanSelectCardCondition(CardSource cardSource)
  110. {
  111. if (cardSource.ContainsCardName("Dex") || cardSource.ContainsCardName("DeathX"))
  112. {
  113. if (cardSource.IsDigimon)
  114. {
  115. if (cardSource.CanPlayCardTargetFrame(selectedPermanent.PermanentFrame, true, activateClass, root: SelectCardEffect.Root.Trash))
  116. {
  117. return true;
  118. }
  119. }
  120. }
  121. return false;
  122. }
  123. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  124. {
  125. List<CardSource> selectedCards = new List<CardSource>();
  126. maxCount = 1;
  127. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  128. selectCardEffect.SetUp(
  129. canTargetCondition: CanSelectCardCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. canNoSelect: () => false,
  133. selectCardCoroutine: SelectCardCoroutine,
  134. afterSelectCardCoroutine: null,
  135. message: "Select 1 card to digivolve.",
  136. maxCount: maxCount,
  137. canEndNotMax: false,
  138. isShowOpponent: true,
  139. mode: SelectCardEffect.Mode.Custom,
  140. root: SelectCardEffect.Root.Trash,
  141. customRootCardList: null,
  142. canLookReverseCard: true,
  143. selectPlayer: card.Owner,
  144. cardEffect: activateClass);
  145. selectCardEffect.SetUpCustomMessage("Select 1 card to digivolve.", "The opponent is selecting 1 card to digivolve.");
  146. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  147. yield return StartCoroutine(selectCardEffect.Activate());
  148. IEnumerator SelectCardCoroutine(CardSource cardSource)
  149. {
  150. selectedCards.Add(cardSource);
  151. yield return null;
  152. }
  153. if (selectedCards.Count >= 1)
  154. {
  155. CardSource selectedCard = selectedCards[0];
  156. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  157. cardSources: new List<CardSource>() { selectedCard },
  158. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  159. payCost: true,
  160. targetPermanent: selectedPermanent,
  161. isTapped: false,
  162. root: SelectCardEffect.Root.Trash,
  163. activateETB: true).PlayCard());
  164. }
  165. }
  166. }
  167. }
  168. }
  169. }
  170. if (timing == EffectTiming.SecuritySkill)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  174. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  175. activateClass.SetIsSecurityEffect(true);
  176. cardEffects.Add(activateClass);
  177. string EffectDiscription()
  178. {
  179. return "[Security] Add this card to its owner's hand.";
  180. }
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  184. }
  185. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  186. {
  187. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  188. }
  189. }
  190. return cardEffects;
  191. }
  192. }