BT13_040.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT13
  5. {
  6. public class BT13_040 : 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.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.CardNames.Contains("Veemon");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.None)
  20. {
  21. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  22. }
  23. if (timing == EffectTiming.WhenRemoveField)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Draw 1 and play 1 [Veemon] from hand or this Digimon's digivolution cards", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  28. activateClass.SetHashString("DrawAndPlay_BT13_040");
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[All Turns] When this Digimon would leave the battle area, <Draw 1>. Then, you may play 1 [Veemon] from your hand or this Digimon's digivolution cards without paying the cost.";
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource.CardNames.Contains("Veemon"))
  37. {
  38. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (card.Owner.LibraryCards.Count >= 1)
  61. {
  62. return true;
  63. }
  64. if (card.Owner.HandCards.Count >= 1)
  65. {
  66. return true;
  67. }
  68. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  78. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  79. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  80. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  81. if (canSelectHand || canSelectDigivolutionCards)
  82. {
  83. if (canSelectHand && canSelectDigivolutionCards)
  84. {
  85. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  86. {
  87. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  88. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  89. };
  90. string selectPlayerMessage = "From which area do you play a card?";
  91. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  92. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  93. }
  94. else
  95. {
  96. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  97. }
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  99. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  100. List<CardSource> selectedCards = new List<CardSource>();
  101. IEnumerator SelectCardCoroutine(CardSource cardSource)
  102. {
  103. selectedCards.Add(cardSource);
  104. yield return null;
  105. }
  106. if (fromHand)
  107. {
  108. int maxCount = 1;
  109. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  110. selectHandEffect.SetUp(
  111. selectPlayer: card.Owner,
  112. canTargetCondition: CanSelectCardCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. maxCount: maxCount,
  116. canNoSelect: true,
  117. canEndNotMax: false,
  118. isShowOpponent: true,
  119. selectCardCoroutine: SelectCardCoroutine,
  120. afterSelectCardCoroutine: null,
  121. mode: SelectHandEffect.Mode.Custom,
  122. cardEffect: activateClass);
  123. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  124. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  125. yield return StartCoroutine(selectHandEffect.Activate());
  126. }
  127. else
  128. {
  129. int maxCount = 1;
  130. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  131. selectCardEffect.SetUp(
  132. canTargetCondition: CanSelectCardCondition,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. canNoSelect: () => true,
  136. selectCardCoroutine: SelectCardCoroutine,
  137. afterSelectCardCoroutine: null,
  138. message: "Select 1 card to play.",
  139. maxCount: maxCount,
  140. canEndNotMax: false,
  141. isShowOpponent: true,
  142. mode: SelectCardEffect.Mode.Custom,
  143. root: SelectCardEffect.Root.Custom,
  144. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  145. canLookReverseCard: true,
  146. selectPlayer: card.Owner,
  147. cardEffect: activateClass);
  148. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  149. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  150. yield return StartCoroutine(selectCardEffect.Activate());
  151. }
  152. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  153. if (!fromHand)
  154. {
  155. root = SelectCardEffect.Root.DigivolutionCards;
  156. }
  157. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  158. cardSources: selectedCards,
  159. activateClass: activateClass,
  160. payCost: false,
  161. isTapped: false,
  162. root: root,
  163. activateETB: true));
  164. }
  165. }
  166. }
  167. return cardEffects;
  168. }
  169. }
  170. }