BT13_016.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT13
  5. {
  6. public class BT13_016 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("This Digimon digivolves into 1 Digimon card with [Jesmon] in its name", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[Your Turn] When you play a Digimon with [Sistermon] in its name, this Digimon may digivolve into a Digimon card with [Jesmon] in its name in the hand for the digivolution cost. When this Digimon would digivolve by this effect, reduce the digivolution cost by 2.";
  20. }
  21. bool CanSelectCardCondition(CardSource cardSource)
  22. {
  23. return cardSource.IsDigimon && cardSource.ContainsCardName("Jesmon");
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. if (CardEffectCommons.IsExistOnBattleArea(card))
  28. {
  29. if (CardEffectCommons.IsOwnerTurn(card))
  30. {
  31. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, (permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent.TopCard.ContainsCardName("Sistermon")))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnBattleArea(card))
  42. {
  43. if (card.Owner.HandCards.Count >= 1)
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  53. targetPermanent: card.PermanentOfThisCard(),
  54. cardCondition: CanSelectCardCondition,
  55. payCost: true,
  56. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  57. fixedCostTuple: null,
  58. ignoreDigivolutionRequirementFixedCost: -1,
  59. isHand: true,
  60. activateClass: activateClass,
  61. successProcess: null));
  62. }
  63. }
  64. if (timing == EffectTiming.OnAllyAttack)
  65. {
  66. ActivateClass activateClass = new ActivateClass();
  67. activateClass.SetUpICardEffect("Play 1 Digimon card with [Sistermon] in its name", CanUseCondition, card);
  68. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  69. activateClass.SetIsInheritedEffect(true);
  70. activateClass.SetHashString("Play_BT13_016");
  71. cardEffects.Add(activateClass);
  72. string EffectDiscription()
  73. {
  74. return "[When Attacking][Once Per Turn] If this Digimon has the [Royal Knight] trait, you may play 1 Digimon card with [Sistermon] in its name from your hand or trash without paying the cost.";
  75. }
  76. bool CanSelectCardCondition(CardSource cardSource)
  77. {
  78. if (cardSource.IsDigimon)
  79. {
  80. if (cardSource.ContainsCardName("Sistermon"))
  81. {
  82. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  83. {
  84. return true;
  85. }
  86. }
  87. }
  88. return false;
  89. }
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  93. }
  94. bool CanActivateCondition(Hashtable hashtable)
  95. {
  96. if (CardEffectCommons.IsExistOnBattleArea(card))
  97. {
  98. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1 || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  99. {
  100. if (card.PermanentOfThisCard().TopCard.HasRoyalKnightTraits)
  101. {
  102. return true;
  103. }
  104. }
  105. }
  106. return false;
  107. }
  108. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  109. {
  110. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  111. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  112. if (canSelectHand || canSelectTrash)
  113. {
  114. if (canSelectHand && canSelectTrash)
  115. {
  116. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  117. {
  118. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  119. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  120. };
  121. string selectPlayerMessage = "From which area do you play a card?";
  122. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  123. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  124. }
  125. else
  126. {
  127. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  128. }
  129. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  130. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  131. List<CardSource> selectedCards = new List<CardSource>();
  132. IEnumerator SelectCardCoroutine(CardSource cardSource)
  133. {
  134. selectedCards.Add(cardSource);
  135. yield return null;
  136. }
  137. if (fromHand)
  138. {
  139. int maxCount = 1;
  140. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  141. selectHandEffect.SetUp(
  142. selectPlayer: card.Owner,
  143. canTargetCondition: CanSelectCardCondition,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. maxCount: maxCount,
  147. canNoSelect: true,
  148. canEndNotMax: false,
  149. isShowOpponent: true,
  150. selectCardCoroutine: SelectCardCoroutine,
  151. afterSelectCardCoroutine: null,
  152. mode: SelectHandEffect.Mode.Custom,
  153. cardEffect: activateClass);
  154. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  155. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  156. yield return StartCoroutine(selectHandEffect.Activate());
  157. }
  158. else
  159. {
  160. int maxCount = 1;
  161. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  162. selectCardEffect.SetUp(
  163. canTargetCondition: CanSelectCardCondition,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canEndSelectCondition: null,
  166. canNoSelect: () => true,
  167. selectCardCoroutine: SelectCardCoroutine,
  168. afterSelectCardCoroutine: null,
  169. message: "Select 1 card to play.",
  170. maxCount: maxCount,
  171. canEndNotMax: false,
  172. isShowOpponent: true,
  173. mode: SelectCardEffect.Mode.Custom,
  174. root: SelectCardEffect.Root.Trash,
  175. customRootCardList: null,
  176. canLookReverseCard: true,
  177. selectPlayer: card.Owner,
  178. cardEffect: activateClass);
  179. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  180. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  181. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  182. }
  183. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  184. if (!fromHand)
  185. {
  186. root = SelectCardEffect.Root.Trash;
  187. }
  188. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true));
  189. }
  190. }
  191. }
  192. return cardEffects;
  193. }
  194. }
  195. }