BT12_074.cs 13 KB

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