BT12_075.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_075 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasSaveText && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 2;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 0,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null));
  24. }
  25. if (timing == EffectTiming.OnEnterFieldAnyone)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Add 1 card from under your Tamer to hand", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  30. cardEffects.Add(activateClass);
  31. string EffectDiscription()
  32. {
  33. return "[On Play] You may return 1 Digimon card with <Save> in its text from under one of your Tamers to your hand.";
  34. }
  35. bool CanSelectCardCondition(CardSource cardSource)
  36. {
  37. if (cardSource.HasSaveText)
  38. {
  39. if (cardSource.IsDigimon)
  40. {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  49. {
  50. if (permanent.IsTamer)
  51. {
  52. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  78. {
  79. Permanent selectedPermanent = null;
  80. int maxCount = Math.Min(1, card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  81. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectPermanentCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: maxCount,
  88. canNoSelect: true,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: SelectPermanentCoroutine,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer.", "The opponent is selecting 1 Tamer.");
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  97. {
  98. selectedPermanent = permanent;
  99. yield return null;
  100. }
  101. if (selectedPermanent != null)
  102. {
  103. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  104. {
  105. maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  106. List<CardSource> selectedCards = new List<CardSource>();
  107. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  108. selectCardEffect.SetUp(
  109. canTargetCondition: CanSelectCardCondition,
  110. canTargetCondition_ByPreSelecetedList: null,
  111. canEndSelectCondition: null,
  112. canNoSelect: () => true,
  113. selectCardCoroutine: null,
  114. afterSelectCardCoroutine: null,
  115. message: "Select 1 digivolution card to add to your hand.",
  116. maxCount: maxCount,
  117. canEndNotMax: false,
  118. isShowOpponent: true,
  119. mode: SelectCardEffect.Mode.AddHand,
  120. root: SelectCardEffect.Root.Custom,
  121. customRootCardList: selectedPermanent.DigivolutionCards,
  122. canLookReverseCard: true,
  123. selectPlayer: card.Owner,
  124. cardEffect: activateClass);
  125. yield return StartCoroutine(selectCardEffect.Activate());
  126. }
  127. }
  128. }
  129. }
  130. }
  131. if (timing == EffectTiming.OnDestroyedAnyone)
  132. {
  133. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  134. }
  135. if (timing == EffectTiming.OnAllyAttack)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  139. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  140. activateClass.SetIsInheritedEffect(true);
  141. activateClass.SetHashString("Draw1_BT12_075");
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[When Attacking][Once Per Turn] If this Digimon has <Save> in its text, <Draw 1>. (Draw 1 card from your deck.)";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  150. }
  151. bool CanActivateCondition(Hashtable hashtable)
  152. {
  153. if (CardEffectCommons.IsExistOnBattleArea(card))
  154. {
  155. if (card.PermanentOfThisCard().TopCard.HasSaveText)
  156. {
  157. return true;
  158. }
  159. }
  160. return false;
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  163. {
  164. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  165. }
  166. }
  167. if (timing == EffectTiming.None)
  168. {
  169. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  170. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  171. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  172. addDigiXrosConditionClass.SetNotShowUI(true);
  173. cardEffects.Add(addDigiXrosConditionClass);
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return true;
  177. }
  178. DigiXrosCondition GetDigiXros(CardSource cardSource)
  179. {
  180. if (cardSource == card)
  181. {
  182. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Digimon card with <Save> in text");
  183. bool CanSelectCardCondition(CardSource cardSource)
  184. {
  185. if (cardSource != null)
  186. {
  187. if (cardSource.Owner == card.Owner)
  188. {
  189. if (cardSource.IsDigimon)
  190. {
  191. if (cardSource.HasSaveText)
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. }
  198. return false;
  199. }
  200. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element };
  201. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  202. return digiXrosCondition;
  203. }
  204. return null;
  205. }
  206. }
  207. return cardEffects;
  208. }
  209. }
  210. }