ST16_13.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 ST16_13 : 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("Draw 1 and trash 1 card from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] <Draw 1>. (Draw 1 card from your deck.) Then, trash 1 card in your hand.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  26. }
  27. bool CanActivateCondition(Hashtable hashtable)
  28. {
  29. if (CardEffectCommons.IsExistOnBattleArea(card))
  30. {
  31. if (card.Owner.LibraryCards.Count >= 1)
  32. {
  33. return true;
  34. }
  35. if (card.Owner.HandCards.Count >= 1)
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  45. if (card.Owner.HandCards.Count >= 1)
  46. {
  47. int discardCount = 1;
  48. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  49. selectHandEffect.SetUp(
  50. selectPlayer: card.Owner,
  51. canTargetCondition: (cardSource) => true,
  52. canTargetCondition_ByPreSelecetedList: null,
  53. canEndSelectCondition: null,
  54. maxCount: discardCount,
  55. canNoSelect: false,
  56. canEndNotMax: false,
  57. isShowOpponent: true,
  58. selectCardCoroutine: null,
  59. afterSelectCardCoroutine: null,
  60. mode: SelectHandEffect.Mode.Discard,
  61. cardEffect: activateClass);
  62. yield return StartCoroutine(selectHandEffect.Activate());
  63. }
  64. }
  65. }
  66. if (timing == EffectTiming.OnDiscardHand)
  67. {
  68. ActivateClass activateClass = new ActivateClass();
  69. activateClass.SetUpICardEffect("Play 1 Digimon card from trash", CanUseCondition, card);
  70. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  71. activateClass.SetHashString("Play_ST16_13");
  72. cardEffects.Add(activateClass);
  73. string EffectDiscription()
  74. {
  75. return "[All Turns][Once Per Turn] When one of your effects trashes a card in your hand, you may play 1 level 4 or lower purple Digimon card from your trash without paying the cost.";
  76. }
  77. bool CanSelectCardCondition(CardSource cardSource)
  78. {
  79. if (cardSource.IsDigimon)
  80. {
  81. if (cardSource.HasCardColor(CardColor.Purple))
  82. {
  83. if (cardSource.Level <= 4)
  84. {
  85. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  86. {
  87. if (cardSource.HasLevel)
  88. {
  89. return true;
  90. }
  91. }
  92. }
  93. }
  94. }
  95. return false;
  96. }
  97. bool CanUseCondition(Hashtable hashtable)
  98. {
  99. if (CardEffectCommons.IsExistOnBattleArea(card))
  100. {
  101. bool SkillCondition(ICardEffect cardEffect)
  102. {
  103. if (cardEffect != null)
  104. {
  105. if (cardEffect.EffectSourceCard != null)
  106. {
  107. if (cardEffect.EffectSourceCard.Owner == card.Owner)
  108. {
  109. return true;
  110. }
  111. }
  112. }
  113. return false;
  114. }
  115. if (CardEffectCommons.CanTriggerOnTrashHand(hashtable, SkillCondition, cardSource => cardSource.Owner == card.Owner))
  116. {
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. if (CardEffectCommons.IsExistOnBattleArea(card))
  125. {
  126. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  127. {
  128. return true;
  129. }
  130. }
  131. return false;
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  134. {
  135. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  136. {
  137. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  138. List<CardSource> selectedCards = new List<CardSource>();
  139. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  140. selectCardEffect.SetUp(
  141. canTargetCondition: CanSelectCardCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. canNoSelect: () => true,
  145. selectCardCoroutine: SelectCardCoroutine,
  146. afterSelectCardCoroutine: null,
  147. message: "Select 1 card to play.",
  148. maxCount: maxCount,
  149. canEndNotMax: false,
  150. isShowOpponent: true,
  151. mode: SelectCardEffect.Mode.Custom,
  152. root: SelectCardEffect.Root.Trash,
  153. customRootCardList: null,
  154. canLookReverseCard: true,
  155. selectPlayer: card.Owner,
  156. cardEffect: activateClass);
  157. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  158. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  159. yield return StartCoroutine(selectCardEffect.Activate());
  160. IEnumerator SelectCardCoroutine(CardSource cardSource)
  161. {
  162. selectedCards.Add(cardSource);
  163. yield return null;
  164. }
  165. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  166. }
  167. }
  168. }
  169. return cardEffects;
  170. }
  171. }