BT9_079.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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_079 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 level 3 Digimon from trash", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] You may play 1 purple level 3 Digimon card from your trash without paying its memory cost.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.IsDigimon)
  26. {
  27. if (cardSource.HasCardColor(CardColor.Purple))
  28. {
  29. if (cardSource.Level == 3)
  30. {
  31. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  32. {
  33. if (cardSource.HasLevel)
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  61. {
  62. List<CardSource> selectedCards = new List<CardSource>();
  63. int maxCount = 1;
  64. if (card.Owner.TrashCards.Count(CanSelectCardCondition) <= maxCount)
  65. {
  66. maxCount = card.Owner.TrashCards.Count(CanSelectCardCondition);
  67. }
  68. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  69. selectCardEffect.SetUp(
  70. canTargetCondition: CanSelectCardCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. canNoSelect: () => true,
  74. selectCardCoroutine: SelectCardCoroutine,
  75. afterSelectCardCoroutine: null,
  76. message: "Select 1 card to play.",
  77. maxCount: maxCount,
  78. canEndNotMax: false,
  79. isShowOpponent: true,
  80. mode: SelectCardEffect.Mode.Custom,
  81. root: SelectCardEffect.Root.Trash,
  82. customRootCardList: null,
  83. canLookReverseCard: true,
  84. selectPlayer: card.Owner,
  85. cardEffect: activateClass);
  86. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  87. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  88. yield return StartCoroutine(selectCardEffect.Activate());
  89. IEnumerator SelectCardCoroutine(CardSource cardSource)
  90. {
  91. selectedCards.Add(cardSource);
  92. yield return null;
  93. }
  94. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  95. cardSources: selectedCards,
  96. activateClass: activateClass,
  97. payCost: false,
  98. isTapped: false,
  99. root: SelectCardEffect.Root.Trash,
  100. activateETB: true));
  101. }
  102. }
  103. }
  104. if (timing == EffectTiming.OnEndAttack)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("Your 1 Digimon digivolves to [Undead] or [Dark Animal] Digimon", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  109. activateClass.SetHashString("Digivolve_BT9_079");
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[End of Attack][Once Per Turn] You may digivolve 1 of your other Digimon into a Digimon card with [Undead] or [Dark Animal] in its traits from your trash without paying its memory cost.";
  114. }
  115. bool CanSelectPermanentCondition(Permanent permanent)
  116. {
  117. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  118. {
  119. if (permanent != card.PermanentOfThisCard())
  120. {
  121. foreach (CardSource cardSource in permanent.TopCard.Owner.TrashCards)
  122. {
  123. if (CanSelectCardCondition(cardSource))
  124. {
  125. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash))
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. }
  132. }
  133. return false;
  134. }
  135. bool CanSelectCardCondition(CardSource cardSource)
  136. {
  137. if (cardSource.IsDigimon)
  138. {
  139. if (cardSource.CardTraits.Contains("Undead"))
  140. {
  141. return true;
  142. }
  143. if (cardSource.CardTraits.Contains("Dark Animal"))
  144. {
  145. return true;
  146. }
  147. if (cardSource.CardTraits.Contains("DarkAnimal"))
  148. {
  149. return true;
  150. }
  151. }
  152. return false;
  153. }
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  157. }
  158. bool CanActivateCondition(Hashtable hashtable)
  159. {
  160. if (CardEffectCommons.IsExistOnBattleArea(card))
  161. {
  162. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  163. {
  164. return true;
  165. }
  166. }
  167. return false;
  168. }
  169. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  170. {
  171. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  172. {
  173. Permanent selectedPermanent = null;
  174. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. selectPermanentEffect.SetUp(
  177. selectPlayer: card.Owner,
  178. canTargetCondition: CanSelectPermanentCondition,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. maxCount: maxCount,
  182. canNoSelect: false,
  183. canEndNotMax: false,
  184. selectPermanentCoroutine: SelectPermanentCoroutine,
  185. afterSelectPermanentCoroutine: null,
  186. mode: SelectPermanentEffect.Mode.Custom,
  187. cardEffect: activateClass);
  188. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  189. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  190. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  191. {
  192. selectedPermanent = permanent;
  193. yield return null;
  194. }
  195. if (selectedPermanent != null)
  196. {
  197. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  198. targetPermanent: selectedPermanent,
  199. cardCondition: CanSelectCardCondition,
  200. payCost: false,
  201. reduceCostTuple: null,
  202. fixedCostTuple: null,
  203. ignoreDigivolutionRequirementFixedCost: -1,
  204. isHand: false,
  205. activateClass: activateClass,
  206. successProcess: null));
  207. }
  208. }
  209. }
  210. }
  211. return cardEffects;
  212. }
  213. }